Should I Use Spring Security with Sessions or JWT for My Angular and Spring Boot Project?

0
0
Asked By CuriousCoder42 On

Hey everyone! I'm currently working on a project where I'm using Angular for the frontend and Spring Boot for the backend. I've come across several tutorials that demonstrate how to utilize JWT stored in cookies with Spring Boot. However, I'm curious if it might be better to enable Spring Security and let it manage sessions with cookies instead. What's the best practice here? Should I stick with JWT in cookies, or is session management via Spring Security a more reliable approach?

5 Answers

Answered By DevNinja89 On

Honestly, if you're only using JWT just to avoid managing sessions, it might not be worth the hassle. Regular session cookies are totally fine for a single application server scenario. JWT shines when you need single sign-on across multiple applications, but if that’s not your case, stick with Spring Security and session management.

Answered By DevDude123 On

It really depends on how you plan to set up authentication. If you're using form login with user credentials, JWT can work. For session-based authentication, stick with Spring Security, especially for local deployments. Keep it simple if you're not sure why you need JWT.

Answered By CodeGuru77 On

Remember, JWT is just a format to store data, not a complete authentication scheme by itself. If you're managing user credentials in your database, using traditional session management is simpler and gives you control. If you're aiming for OAuth or dealing with external logins, that's when you might want to consider using JWT.

Answered By SimpleSolutions On

In my experience, if you're unsure about the need for JWT, you might be better off with plain session management through Spring Security. It's often one of the safest and easiest methods to secure your app. Remember, simplicity is key!

Answered By TechSavvyGator On

You should go with Spring Security regardless. It offers both session-based authentication and stateless options like JWT tokens. The difference mainly lies in how they manage session data: session information with traditional cookies is stored on the server, while JWT includes user info in the token itself and is validated with each request.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.