Update RBAC on console

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2025-12-23 09:04:26 +01:00
parent 72831d4c2b
commit e9ac50d91c
26 changed files with 2123 additions and 1444 deletions

View File

@@ -30,7 +30,34 @@ func (r *Resolver) MustBeAuthorized(ctx context.Context, entityID gid.GID, actio
credentialID = &apiKey.ID
}
err := r.iamSvc.LegacyAccessManagementService.Authorize(ctx, user.ID, credentialID, entityID, action)
// When API key is used, fall back to legacy system for intersection semantics.
// The legacy system handles API key role checking properly.
// TODO: Migrate API key authorization to new system.
if credentialID != nil {
err := r.iamSvc.LegacyAccessManagementService.Authorize(ctx, user.ID, credentialID, entityID, action)
if err != nil {
panic(err)
}
return
}
// Map legacy action to new namespaced action
newAction, ok := probo.MapLegacyAction(entityID.EntityType(), action)
if !ok {
// Fall back to legacy system for unmapped actions
err := r.iamSvc.LegacyAccessManagementService.Authorize(ctx, user.ID, credentialID, entityID, action)
if err != nil {
panic(err)
}
return
}
// Use new authorizer with mapped action
err := r.iamSvc.Authorizer.Authorize(ctx, iam.AuthorizeParams{
Principal: user.ID,
Resource: entityID,
Action: newAction,
})
if err != nil {
panic(err)
}