Sanctum default has all abilities #55185
Unanswered
ChrisSantiago82
asked this question in
General
Replies: 1 comment 6 replies
-
Aren't gates the tool for permissions? https://laravel.com/docs/12.x/authorization#gates Or policies https://laravel.com/docs/12.x/authorization#creating-policies |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I got to play around with Sanctum on a new project, and I love it. But I have run into the following issue.
First, the idea was to use Sanctum for a mobile app. I was generating the tokens on the user model, without any special abilities, because in our project the mobile user can access all of their apis:
$token = $request->user()->createToken($request->token_name);
Then we run into the situation that other apis from our app can be consumed by other programs. Our thoughts where to use Sanctum again. But this time it wouldn't be based on the user model. And we wanted to use the abilities to define what exactly they can do.
First issue is, if you don't define the abilities, they get the ['*'] ability, that means the mobile tokens can now also do everything on the other apis. So we ended up to create mobile ability and add them to all the old tokens.
I know those are all my errors and I'm sure it won't happen to me again, but isn't it a bit risky that if you don't define the abilities that they get all the abilities? I wonder if the default shouldn't be the other way around.
What are your thoughts?
Beta Was this translation helpful? Give feedback.
All reactions