Question about SecurityContextHolder from Spring Boot Security
Speaking about Spring Boot RestController... - can I extract a username from SecurityContextHolder only once outside of all methods and then use that string username in any methods as a class scope variable or a constant? Or should the username acquiring be only inside any particular method that has @Secured({"..."}) and mapping annotations? Can the SecurityContextHolder be in a service?
8 Replies
Hey, @Tomasm21!
Please remember to
/close
this post once your question has been answered!as long as it runs in the same thread as the controller ig
what's ig
I guess
mk.. ok
I'll test it myself anytime.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I meant that
SecurityContextHolder
uses ThreadLocal
Post Closed
This post has been closed by <@312509109863710732> for the following reason:
Andrew and Dan answered