The SecurityContextHolder
in Spring Security has three operation modes that determine how and where the SecurityContext
is stored per thread/request:
MODE_THREADLOCAL
(Default)SecurityContext
in a ThreadLocal
variable.java
CopyEdit
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_THREADLOCAL);
MODE_INHERITABLETHREADLOCAL
SecurityContext
in an InheritableThreadLocal
.SecurityContext
.java
CopyEdit
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
MODE_GLOBAL
SecurityContext
in a static global variable (singleton).