Using Permissions on individual Sanctum Tokens #2625
Unanswered
nilskretschmer
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have a use case in my application that requires individual permissions on Laravel Sanctum tokens. The tokens belong to the same user (service account), but each token has different permissions.
As I already integrated this package I am thinking about how to solve the problem using roles and permissions on individual tokens. I have a lot of fine-grained permissions based on the wildcard permissions feature (permissions on model instances). Laravel Sanctum already includes a database field
abilities
for each Sanctum token. But this is atext
-column and I am not sure if it is suited for fine-grained permissions.I think the following approach would be nice, but I am not sure if this is possible using this package:
These permissions can be already existing permissions that are shared with the default web guard/routes
can
-methodsSome problems I already found on investigating this package and Laravel Sanctum:
class PersonalAccessToken extends Model implements HasAbilities
This already enforces the implementation of a
can
-method that is a bit different from thecan-
-method of Laravel'sAuthorizable
-Trait.Authorizable
-Trait, because it distinguishes from theHasAbilities
-InterfaceAuthorizable
-TraitSo the question is:
How could I integrate Spatie Permissions on individual Sanctum tokens?
Beta Was this translation helpful? Give feedback.
All reactions