advancedSpring Security

What is SecurityContext and SecurityContextHolder? What are the storage strategies?

SecurityContext holds the current Authentication object. SecurityContextHolder stores it via a pluggable strategy: ThreadLocal (default, per-thread), InheritableThreadLocal (shared with child threads), or Global (one shared context, for desktop apps). With virtual threads, ThreadLocal still works correctly since each virtual thread gets its own.

This is a Pro question

Sign in, then upgrade to Pro or Power to unlock this question and the full Interview Prep bank.

What is SecurityContext and SecurityContextHolder? What are the storage strategies?

Next Step

Continue to What is UserDetailsService? How does Spring Security authenticate a user?← Back to all Spring Boot & Microservices questions