spring - An Authentication object was not found in the SecurityContext -
- i have application exporting web services, configured spring security
securityfilterchain
(withsecuritycontextpersistencefilter
among others, required rest). - my application uses spring security secure method invocations.
i have following error when method security triggered:
org.springframework.security.authentication.authenticationcredentialsnotfoundexception: authentication object not found in securitycontext
the 2nd part requires authentication
in securitycontextholder
showed in org.springframework.security.access.intercept.abstractsecurityinterceptor
(line 195):
securitycontextholder.getcontext().getauthentication();
but, securitycontextpersistencefilter
removes before method invocation triggered, shown in org.springframework.security.web.context.securitycontextpersistencefilter
(line 84)
securitycontextholder.clearcontext();
what can have object in securitycontextholder
when method invocation triggered?
thank in advance.
i'm using spring security 3.0.8-release
securitycontextholder.clearcontext()
called after request processing completion. application logic code executed before line, , there no problem @ all. problem may present if execute new thread in code (by default security context not propogated). if case can try force context propogation child thread. if use 1 thread make sure code covered spring security filter chain (may have custom filter executed around spring security filter chain?).
Comments
Post a Comment