r/javahelp • u/markColibri • Jul 22 '19
Which way of authentication is better and safer for Angular 8 with Spring Boot backend?
So, I searched the web and I found two popular ways to do it.
The first one is in the official Spring documentation: https://spring.io/guides/tutorials/spring-security-and-angular-js/
Second one is an Auth0 blog post: https://auth0.com/blog/implementing-jwt-authentication-on-spring-boot/
Both are outdated a little. The first maybe safer, because it is official, but seems a little complicated. The second one is using JWT, which is so popular.
What do you think, which way would you do and why?
5
2
u/ndm250 Jul 22 '19
I've done JWT with a simple web filter. If you need complicated permissions, spring security may work well. Hard to recommend something without knowing your requirements.
1
u/BryanBugfrog Jul 23 '19
Not sure if this post will help, but it's about integrating Spring and a platform called FusionAuth. https://fusionauth.io/blog/2018/10/24/easy-integration-of-fusionauth-and-spring It might give you some additional info to work with. There's also a Angular 7 example here: https://github.com/FusionAuth/fusionauth-angular-example that might be useful.
2
u/nutrecht Lead Software Engineer / EU / 20+ YXP Jul 22 '19
You should not use JWT unless you specifically need it. If it's a single monolithic back-end there's no use at all for JWTs. You're better off just using token authentication.
Also don't make the mistake of using OAuth2 for just user logins; that's not what it's for and it's also overkill.