2013-10-10 3 views
1

Shiro를 내 dropwizard webapp에 통합하고 있습니다. 나는Shiro in Dropwizard가 계속 로그인 페이지로 리디렉션합니다

  • 시로 인증이 필요한 자원을 인식하고 (때문에 잘못된 암호로 로그인 페이지 (/ 인증/로그인)
  • 시로 경고 나 로그인이 실패 할 경우에 저를 전송하는 시점에 들어 왔/인증/로그인? loginFailed = true)를 내가 그러나 성공

에 (같은/관리/**)

  • 시로 정의 된 페이지로 리디렉션 보호 된 리소스에 액세스하려고하면
  • 시로 만 리디렉션 시로가 항상 나를 보내고있어. 로그인했는지 여부에 관계없이 보호 된 리소스에 액세스하려고하면 ogin 페이지가 표시됩니다. 나는 로그인이 작동하고 있다고 믿는다; 나는 또한 시로가 내가 로그인했는지 여부를 존중하지 않는다고 믿는다.

    내 shiro.ini : 또한 노트의

    [main] 
    # some other stuff 
    authc = org.apache.shiro.web.filter.authc.PassThruAuthenticationFilter 
    authc.loginUrl = /auth/login 
    
    # NOTE: URLs are evaluated in order, and the first matching pattern is accepted. 
    [urls] 
    /static/** = noSessionCreation, anon 
    /auth/** = authc 
    /admin/** = authc 
    /** = anon 
    

    : 나는 오류 내가 돈 302

    0:0:0:0:0:0:0:1%0 - - [10/Oct/2013:18:23:54 +0000] "GET /auth/login;JSESSIONID=65e06b39-30e5-45dd-85f9-b2a1c29fc3af HTTP/1.1" 200 739 4 4 
    WARN [2013-10-10 18:24:08,485] com.sun.jersey.spi.container.servlet.WebComponent: 
    A servlet request, to the URI http://blah:8080/auth/login, contains form 
    parameters in the request body but the request body has been consumed by the servlet 
    or a servlet filter accessing the request parameters. Only resource methods using 
    @FormParam will work as expected. Resource methods consuming the request body by other 
    means will not work as expected. 
    

    을 말한다 오류 및 각 방문/관리 결과를 얻고있다 ' 이 문제에 대한 답을 얻기 위해 무엇이 더 적절한 지 알 수 있습니다. 나는 다른 몇몇 "Shiro가 나를 로그인으로 리디렉션하고있다"문제를 탐구했지만 대부분은 Dropwizard가 사용하지 않는 web.xml로 Jetty를 직접 참조하거나 어떤 필터가 적용되는지를 알지 못합니다. 내 동료는 shiro가 그의 dropwizard 프로젝트로 작업하는 데 동일한 방법을 사용했습니다.

    shiro는 사용자를 로그인 페이지로 보낼지 여부를 결정하기 전에 사용자를 어떻게 인증합니까?

  • 답변

    1

    문제점을 발견했습니다. (. 그리고 한 순간에 제거됩니다) : 여기, 특히 세션 관리 부분 shiro.ini의 더 나는 sessionIdCookie.secure 댓글을 달았습니다

    sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager 
    # NOTE: The session ID cookie seems to be required in order for authentication to work as intended. 
    # If the presence of cookies is a deal-breaker, further investigation will be required. 
    # Here we enable the Secure attribute (serve over SSL only) for this cookie; 
    # the HttpOnly attribute (not accessible by JavaScript) is enabled by default. 
    #sessionManager.sessionIdCookie.secure = true 
    # enabled Ehcache following advice from Shiro docs 
    sessionDAO = org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO 
    sessionManager.sessionDAO = $sessionDAO 
    # can optionally add session listeners here if actions need to be performed on session start/stop/expiration 
    # sessionManager.sessionListeners = $listener_1, $listener_2, ... 
    securityManager.sessionManager = $sessionManager 
    

    없이 SSL을 사용할 것을 밝혀 쿠키는 아니다 변수가 true로 설정된 경우에 저장됩니다. 이것은 url 바에있는 JSESSIONID 쿼리 param을 설명하지만, 왜 인증을 한 후에 즉시 나에 대해 잊어 버렸고 다시 로그인해야한다고 결정한 이유는 무엇입니까?

    관련 문제