Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
afe3ad1
feat(authz): GetEntitlementsV2 protos and gencode
jakedoublev Apr 28, 2025
c547edc
fix copilot-flagged comment
jakedoublev Apr 28, 2025
8843729
proto fixes
jakedoublev Apr 29, 2025
65fd691
put back auth service change accidentally committed
jakedoublev Apr 29, 2025
288592d
latest changes
jakedoublev Apr 29, 2025
999a876
draft v2 protos
jakedoublev Apr 29, 2025
50d8436
put back original authz protos
jakedoublev Apr 29, 2025
6993846
Merge branch 'main' into feat/entitle-actions-protos
jakedoublev Apr 30, 2025
88c25d2
undo change to original authn proto file
ryanulit Apr 30, 2025
b3c41f3
rename reg res fqn to use value
ryanulit Apr 30, 2025
13cf017
add entity chain comment
ryanulit Apr 30, 2025
ec22eb2
Merge branch 'main' into feat/entitle-actions-protos
ryanulit Apr 30, 2025
decdd36
Merge branch 'main' into feat/entitle-actions-protos
ryanulit Apr 30, 2025
7e9e22b
rename bulk methods to use same prefix
ryanulit Apr 30, 2025
2364f25
update protos per meeting outcome
jakedoublev Apr 30, 2025
c25a26f
cleanup
jakedoublev Apr 30, 2025
8d3b5ca
Merge branch 'main' into feat/entitle-actions-protos
jakedoublev May 1, 2025
fe76f4b
Merge branch 'main' into feat/entitle-actions-protos
jakedoublev May 4, 2025
03651a8
ERS should take new authv2 entity proto
jakedoublev May 5, 2025
5dad8b5
Merge remote-tracking branch 'origin' into feat/entitle-actions-protos
jakedoublev May 5, 2025
999428f
auth v2 service scaffold and versioned registration/sdk
ryanulit May 6, 2025
095d515
add proper deprecated comments
ryanulit May 6, 2025
aade0d6
remove non-proto changes moved to separate branch
ryanulit May 6, 2025
76390ab
Merge remote-tracking branch 'origin' into feat/entitle-actions-protos
jakedoublev May 6, 2025
8833bcb
Merge branch 'main' into feat/entitle-actions-protos
jakedoublev May 7, 2025
944a7a8
drop scope from GetEntitlements
jakedoublev May 8, 2025
ab1fc4f
comment clarity
jakedoublev May 8, 2025
120ba08
Merge branch 'main' into feat/entitle-actions-protos
jakedoublev May 9, 2025
038cf7d
Merge branch 'main' into feat/entitle-actions-protos
jakedoublev May 13, 2025
6cfb545
update protos
jakedoublev May 13, 2025
8be0ff6
improve protovalidate rules
jakedoublev May 13, 2025
0fdab47
improve protovalidate rules
jakedoublev May 13, 2025
be2118d
GetDecisionByTokenMultiResource addition
jakedoublev May 13, 2025
066cb55
deprecated comments
jakedoublev May 13, 2025
f003f41
use v1 messages in v2 authz where it makes sense (token and entity ch…
jakedoublev May 13, 2025
75b37bd
rm extraneous resource ID
jakedoublev May 13, 2025
d4444b8
pare back responses, proto comments, better validation
jakedoublev May 13, 2025
0ddaeea
ERS v2 after PR review discussion
jakedoublev May 13, 2025
2317e79
feat(core): auth v2 with breaking changes to auth v1 protos (#2211)
jakedoublev May 14, 2025
8ee0b3b
make no changes at all to authz v1
jakedoublev May 14, 2025
1c5a1a9
proto comments
jakedoublev May 14, 2025
67bc23c
field names
jakedoublev May 14, 2025
1782f18
entity identifier proto name
jakedoublev May 14, 2025
7f50caa
proto comments
jakedoublev May 14, 2025
96d86d7
fix misnumbered index called out by copilot
jakedoublev May 14, 2025
33d98c7
rm empty commits to unchanged proto files
jakedoublev May 14, 2025
33dc394
validation PR suggestion
jakedoublev May 14, 2025
c75ca96
Merge branch 'main' into DSPX-1053-auth-svc-versioning-strategy
jakedoublev May 20, 2025
a0fc6a3
use auth v2 in sdk
jakedoublev May 20, 2025
f6d40af
service registry appending version to service logs
jakedoublev May 20, 2025
a8794d7
auth svc stubs
jakedoublev May 20, 2025
74e9606
lint fix
jakedoublev May 20, 2025
420f87d
lint fix
jakedoublev May 20, 2025
b45e5a7
v2 ERS
jakedoublev May 20, 2025
2328fb3
rm unused variable
jakedoublev May 20, 2025
3426199
cleanup
jakedoublev May 20, 2025
598c8f3
tweak
jakedoublev May 20, 2025
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
13 changes: 8 additions & 5 deletions sdk/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/opentdf/platform/lib/ocrypto"
"github.com/opentdf/platform/protocol/go/authorization"
authorizationV2 "github.com/opentdf/platform/protocol/go/authorization/v2"
"github.com/opentdf/platform/protocol/go/entityresolution"
entityresolutionV2 "github.com/opentdf/platform/protocol/go/entityresolution/v2"
"github.com/opentdf/platform/protocol/go/policy"
Expand Down Expand Up @@ -71,6 +72,7 @@ type SDK struct {
Actions actions.ActionServiceClient
Attributes attributes.AttributesServiceClient
Authorization authorization.AuthorizationServiceClient
AuthorizationV2 authorizationV2.AuthorizationServiceClient
EntityResoution entityresolution.EntityResolutionServiceClient
EntityResolutionV2 entityresolutionV2.EntityResolutionServiceClient
KeyAccessServerRegistry kasregistry.KeyAccessServerRegistryServiceClient
Expand Down Expand Up @@ -208,16 +210,17 @@ func New(platformEndpoint string, opts ...Option) (*SDK, error) {
tokenSource: accessTokenSource,
Actions: actions.NewActionServiceClient(platformConn),
Attributes: attributes.NewAttributesServiceClient(platformConn),
Authorization: authorization.NewAuthorizationServiceClient(platformConn),
AuthorizationV2: authorizationV2.NewAuthorizationServiceClient(platformConn),
EntityResoution: entityresolution.NewEntityResolutionServiceClient(ersConn),
EntityResolutionV2: entityresolutionV2.NewEntityResolutionServiceClient(ersConn),
KeyAccessServerRegistry: kasregistry.NewKeyAccessServerRegistryServiceClient(platformConn),
KeyManagement: keymanagement.NewKeyManagementServiceClient(platformConn),
Namespaces: namespaces.NewNamespaceServiceClient(platformConn),
RegisteredResources: registeredresources.NewRegisteredResourcesServiceClient(platformConn),
ResourceMapping: resourcemapping.NewResourceMappingServiceClient(platformConn),
SubjectMapping: subjectmapping.NewSubjectMappingServiceClient(platformConn),
Unsafe: unsafe.NewUnsafeServiceClient(platformConn),
KeyAccessServerRegistry: kasregistry.NewKeyAccessServerRegistryServiceClient(platformConn),
Authorization: authorization.NewAuthorizationServiceClient(platformConn),
EntityResoution: entityresolution.NewEntityResolutionServiceClient(ersConn),
EntityResolutionV2: entityresolutionV2.NewEntityResolutionServiceClient(ersConn),
KeyManagement: keymanagement.NewKeyManagementServiceClient(platformConn),
wellknownConfiguration: wellknownconfiguration.NewWellKnownServiceClient(platformConn),
}, nil
}
Expand Down
80 changes: 80 additions & 0 deletions service/authorization/v2/authorization.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package authorization

import (
"context"
"errors"

"connectrpc.com/connect"
authzV2 "github.com/opentdf/platform/protocol/go/authorization/v2"
authzV2Connect "github.com/opentdf/platform/protocol/go/authorization/v2/authorizationv2connect"
otdf "github.com/opentdf/platform/sdk"
"github.com/opentdf/platform/service/logger"
"github.com/opentdf/platform/service/pkg/serviceregistry"
"go.opentelemetry.io/otel/trace"
)

type Service struct {
sdk *otdf.SDK
config *Config
logger *logger.Logger
trace.Tracer
}

type Config struct{}

func NewRegistration() *serviceregistry.Service[authzV2Connect.AuthorizationServiceHandler] {
as := new(Service)

return &serviceregistry.Service[authzV2Connect.AuthorizationServiceHandler]{
ServiceOptions: serviceregistry.ServiceOptions[authzV2Connect.AuthorizationServiceHandler]{
Namespace: "authorization",
Version: "v2",
ServiceDesc: &authzV2.AuthorizationService_ServiceDesc,
ConnectRPCFunc: authzV2Connect.NewAuthorizationServiceHandler,
RegisterFunc: func(srp serviceregistry.RegistrationParams) (authzV2Connect.AuthorizationServiceHandler, serviceregistry.HandlerServer) {
authZCfg := new(Config)

logger := srp.Logger

// default ERS endpoint
as.sdk = srp.SDK
as.logger = logger
// if err := srp.RegisterReadinessCheck("authorization", as.IsReady); err != nil {
// logger.Error("failed to register authorization readiness check", slog.String("error", err.Error()))
// }

as.config = authZCfg
as.Tracer = srp.Tracer
logger.Debug("authorization v2 service register func")

return as, nil
},
},
}
}

// TODO: uncomment after v1 is deprecated, as cannot have more than one readiness check under a namespace
// func (as Service) IsReady(ctx context.Context) error {
// as.logger.TraceContext(ctx, "checking readiness of authorization service")
// return nil
// }

// GetEntitlements for an entity chain
func (as *Service) GetEntitlements(_ context.Context, _ *connect.Request[authzV2.GetEntitlementsRequest]) (*connect.Response[authzV2.GetEntitlementsResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("GetEntitlements not implemented"))
}

// GetDecision for an entity chain and an action on a single resource
func (as *Service) GetDecision(_ context.Context, _ *connect.Request[authzV2.GetDecisionRequest]) (*connect.Response[authzV2.GetDecisionResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("GetDecision not implemented"))
}

// GetDecisionMultiResource for an entity chain and action on multiple resources
func (as *Service) GetDecisionMultiResource(_ context.Context, _ *connect.Request[authzV2.GetDecisionMultiResourceRequest]) (*connect.Response[authzV2.GetDecisionMultiResourceResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("GetDecisionMultiResource not implemented"))
}

// GetDecisionBulk for multiple requests, each comprising a combination of entity chain, action, and one or more resources
func (as *Service) GetDecisionBulk(_ context.Context, _ *connect.Request[authzV2.GetDecisionBulkRequest]) (*connect.Response[authzV2.GetDecisionBulkResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("GetDecisionBulk not implemented"))
}
1 change: 1 addition & 0 deletions service/entityresolution/v2/entity_resolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func NewRegistration() *serviceregistry.Service[entityresolutionv2connect.Entity
return &serviceregistry.Service[entityresolutionv2connect.EntityResolutionServiceHandler]{
ServiceOptions: serviceregistry.ServiceOptions[entityresolutionv2connect.EntityResolutionServiceHandler]{
Namespace: "entityresolution",
Version: "v2",
ServiceDesc: &ersV2.EntityResolutionService_ServiceDesc,
ConnectRPCFunc: entityresolutionv2connect.NewEntityResolutionServiceHandler,
RegisterFunc: func(srp serviceregistry.RegistrationParams) (entityresolutionv2connect.EntityResolutionServiceHandler, serviceregistry.HandlerServer) {
Expand Down
6 changes: 6 additions & 0 deletions service/pkg/server/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/go-viper/mapstructure/v2"
"github.com/opentdf/platform/sdk"
"github.com/opentdf/platform/service/authorization"
authorizationV2 "github.com/opentdf/platform/service/authorization/v2"
"github.com/opentdf/platform/service/entityresolution"
entityresolutionV2 "github.com/opentdf/platform/service/entityresolution/v2"
"github.com/opentdf/platform/service/health"
Expand Down Expand Up @@ -70,6 +71,7 @@ func registerCoreServices(reg serviceregistry.Registry, mode []string) ([]string
registeredServices = append(registeredServices, []string{servicePolicy, serviceAuthorization, serviceKAS, serviceWellKnown, serviceEntityResolution}...)
services = append(services, []serviceregistry.IService{
authorization.NewRegistration(),
authorizationV2.NewRegistration(),
kas.NewRegistration(),
wellknown.NewRegistration(),
entityresolution.NewRegistration(),
Expand All @@ -80,6 +82,7 @@ func registerCoreServices(reg serviceregistry.Registry, mode []string) ([]string
registeredServices = append(registeredServices, []string{servicePolicy, serviceAuthorization, serviceWellKnown}...)
services = append(services, []serviceregistry.IService{
authorization.NewRegistration(),
authorizationV2.NewRegistration(),
wellknown.NewRegistration(),
}...)
services = append(services, policy.NewRegistrations()...)
Expand Down Expand Up @@ -165,6 +168,9 @@ func startServices(ctx context.Context, cfg *config.Config, otdf *server.OpenTDF
return err
}
}
if svc.GetVersion() != "" {
svcLogger = svcLogger.With("version", svc.GetVersion())
}

err = svc.Start(ctx, serviceregistry.RegistrationParams{
Config: cfg.Services[svc.GetNamespace()],
Expand Down
20 changes: 11 additions & 9 deletions service/pkg/server/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ type mockTestServiceOptions struct {
dbRegister serviceregistry.DBRegister
}

const numExpectedPolicyServices = 9
const (
numExpectedPolicyServices = 9
numExpectedEntityResolutionServiceVersions = 2
numExpectedAuthorizationServiceVersions = 2
)

func mockTestServiceRegistry(opts mockTestServiceOptions) (serviceregistry.IService, *spyTestService) {
spy := &spyTestService{}
Expand Down Expand Up @@ -104,7 +108,7 @@ func (suite *ServiceTestSuite) Test_RegisterCoreServices_In_Mode_ALL_Expect_All_

authz, err := registry.GetNamespace(serviceAuthorization)
suite.Require().NoError(err)
suite.Len(authz.Services, 1)
suite.Len(authz.Services, numExpectedAuthorizationServiceVersions)
suite.Equal(modeCore, authz.Mode)

kas, err := registry.GetNamespace(serviceKAS)
Expand All @@ -124,8 +128,7 @@ func (suite *ServiceTestSuite) Test_RegisterCoreServices_In_Mode_ALL_Expect_All_

ers, err := registry.GetNamespace(serviceEntityResolution)
suite.Require().NoError(err)
ersServiceVersionsCount := 2
suite.Len(ers.Services, ersServiceVersionsCount)
suite.Len(ers.Services, numExpectedEntityResolutionServiceVersions)
suite.Equal(modeCore, ers.Mode)
}

Expand All @@ -137,7 +140,7 @@ func (suite *ServiceTestSuite) Test_RegisterCoreServices_In_Mode_Core_Expect_Cor

authz, err := registry.GetNamespace(serviceAuthorization)
suite.Require().NoError(err)
suite.Len(authz.Services, 1)
suite.Len(authz.Services, numExpectedAuthorizationServiceVersions)
suite.Equal(modeCore, authz.Mode)

_, err = registry.GetNamespace(serviceKAS)
Expand All @@ -163,7 +166,7 @@ func (suite *ServiceTestSuite) Test_RegisterServices_In_Mode_Core_Plus_Kas_Expec

authz, err := registry.GetNamespace(serviceAuthorization)
suite.Require().NoError(err)
suite.Len(authz.Services, 1)
suite.Len(authz.Services, numExpectedAuthorizationServiceVersions)
suite.Equal(modeCore, authz.Mode)

kas, err := registry.GetNamespace(serviceKAS)
Expand All @@ -190,7 +193,7 @@ func (suite *ServiceTestSuite) Test_RegisterServices_In_Mode_Core_Plus_Kas_Expec

authz, err := registry.GetNamespace(serviceAuthorization)
suite.Require().NoError(err)
suite.Len(authz.Services, 1)
suite.Len(authz.Services, numExpectedAuthorizationServiceVersions)
suite.Equal(modeCore, authz.Mode)

kas, err := registry.GetNamespace(serviceKAS)
Expand All @@ -210,8 +213,7 @@ func (suite *ServiceTestSuite) Test_RegisterServices_In_Mode_Core_Plus_Kas_Expec

ers, err := registry.GetNamespace(serviceEntityResolution)
suite.Require().NoError(err)
ersServiceVersionsCount := 2
suite.Len(ers.Services, ersServiceVersionsCount)
suite.Len(ers.Services, numExpectedEntityResolutionServiceVersions)
suite.Equal(modeERS, ers.Mode)
}

Expand Down
14 changes: 13 additions & 1 deletion service/pkg/serviceregistry/serviceregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type IService interface {
IsDBRequired() bool
DBMigrations() *embed.FS
GetNamespace() string
GetVersion() string
GetServiceDesc() *grpc.ServiceDesc
Start(ctx context.Context, params RegistrationParams) error
IsStarted() bool
Expand Down Expand Up @@ -99,6 +100,8 @@ type ServiceOptions[S any] struct {
// Namespace is the namespace of the service. One or more gRPC services can be registered under
// the same namespace.
Namespace string
// Version is the major version of the service according to the protocol buffer definition.
Version string
// ServiceDesc is the gRPC service descriptor. For non-gRPC services, this can be mocked out,
// but at minimum, the ServiceName field must be set
ServiceDesc *grpc.ServiceDesc
Expand All @@ -120,6 +123,10 @@ func (s Service[S]) GetNamespace() string {
return s.Namespace
}

func (s Service[S]) GetVersion() string {
return s.Version
}

func (s Service[S]) GetServiceDesc() *grpc.ServiceDesc {
return s.ServiceDesc
}
Expand Down Expand Up @@ -219,6 +226,7 @@ func (s Service[S]) RegisterGRPCGatewayHandler(ctx context.Context, mux *runtime
// namespace represents a namespace in the service registry.
type Namespace struct {
Mode string
Version string
Services []IService
}

Expand Down Expand Up @@ -258,7 +266,11 @@ func (reg Registry) RegisterService(svc IService, mode string) error {
return fmt.Errorf("service already registered namespace:%s service:%s", svc.GetNamespace(), svc.GetServiceDesc().ServiceName)
}

slog.Info("registered service", slog.String("namespace", svc.GetNamespace()), slog.String("service", svc.GetServiceDesc().ServiceName))
slog.Info(
"registered service",
slog.String("namespace", svc.GetNamespace()),
slog.String("service", svc.GetServiceDesc().ServiceName),
)
copyNamespace.Services = append(copyNamespace.Services, svc)

reg[svc.GetNamespace()] = copyNamespace
Expand Down
Loading