feat(ai-autopilot): compose vike-rbac for roles/permissions#195
Merged
Conversation
Add a vike-rbac-composer persona to vikeExtensionPersonas (between auth and crud) so the composed build declares permissions with definePermissions and routes every guard through can()/hasRole(), seeded from the registry with seedRbac(), instead of hand-rolling a roles/permissions schema and checker. vike-rbac is the guard subject vike-admin and vike-actions are built around. No runtime change. Closes #194.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The last authz gap in the composed stack. #191's crud composer teaches ad-hoc
user.role === 'admin'checks (fine for signed-in-vs-not), but past that the vike-data way iscan(user, permission)from vike-rbac — and without a persona the agent hand-rolls a roles/permissions schema + checker, the security-sensitive churn we compose to avoid. vike-rbac is also the guard subject vike-admin ("vike-auth resolves the user, vike-rbac enriches roles/permissions, the guard runs") and vike-actions (guard: (ctx) => can(ctx.user, 'posts.publish')) are built around. Same lever as before: a persona, no runtime change.What changed
vike-rbac-composerpersona, wired intovikeExtensionPersonasbetween auth and crud (so crud/actions guards can delegate to it).definePermissions([{ name, roles }])+extends: ['import:vike-rbac/config:default'](self-installs vike-auth) +defaultRoles; one check everywhere viacan()/hasRole()(route crudcanView/canEdit, page guards, session scope, and vike-actions guards through it instead of ad-hoc role fields); seed from the registry withseedRbac()/assignRoles(); guarded RPCs viarequirePermission(). Do NOT model theroles/permissions/role_user/permission_roletables by hand.definePermissions/can(user, permission)/seedRbac/ no hand-rolled RBAC tables;vikeExtensionPersonasorder updated.API verification
Cross-checked against the real vike-rbac public API in vike-data (README + exports):
definePermissions/can/hasRolefromvike-rbac,import:vike-rbac/config:default+defaultRoles,seedRbac/assignRolesfromvike-rbac/seed,requirePermissionfromvike-rbac/telefunc.Notes
Part of #186. Closes #194.