Skip to content

Commit 5fdb259

Browse files
AmanGIT07claude
andauthored
feat(userpat): route policy writes through membership; enforce 1 role per scope (#1668)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2554d4a commit 5fdb259

9 files changed

Lines changed: 595 additions & 467 deletions

File tree

cmd/serve.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ func buildAPIDependencies(
488488
metaschemaRepository := postgres.NewMetaSchemaRepository(logger, dbc)
489489
metaschemaService := metaschema.NewService(metaschemaRepository)
490490

491-
userPATService := userpat.NewService(logger, userPATRepo, cfg.App.PAT, organizationService, roleService, policyService, projectService, auditRecordRepository)
491+
userPATService := userpat.NewService(logger, userPATRepo, cfg.App.PAT, organizationService, roleService, membershipService, projectService, auditRecordRepository)
492492
membershipService.SetUserPATService(userPATService)
493493
patAlertService := userpat.NewAlertService(userPATRepo, userService, organizationService, mailDialer, dbc, cfg.App.PAT.Alert, logger, auditRecordRepository)
494494
auditRecordService := auditrecord.NewService(auditRecordRepository, userService, serviceUserService, sessionService, userPATService)

core/userpat/errors/errors.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ var (
1717
ErrScopeMismatch = errors.New("role does not support the specified scope")
1818
ErrRoleNotFound = errors.New("one or more requested roles do not exist")
1919
ErrProjectForbidden = errors.New("user does not have access to one or more specified projects")
20+
ErrDuplicateScope = errors.New("only one role per resource type is allowed")
2021
)

core/userpat/mocks/membership_service.go

Lines changed: 293 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)