2013-06-17 2 views
0

내 grails 2.2 앱에는 외부 시스템에 대해 사용자를 인증하고 부울 응답을 반환하는 간단한 사용자 정의 양식 기반 로그인 컨트롤러가 있습니다. 성공적인 응답 인 경우 reauthenticate 메소드를 호출하고 세션을 갱신하고 재 지정합니다.사용자 정의 로그인 컨트롤러 동작 인증 후 grails no 렌더링

springSecurityService.reauthenticate(thisuser.username) 
session['SPRING_SECURITY_CONTEXT'] = SecurityContextHolder.context 
if (springSecurityService.isLoggedIn()) { 
println "Redirecting to postauth" 
redirect(action: 'postauth') 
} 

문제는 이후에 새 페이지가 렌더링하지 않습니다 리디렉션됩니다. 사용자가 기록한 로그에서 인증과의 활성 세션이 있어도 사용자의 관점에서 로그인 페이지를 클릭 한 후에도 로그인 페이지가 변경되지 않습니다. 버튼을 클릭하여 홈페이지로 이동하면 사용자가 인증 된 것으로 표시되고 모두 정상이지만이 조치 또는 다른 조치가 취해질 때까지는 아닙니다. 설명서 및 유사한 stackoverflow 질문에서 찾을 수있는 모든 것을 읽지 만 여기에 붙어 있습니다.

로그 단지 주요 통과지고 있었다 보장하기 위해 몇 가지 추가 불필요한 리디렉션을 추가하려고

pid.authenticateads: [juser:testuser, action:authenticateads, controller:pid] 
ADS Validation:true 
testuser is logged in 
Authentication org.springframew[email protected]1927f6c4: Principal: org.[email protected]2: Username: testuser; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMIN; Credentials: [PROTECTED]; Authenticated: true; Details: null; Granted Authorities: ROLE_ADMIN 
Session Content: 
    SPRING_SECURITY_CONTEXT = [email protected]27f6c4: Authentication: org.springframew[email protected]1927f6c4: Principal: [email protected]ee5b2: Username: testuser; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMIN; Credentials: [PROTECTED]; Authenticated: true; Details: null; Granted Authorities: ROLE_ADMIN 
Redirecting to postauth 
pid.postauth: [action:postauth, controller:pid] 
In postauth action, redirecting to Cluster controller, action search 
cluster.search: [action:search, controller:cluster] 

하지만, 문제는 렌더링에 있습니다. 검색 gsp는 기본적으로 비어있어 테스트를위한 리소스 플러그인 레이아웃 문제를 제거합니다. 디버깅이 켜져 있고 렌더링 오류 또는 리소스 오류가 없습니다. 그것은 페이지를 표시하기위한 호출을하지만 실제로 업데이트하는 것은 없습니다. 다시 브라우저로 가서 로그인 후 수동으로 URL을 변경하면 로그인 한 사용자가 표시됩니다. 또한 cachedRequestMaps 및 모든 sessionfixationprevention 옵션을 지우는 것이 좋습니다.

class ClusterController { 

    def springSecurityService 

    def search() { 
     def user = User.get(springSecurityService.principal.id) 
     println "In Cluster controller, action: search, user: "+user.username 
    } 
+0

메소드 실행 검색 후 clusterController에서 search.gsp를 찾고, 발견되지 않으면 공백으로 표시합니다. 그러나 리디렉션을 원한다면 리디렉션 문을 검색 방법으로 작성해야합니다. – sanghavi7

+0

여러 가지 다른 리디렉션을 시도했습니다. 문제는 아니지만 문제는 페이지를 렌더링하지 않습니다. 이 모든 것은 정상적인 j_spring_security_check를 사용할 때 잘 작동하므로 워크 플로에서 일어나는 일이 없지만 정확히 무엇을 결정할 수는 없습니다. 아마도 일부 필터. –

+0

인증을 위해 search()에 주석을 넣으려고 했습니까? – sanghavi7

답변

관련 문제