Repository navigation
Add an admin page for API tokens - #569
Merged
Merged
Conversation
The new API Tokens resource lists Sanctum tokens, creates them for a chosen user with abilities picked from checkboxes and an optional expiry, shows the new token once with a copy button, and revokes them. The known abilities are an ApiAbility enum, which the v1 route middleware now uses too.
21 tasks done
This was referenced Oct 17, 2026
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.
Adds an API Tokens page to the Filament admin (Secondary group), so Sanctum tokens no longer have to be made or revoked in tinker. It's needed to test #568 on development and for #551.
The page
$user->createToken(), so it's stored hashed as before.canAccessPanel()checksisAdmin().Abilities in one place
The known abilities are now an
ApiAbilityenum. The page's checkboxes and the route middleware both use it:ApiAbility::middleware()builds theability:string for the v1 group (all abilities), the WeDigBio dashboard route (its four) and the projects and expeditions routes (public:read). The middleware strings are unchanged (checked withroute:list).Tested locally
tests/Feature/Admin/ApiTokenResourceTest.php: non-admins get 403; the list shows tokens with owner and abilities; creating saves the chosen abilities and expiry; the new token is queued for the modal only once; it works as a bearer token on/v1/projectsand gets 403 on the WeDigBio dashboard; no ability or an unknown one (*) is rejected; revoking deletes the token.tests/Feature/Admin/ApiTokenResourceTest.phpandtests/Feature/Api: 24 passed.To verify on development
See #567.