You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After Sanctum version 3.2.1 (PR #417) a custom bearer token always returns 404 when someone tries to reach an endpoint secured with Sanctum. Logging in and retrieving the token works OK.
My model ID is an integer, but I'm using another column in the bearer token to not expose the model ID. For example a uuid-column.
I'm well aware this PR is for good reasons, but how can I reach my endpoints now with a custom bearer token ID? I've been browsing through the source files and there does not seem to be a good method as it always looks for the model ID (which is an integer in my case). Is this something which will be supported in the near future, or is my situation an edge case which is not encouraged?
Please let me know if more information is required.
Steps To Reproduce
User-model:
public function tokens(): MorphMany
{
return $this->morphMany(Sanctum::$personalAccessTokenModel, 'tokenable')
->withTrashed();
}
public function createToken(string $name, array $abilities = ['*']): NewAccessToken
{
$token = $this->tokens()->create([
'name' => $name,
'token' => hash('sha256', $plainTextToken = Str::random(40)),
'abilities' => $abilities,
]);
return new NewAccessToken($token, $token->uuid.'|'.$plainTextToken);
}
Thanks for reporting the problem you are encountering, but it looks like this is a question which may be better suited for a support channel. We only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repository you can try one of the following channels:
Sanctum Version
3.2.5
Laravel Version
10.16.1
PHP Version
8.1.4
Database Driver & Version
No response
Description
After Sanctum version 3.2.1 (PR #417) a custom bearer token always returns 404 when someone tries to reach an endpoint secured with Sanctum. Logging in and retrieving the token works OK.
My model ID is an integer, but I'm using another column in the bearer token to not expose the model ID. For example a uuid-column.
I'm well aware this PR is for good reasons, but how can I reach my endpoints now with a custom bearer token ID? I've been browsing through the source files and there does not seem to be a good method as it always looks for the model ID (which is an integer in my case). Is this something which will be supported in the near future, or is my situation an edge case which is not encouraged?
Please let me know if more information is required.
Steps To Reproduce
User-model:
PersonalAccessToken-model
Login-controller
The text was updated successfully, but these errors were encountered: