Похожие чаты

Thank you very much for your answer. I'm familiar with spring

security concepts.

I have used spring mvc and thymeleaf as view technology and enabled spring security by extending WebSecurityConfigurerAdapter.

I have two table in db :
User and VerificationToken.

User can login with social login or custom login.

After Successfully logged in, user will be redirect to a dashboard page.

Untill now i dont show user id in the url.
In fact i used a controller class with @ModelAttribute method that check user is logged in or not with SecurityContextHolder.getContext.getAuthentication.getName

then this method check this name exist in database and its token in database is expired or not.

Then i will use this user object in other @RequestMapping method to check if the user object is null or not.
If the user is null so redirect to 403 or login page.
And if user is not null let to continue in that method.

Is true this scenario?

3 ответов

11 просмотров

I think Spring Security managed this scenario automatically just you can add a filter chain for managing verification token you can see this mkyong.com link.x

No need to check null user, spring sec filter will handle this.

As gyus already said, spring security already does that for you. Let me explain in more detail. The backbone of all interactions with your app is Servlet. Spring uses "jsessionid" to distinguish connected clients (another word to not use "user"), to distinguish http sessions in other words. Another layer of your app is database and User, Role, UserRole entities. Spring security maps jsessionid (for the most simple case, any other thing also may be used, like token) to the actual User+Role from db, and applies access rules (expressed with spring security filters). This mechanism already performs what you are trying to achieve by storing userid in http session or in views. I see that you have a "dashboard" page and assume that you are building an spa app. Try googling "spring security spa" or "srping security rest", this is another topic.

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

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

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
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
Карта сайта