Authenticating users in Symfony — with Vue.js as frontend framework.

In this article I will skip the Symfony authentication process as this can be found in the official documentation (it’s more about presenting the solutions in case of using Vue.js):

  • Symfony Authentication,
  • Symfony Login Form,
  • Symfony Guard Authentication,

JWT Token-based Authentication — Does It Have to Be This Way?

Vue.js allows us to either create a SPA (Single-Page Application) or to be used in the form of hybrid where we can inject the components into already existing code or use Vue.js as an extension of current frontend code (_In which case I learned the hard way that it can become very messy — You can find more _ here) — as for both cases the authentication can be implemented/solved in different ways.

Personally, I didn’t even intend to test both solutions, as the hybrid one works very well — but — I’ve already had a chance to see some interesting/confusing authentication in Symfony by using JWT to validate user on Angular based frontend (in this case the solution/end goal was different than simple login form).

In general, the JWT solution does work, makes everything it should, there is no problem — so what’s the point? Since Vue.js is the first modern JS framework used on my own alongside with backend framework I wondered:

“Do I really need to use some tokens, as the Symfony auth no longer works the way it should? Is it always like this in modern JS?”

A long story short — it doesn’t need to be this way, there is actually no magical, special token required in the authentication process — although the full SPA does require special logic, it’s still ‘almost’ standard Symfony logic.

#javascript #php #vuejs #symfony #vue

Vue.js and Symfony — User Authentication
5.10 GEEK