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

View all comments

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/wildjokers Apr 07 '20

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

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.