Questions tagged [sanctum]
65 questions
0
votes
0 answers
Why my tokensMatch() method is not working on Laravel?
Inside VerifyCsrfToken.php in tokenMatch() method the hash_equals($request->session()->token(), $token); method is having some error 419. I am building a SPA with React and a Laravel API Sanctum, making a manual request with fetch get request…

Nicolas Tabia
- 1
- 2
0
votes
0 answers
Laravel Sanctum - user two laravel for microservice (401 "Unauthenticated.")(Solved)
I Have two project of laravel and one of them have sanctum.and I wrote a middleware for another laravel project.
My middlware:
$url = 'http://localhost/v1/management/auth/me';
$suepackAuth = Http::withToken(
…

milad modaresi
- 11
- 4
0
votes
1 answer
Vue - Larave SPA Frontend api security & Restriction
I'm facing an issue where a former frontend developer who worked on my project has access to my frontend APIs even after quitting. I've implemented Laravel Sanctum for authentication and authorization, along with a username and password system and…

Burak Celen
- 9
- 1
0
votes
2 answers
Laravel Authentication API Sanctum – With Custom Database
First important information: I’m new to Laravel, so your patience is appreciated.
I’m currently migrating a framework of mine to Laravel and still in the early stages. I know that Laravel has it’s own database construction mechanism that is…

Jorge Mauricio
- 411
- 6
- 18
0
votes
1 answer
How to create a guard for guest users in Angular to authenticate with sanctum only
I have a forum like application that uses Laravel for the back-end, sanctum for authentication and Angular for the front-end
I need guest users to access the home page and request the list of questions to show from the Laravel api but I need to…

Armando_pagano
- 150
- 9
0
votes
0 answers
"Nuxt" receives data about the user, but does not pass through "auth" middleware
Nuxt Auth, Laravel Sanctum.
When the login button is pressed, all requests receive user data.
Locally it works fine. But when working on the server, it is not
possible to log in. As if stuck between two middleware)
Result of page refresh

Иван Апевалов
- 33
- 3
0
votes
0 answers
Laravel : How can I modify auth:sanctum middleware to return a 401 instead of redirect to login route?
Good evening,
I encounter a problem using Laravel and Sanctum to build an Api for a Mobile application.
I followed the documentation and define a route to get a token :
use App\Models\User;
use Illuminate\Http\Request;
use…

Ulrick Evrard
- 7
- 4
0
votes
1 answer
Laravel sanctum and vue: user is logged in frontend but backend returns unauthorized
i have a log in form in my front end (vue) when users log in, in vue i can get back data of logged in user perfectly fine through
axios.get('http://127.0.0.1:8000/api/user').then((response)=>{
this.userData = response.data;
However in my…

aliana
- 47
- 5
0
votes
0 answers
laravel auth sanctum and spatie error in group routes
routes code :
Route 1 :
Route::middleware('auth:sanctum')->get('/test_solo', function (Request $request) {
if ($request->user()->getpermissionnames()[0]===UserPermission::CUSTOMER) {
return "auth by solo";
}
});
response :
(http…

Arian Atri
- 9
- 7
0
votes
0 answers
Add expiry date for token with laravel sanctum (expiration - expires_at ) (solved)
use Illuminate\Support\Facades\Date;
$expiresAt = Date::now()->addMinutes(5);
$token = $user->createToken('token name', ['server:update'], $expiresAt)->plainTextToken;
if you want to add expiry time for a token you can do it like this
0
votes
1 answer
laravel sanctum guard trow Segmentation violation error
I would like to use sanctum as a guard, I switch the driver from session to sanctum and then this gives the error message. I don't know where to look for the error or which way to start.
'guards' => [
'web' => [
'driver' =>…

Bálint Bakos
- 474
- 2
- 5
- 21
0
votes
0 answers
Laravel auth sanctum causes socket to hang up
I am trying to use Laravel auth sanctum middelware. Logging in and registering works fine, but when I try to make an authenticated request the socket hangs up, and all requests after that get refused.
Error: connect ECONNREFUSED…

sempakonka
- 35
- 8
0
votes
1 answer
Best practice to place sanctum $user->tokenCan() check
I am following a tutorial on building an API in Laravel. I have reached the stage of Authentication/Authorisation and have a question about best practices.
The tutorial uses "Requests" for validation on the controller's 'store' method and in the…

Typhoon101
- 2,063
- 8
- 32
- 49
0
votes
0 answers
How to Logout All Devices Without Password in Laravel Sanctum?
I am using Laravel Sanctum for both API and SPA authentication.
When an SPA user logs out, I need to logout him from all other devices too without asking for password. This is a requirement (and hence I cannot go other-way).
I am deleting all tokens…

Chitholian
- 432
- 1
- 10
- 19
0
votes
0 answers
laravel sanctum login with token to WebView android , nuxt web application
I have a laravel for back end and nuxt js for front end and implement auth with cookie based session authentication services
it work good
but i have a android application built with java and i have to open a WebView to specific page in nuxt with…