Announcement Announcement Module
Collapse
No announcement yet.
An Authentication object was not found in the SecurityContext Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • An Authentication object was not found in the SecurityContext

    Good afternoon gentlemen,
    1. I have an application exporting web services, with a configured spring security SecurityFilterChain (with SecurityContextPersistenceFilter among others, which is required for the rest).
    2. My application also uses spring security to secure method invocations.

    I have following error when method security is triggered:
    Code:
    org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext
    The 2nd part requires an Authentication in SecurityContextHolder as showed in org.springframework.security.access.intercept.Abst ractSecurityInterceptor (line 195):
    Code:
    SecurityContextHolder.getContext().getAuthentication()
    But, SecurityContextPersistenceFilter removes it before method invocation is triggered, as shown in
    org.springframework.security.web.context.SecurityC ontextPersistenceFilter (line 84)
    Code:
    SecurityContextHolder.clearContext();
    What can I do to have this object in SecurityContextHolder when method invocation is triggered?

    Thank you in advance,
    Isart

    P.S: I'm using spring-security 3.0.8-RELEASE
    Last edited by isartc; May 14th, 2013, 10:03 AM.

  • #2
    My service method invocation turns to happen after the whole securityFilterChain has finished. I mean, all filters have complete the execution of their doFilter() method.

    Is that the expected behaviour? Or service invocation should happen as part of the filter chain?

    Comment

    Working...
    X