Похожие чаты

Thank you very much. Can i ask another question. Spring security uses

these for authentication:
-Authentication interface
-userDetails.UserDetails class
-userDetails.User class

But User and UserDetails only provides username and not more details about of logged in user.
I want to add some fields to logged in UserDetails such as ID and phone and etc.

I read a lot and see there is two way :
1. Create a UserBean Entity (corresponding to DB) and extends it from User or implements UserDetails.
And then create a service class that implements UserDetailsService and change loadByUsername method.

2. Create a custom Authentication class instead of security.core.Authentication
interface.

Which of these two way is better?

1 ответов

14 просмотров

I can't say for sure. Custom Authentication provider is for more advanced scenarios when you want to do something really extraordinary when checking auth requests. Personally, I would use the first option as it is more straightforward and ready-to-use, and I'm familiar with it. I don't know much of your requirements to say what's better. What I would do, if I were you, and have no clear understanding what to choose, what fits better to your system: try to implement first option, add all necessary custom fields to your user, follow online tutorials (there are plenty of them). It shouldn't take too much effort. And then based on the result (or right in the middle of the process) understand whether something more custom is needed. And very personal thing that I would do: I would read a good book dedicated to spring security first. That is exactly what is needed for me to fill that gap "understand the common way, but not sure what to do in special cases". I have that gap, so don't take most of my advices as a holy grail))

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта