Repository navigation
feat: show permission guards in the starter templates - #152
Merged
Merged
Conversation
Each API starter and the Next.js starter serves GET /reports behind its adapter's permission guard for reports:read, beside the betaUser role route. The web and mobile starters show the reports only to a holder of reports:read, with the server guard as what enforces. READMEs and AGENTS.md carry the steps to create the permission and grant it to a role, and say that it needs auth API v0.23: on v0.22 the guard answers 403 to everyone. Moves the starters to the adapter and SDK releases that carry the guard and the client permission helpers. Closes #149
The starters granted the example permission through the existing betaUser role. A role of its own keeps the permission example apart from the role example, so the steps now add reportViewer to available_roles first.
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.
Closes #149. Every starter now shows a permission check: the server starters guard a route with their adapter's permission guard, and the UI starters show content only to a holder of the permission.
Merge with the auth API v0.23.0 release, not before. On API v0.22 no token carries permissions, so the new route answers 403 to everyone, and "works out of the box" only holds once v0.23.0 ships (fells-code/seamless-auth-api#566). The comments and READMEs say so.
What
reports:read. It is the example used in the adapter docs, and with one name a single grant opens both the route and the UI in whichever starters you combine.GET /reportsbeside/beta_users:requirePermissionrequirePermissionas apreHandlerauth.RequirePermission, through a smalladapterGuardhelper thatrequireSessionnow sharesauth.require_permissionas a route layerRequireUser(auth, permissions=[...])/api/reportswithrequirePermissionhasPermission:ReportsPanelcomponent, fromshared/react-appand synced into eachReportsAccesson the Beta pagereportViewerrole toavailable_roles(console system config, orseamless config set available_roles), createreports:readand grant it toreportViewer, through the console's Roles page orPOST /admin/permissionsandPUT /admin/roles/instance/reportViewer/permissions(both needadmin:writeand step-up), give your user the role, then sign in again. The Roles page is not in a console release yet, and the READMEs say so.seamless-auth-gov0.6.0, Rustseamless-auth0.6, Pythonseamless-auth[fastapi]0.6Behavior notes
detailtoerror). The template never readdetail, and its 401 test now asserts{"error":"unauthenticated"}. The template's ownrequire_rolestill answers{"detail":"forbidden"}, which this leaves alone./authroutes only, the template routes are GETs, and client 0.9.0 sends the transport header.For review
beta_userwhere the code usesbetaUser.Testing
npm run validate,format:check,sync-shared --checkand the pre-commit hook all pass.npm run checkandnpm run build, on Node 24.gofmt,go vetandgo test.cargo fmt --check,clippy -D warningsandcargo test --locked.uv sync --locked,ruff,mypyandpytest.docker build --target runtimefor Gin, Axum and FastAPI, and its Node 22 and latest matrix