문제가 있어요
기억 이를 이해하고 로그인 패널을 채 웁니다. 어떻게 해결할 수 있습니까?
감사합니다.
문제가 있어요
기억 이를 이해하고 로그인 패널을 채 웁니다. 어떻게 해결할 수 있습니까?
감사합니다.
꽤 오래된 질문이지만, 나는 똑같은 문제를 연구하는 동안 그것을 우연히 발견했습니다. 그래서 다른 사람이이 문제를 우연히 만난다면 여기에 내 해결책이 있습니다.
AuthenticatedWebSession # isSignedIn()은 SecurityContext를 무시하고 대신 자신의 부울 플래그를 확인합니다. #isSignedIn()의 마지막 메서드를 재정의 할 수 없으므로 해결 방법이 필요합니다.
// MyApplication.java
public MyApplication extends AuthenticatedWebApplication {
// SNIP
@Override
public RequestCycle newRequestCycle(final Request request, final Response response) {
return new WebRequestCycle(this, (WebRequest) request, (WebResponse) response) {
@Override
protected void onBeginRequest() {
MySession.get().updateSignIn();
}
};
}
}
// MySession.java
public class MySession extends AuthenticatedWebSession {
// SNIP
void updateSignIn() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
signIn(auth != null && auth.isAuthenticated());
}
}
또는 AuthenticatedWebSession 및 AuthenticatedWebApplication은 개찰구 - 인증 - 역할의 나머지로 alltogether 포기 될 수있다 : 나는 개찰구가 현재 요청을 처리하기 시작 직전에 상태를 동기화 #onBeginRequest()를 오버라이드 (override) 사용자 정의 WebRequestCycle에 대한 갔어요 그들을 필요로하지 않습니다. AuthenticatedWebApplication의 일부 코드 복제만으로 모든 것이 유사하게 작동합니다.