Hello everyone! I have very exciting question form me.
What is a right way to authenticate your SPA JavaScript application (VueJS+Router, ReactJS+Router etc.)?
I have investigated this question and found very different results for such standard feature as authentication.
In most cases developers uses laravel/passport
(Full OAuth2 server implementation) to just authenticate frontend application, which is looks strange for me.
Someone uses Personal Access Token:
Someone uses Password Grant:
Anotherone uses tymon/jwt-auth package:
Someone else uses CreateFreshApiToken
middleware to attach api token to cookie, how recommended in the documentation:
And also have found answers like:
Just use sessions!
So, the main questions:
Whats the profit to use Password Grant or Personal Access Tokens for your JavaScript app, if much simpler and recommended way it’s to use - CreateFreshApiToken
middleware?
Is this not overhead, to install Full OAuth2 Implementation, to just authenticate Frontend SPA with CreateFreshApiToken
middleware which just attach token to cookie?
Is it make sense to use laravel/passport
with CreateFreshApiToken
middleware if it’s just attach token to cookie like in case with sessions?
Is there a reason to use simple JWT with tymon/jwt-auth
, if yes, so which?
And main question, so, What is a right way to authenticate your JavaScript SPA Frontend Application?
P.S. I don’t ask about mobile applications, or 3rd parties, just your Frontend JavaScript application.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community