PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, February 26, 2022

[FIXED] Laravel Sanctum SPA - how to make sure user is only logged in on one device?

 February 26, 2022     laravel, laravel-sanctum, single-page-application     No comments   

Issue

I'm currently using Santum SPA autentication and noticed that I can login from mozilla and chrome at the same time. This means that users can login from different devices. How do I prevent this with Sanctum SPA Authencation?

The thing is I think I should be able to do this if I use Sanctum Tokens since I can easily check if the user has an existing token.

$tokens = $user->tokens;

However, the documentation says:

You should not use API tokens to authenticate your own first-party SPA. Instead, use Sanctum's built-in SPA authentication features.

The things I'll lose if I use sanctum tokens for SPA:

This approach to authentication provides the benefits of CSRF protection, session authentication, as well as protects against leakage of the authentication credentials via XSS.

or is this outside the scope of Laravel Sanctum?


Solution

After googling I'm convinced that this functionality is not included in Laravel SPA Sanctum out-of-the-box.

But I found this youtube video that made this possile.



Answered By - jove0610
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing