Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions service/authorization/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
attr "github.com/opentdf/platform/protocol/go/policy/attributes"
"github.com/opentdf/platform/protocol/go/policy/subjectmapping"
otdf "github.com/opentdf/platform/sdk"
ent "github.com/opentdf/platform/service/entity"
"github.com/opentdf/platform/service/internal/access"
"github.com/opentdf/platform/service/internal/entitlements"
"github.com/opentdf/platform/service/internal/subjectmappingbuiltin"
Expand All @@ -38,8 +39,6 @@ import (
"google.golang.org/grpc/status"
)

const EntityIDPrefix string = "entity_idx_"

var ErrEmptyStringAttribute = errors.New("resource attributes must have at least one attribute value fqn")

type AuthorizationService struct { //nolint:revive // AuthorizationService is a valid name for this struct
Expand Down Expand Up @@ -415,7 +414,7 @@ func (as *AuthorizationService) GetEntitlements(ctx context.Context, req *connec
// Ensure the entity has an ID
entityID := entity.GetId()
if entityID == "" {
entityID = EntityIDPrefix + strconv.Itoa(idx)
entityID = ent.EntityIDPrefix + strconv.Itoa(idx)
}
// Check to maksure if the value is a list. Good validation if someone customizes the rego policy
entityEntitlements, valueListOk := resultsEntitlements[entityID].([]interface{})
Expand Down Expand Up @@ -637,7 +636,7 @@ func (as *AuthorizationService) getDecisions(ctx context.Context, dr *authorizat
for entIdx, e := range ecEntitlements.Msg.GetEntitlements() {
entityID := e.GetEntityId()
if entityID == "" {
entityID = EntityIDPrefix + strconv.Itoa(entIdx)
entityID = ent.EntityIDPrefix + strconv.Itoa(entIdx)
}
entityCategory := entities[entIdx].GetCategory()
auditECEntitlements = append(auditECEntitlements, audit.EntityChainEntitlement{
Expand Down
3 changes: 3 additions & 0 deletions service/entity/entity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package entity

const EntityIDPrefix string = "entity_idx_"
4 changes: 2 additions & 2 deletions service/entityresolution/claims/entity_resolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/lestrrat-go/jwx/v2/jwt"
"github.com/opentdf/platform/protocol/go/authorization"
"github.com/opentdf/platform/protocol/go/entityresolution"
auth "github.com/opentdf/platform/service/authorization"
"github.com/opentdf/platform/service/entity"
"github.com/opentdf/platform/service/logger"
"github.com/opentdf/platform/service/pkg/config"
"github.com/opentdf/platform/service/pkg/serviceregistry"
Expand Down Expand Up @@ -90,7 +90,7 @@ func EntityResolution(_ context.Context,
// make sure the id field is populated
originialID := ident.GetId()
if originialID == "" {
originialID = auth.EntityIDPrefix + strconv.Itoa(idx)
originialID = entity.EntityIDPrefix + strconv.Itoa(idx)
}
resolvedEntities = append(
resolvedEntities,
Expand Down
4 changes: 2 additions & 2 deletions service/entityresolution/claims/v2/entity_resolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/lestrrat-go/jwx/v2/jwt"
"github.com/opentdf/platform/protocol/go/entity"
entityresolutionV2 "github.com/opentdf/platform/protocol/go/entityresolution/v2"
auth "github.com/opentdf/platform/service/authorization"
ent "github.com/opentdf/platform/service/entity"
"github.com/opentdf/platform/service/logger"
"github.com/opentdf/platform/service/pkg/config"
"github.com/opentdf/platform/service/pkg/serviceregistry"
Expand Down Expand Up @@ -90,7 +90,7 @@ func EntityResolution(_ context.Context,
// make sure the id field is populated
originialID := ident.GetEphemeralId()
if originialID == "" {
originialID = auth.EntityIDPrefix + strconv.Itoa(idx)
originialID = ent.EntityIDPrefix + strconv.Itoa(idx)
}
resolvedEntities = append(
resolvedEntities,
Expand Down
6 changes: 3 additions & 3 deletions service/entityresolution/keycloak/entity_resolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/lestrrat-go/jwx/v2/jwt"
"github.com/opentdf/platform/protocol/go/authorization"
"github.com/opentdf/platform/protocol/go/entityresolution"
auth "github.com/opentdf/platform/service/authorization"
"github.com/opentdf/platform/service/entity"
"github.com/opentdf/platform/service/logger"
"github.com/opentdf/platform/service/pkg/config"
"github.com/opentdf/platform/service/pkg/serviceregistry"
Expand Down Expand Up @@ -184,7 +184,7 @@ func EntityResolution(ctx context.Context,
// make sure the id field is populated
originialID := ident.GetId()
if originialID == "" {
originialID = auth.EntityIDPrefix + strconv.Itoa(idx)
originialID = entity.EntityIDPrefix + strconv.Itoa(idx)
}
resolvedEntities = append(
resolvedEntities,
Expand Down Expand Up @@ -299,7 +299,7 @@ func EntityResolution(ctx context.Context,
// make sure the id field is populated
originialID := ident.GetId()
if originialID == "" {
originialID = auth.EntityIDPrefix + strconv.Itoa(idx)
originialID = entity.EntityIDPrefix + strconv.Itoa(idx)
}
resolvedEntities = append(
resolvedEntities,
Expand Down
6 changes: 3 additions & 3 deletions service/entityresolution/keycloak/v2/entity_resolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/lestrrat-go/jwx/v2/jwt"
"github.com/opentdf/platform/protocol/go/entity"
entityresolutionV2 "github.com/opentdf/platform/protocol/go/entityresolution/v2"
auth "github.com/opentdf/platform/service/authorization"
ent "github.com/opentdf/platform/service/entity"
"github.com/opentdf/platform/service/logger"
"github.com/opentdf/platform/service/pkg/config"
"github.com/opentdf/platform/service/pkg/serviceregistry"
Expand Down Expand Up @@ -184,7 +184,7 @@ func EntityResolution(ctx context.Context,
// make sure the id field is populated
originialID := ident.GetEphemeralId()
if originialID == "" {
originialID = auth.EntityIDPrefix + strconv.Itoa(idx)
originialID = ent.EntityIDPrefix + strconv.Itoa(idx)
}
resolvedEntities = append(
resolvedEntities,
Expand Down Expand Up @@ -299,7 +299,7 @@ func EntityResolution(ctx context.Context,
// make sure the id field is populated
originialID := ident.GetEphemeralId()
if originialID == "" {
originialID = auth.EntityIDPrefix + strconv.Itoa(idx)
originialID = ent.EntityIDPrefix + strconv.Itoa(idx)
}
resolvedEntities = append(
resolvedEntities,
Expand Down
Loading