2016-09-23 3 views
0

SAML 보안을 사용하여 응용 프로그램을 서비스 공급자로 활성화했습니다. 이 위대한 작품, 사용자 지정 WickedUserDetails (GrailsUser에서 확장 된) 사용하고 모든대로 채 웁니다.SAML을 통해 Grails 응용 프로그램에 LogoutController에 UserDetailsService에 대한 액세스 권한이 없음

이제 SAML에 대한 글로벌 로그 아웃을 구현하려고하지만 "공상"을하기 전에도 정기적 인 LogoutController를 누르면 WickedUserDetails에 액세스 할 수 없습니다. 방금 익명의 grails 사용자가 있습니다.

이 동작은/logout/index 및/logout/special에 액세스하려고하면 발생합니다. 그것은 SlogoutController를 사용할 때 예상대로 작동합니다. 내 Config.groovy 파일에서

class LogoutController { 

    def springSecurityService 

    /** 
    * Index action. Redirects to the Spring security logout uri. 
    */ 
    def index = { 
     // Populates with ANONYMOUS GRAILS USER when logged in via SAML 
     // but with WickedUserDetails when logged in via the "normal" Spring Security mechanism 
     def check = springSecurityService.principal 

     redirect uri: SpringSecurityUtils.securityConfig.logout.filterProcessesUrl // '/j_spring_security_logout' 
    } 

    def special = { 
     // Populates with ANONYMOUS GRAILS USER when logged in via SAML 
     // but with WickedUserDetails when logged in via the "normal" Spring Security mechanism 
     def check = springSecurityService.principal 

     redirect uri: SpringSecurityUtils.securityConfig.logout.filterProcessesUrl // '/j_spring_security_logout' 
    } 
} 

class SlogoutController { 

    def springSecurityService 

    def special = { 
     // Populates with WickedUserDetails 
     def check = springSecurityService.principal 

     redirect uri: SpringSecurityUtils.securityConfig.logout.filterProcessesUrl // '/j_spring_security_logout' 
    } 

    // Populates with WickedUserDetails 
    def index = { 
     def check = springSecurityService.principal 

     redirect uri: SpringSecurityUtils.securityConfig.logout.filterProcessesUrl // '/j_spring_security_logout' 
    } 

} 

, 내가 설정 한 특별한 인터셉터 URL을하지 않아도, 내가 로그 아웃 URL에있는 유일한 기준은 다음과 같습니다

grails.plugin.springsecurity.secureChannel.definition = [ 
    '/login/**' :  'REQUIRES_SECURE_CHANNEL', 
    '/logout/**' :  'REQUIRES_INSECURE_CHANNEL' 
] 

이 내가 가지고있는 유일한 참조입니다 Url 매핑에 설정 :

"/logout/$action?"(controller: "logout")  

이 문제가 발생하는 이유를 설명해 줄 사람이 있습니까? 내 애플 리케이션에서 해결 방법을 생각해 낼 수는 있지만, 무슨 일이 일어나고 있는지는 궁금하다.

답변

0

좋아요, 문제는 바로 가기입니다. 인증 공급자에서 원래 주문한 토큰을 SAML 자격 증명으로 업데이트하지 않았습니다.

Authentication authenticate(Authentication authentication) { 

    if (authentication instanceof SAMLAuthenticationToken) { 

     def samlToken = super.authenticate(authentication) 
     if (samlToken) { 
      String username = samlToken.principal 
      LightweightContact contact = new LightweightContact(username: username)       

      contact = contact.findByUsername() 

      boolean isContactValid = contactValid(contact, samlToken) 

      if (isContactValid) { 
       WickedAuthenticationToken wickedToken = MyNormalSpringCustomWickedAuthenticationProvider.getWickedAuthenticationToken(contact) 
       // -------- I needed to explicitly set the credentials here ----------------------- 
       wickedToken.setCredentials(samlToken.credentials) 
       return wickedToken 
      } 
     } 
    } 

    // the authentication token was not of the correct class 
    // or no user was found for it 
    return null 
}