r/java • • Apr 06 '20

Spring Security: Authentication and Authorization In-Depth

https://www.marcobehler.com/guides/spring-security
214 Upvotes

17 comments sorted by

16

u/aceinthedeck Apr 06 '20

I highly recommend this website for Spring developers. Marco way of explaining is pretty good.

8

u/marbehl Apr 06 '20

thank you

2

u/borgy_t Apr 06 '20

thank you, your articles on spring are very helpful.

i hope JWT would be better supported in the future, right now it is possible but a lot of boilerplate needs to be written..

2

u/marbehl Apr 06 '20

you are welcome

7

u/RockleyBob Apr 06 '20

This is fantastic. I just read your previous article What is Spring Framework? and got a lot out of it.

As soon as I read

if you started programming with Spring in the last couple of years, there is a very high chance that you went directly into Spring Boot

I was immediately interested because that’s exactly the boat I’m in. Good stuff, keep it coming.

8

u/Indie_Dev Apr 06 '20

Thanks! I always found Spring security to be a bit complex. It helps when someone writes such in depth articles like these.

4

u/wildjokers Apr 07 '20

“a bit complex” is a vast understatement.

1

u/Dantharo Apr 07 '20

I have a question, i made an simple login api with Spring Securit and jjwt, and i used spring security`s UserDetails and UserDetailsService, so i was forced to use some data that i wont need in my model, like, my entity should implement directly UserDetails? Because i dont need some fileds and methods like isEnabled or isAccountNonLocked, is there a way to avoid this?

1

u/marbehl Apr 08 '20

Not really.

You could use Spring Security's " org.springframework.security.core.userdetails.User " class and map between your class and that, but this includes some plumbing.

Or your own object/default interface, like wildjokers said.

1

u/wildjokers Apr 07 '20

Have another object that extends UserDetails then map your entity to it.

1

u/Passspy Apr 07 '20

Finally I solved my week problem with security in my app. Thanks!

1

u/marbehl Apr 07 '20

What was it?

3

u/Nishikantk Apr 06 '20

Thanks for this👍

2

u/Kresenko Apr 06 '20

Really helpful, thank you

1

u/dunamis100 Apr 06 '20

Nice article..... waiting for the oauth2 part. Integration with Spring Webflux would be nice too for projects not using Spring MVC.....thanks for such a nice write

1

u/DrunkensteinsMonster Apr 06 '20

Right in time, been working with Spring Security a lot recently. I find the API to be a bit complex

1

u/wildjokers Apr 07 '20

Just when you get security for Spring MVC figured out then you get the joy of figuring out security for a Spring Webflux app.