Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB query at each request? #47

Open
tugrulkarakaya opened this issue Aug 25, 2023 · 3 comments
Open

DB query at each request? #47

tugrulkarakaya opened this issue Aug 25, 2023 · 3 comments

Comments

@tugrulkarakaya
Copy link

https://github.com/ali-bouali/spring-boot-3-jwt-security/blame/b0a9c0fba5b7d275e90166bec7695ab785626b04/src/main/java/com/alibou/security/config/JwtAuthenticationFilter.java#L54

querying DB for each request even if token is verified? this should not be there as token signature is verified.
for refreshtoken regenerating this is udnerstanble but keeping tokens in db ad queriyng every and each time looks strange. I would keep refreshtokens in db (not tokens) and during refreshtone regeneration I woudl check if still valid)

@j3rryl
Copy link

j3rryl commented Sep 10, 2023

It is strange indeed, adds a lot of unnecessary overhead, I think.

@EduardoMtzSTI
Copy link

EduardoMtzSTI commented Nov 21, 2023

i'm learning spring security and i notice that SecurityContextHolder isn't saving the authentication therefore each new request it is validating becouse "SecurityContextHolder.getContext().getAuthentication()" is always null, thats correct or should not be null after save it the first time?

@Trandinhdongkhanh
Copy link

i'm learning spring security and i notice that SecurityContextHolder isn't saving the authentication therefore each new request it is validating becouse "SecurityContextHolder.getContext().getAuthentication()" is always null, thats correct or should not be null after save it the first time?

Finally someone notice it. I mean what's the point of checking if SecurityContext.getContext().getAuthentication() equals to null if it always null. And as metioned in the video after a successfull authentication the context get update then why in the next request it return null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants