JEESITE登入流程簡單梳理
阿新 • • 發佈:2019-01-07
sysLogin.jsp登入:
使用者登入提交後,先指定了formAuthenticationFilter進行過濾,如果過濾認證成功,則訪問/a/login。
<form id="loginForm" class="form-signin" action="${ctx}/login" method="post">
spring-context-shiro.xml中shiro安全認證過濾器:
<!-- 安全認證過濾器 --> <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"> <property name="securityManager" ref="securityManager" /><!-- <property name="loginUrl" value="${cas.server.url}?service=${cas.project.url}${adminPath}/cas" /> --> <property name="loginUrl" value="${adminPath}/login" /> <property name="successUrl" value="${adminPath}?login" /> <property name="filters"> <map> <entry key="cas" value-ref="casFilter"/> <entry key="authc" value-ref="formAuthenticationFilter"/> </map> </property> <property name="filterChainDefinitions"> <ref bean="shiroFilterChainDefinitions"/> </property> </bean>
使用者登入提交後,先指定了formAuthenticationFilter進行過濾,如果過濾認證成功,則訪問/a/login。
FormAuthenticationFilter根據使用者登入表單提交的資訊生成一個token,然後交給SystemAuthorizingRealm進行認證。先是呼叫doGetAuthenticationInfo進行身份驗證,然後再呼叫doGetAuthorizationInfo進行授權驗證。最後返回LoginController的login進行跳轉。 更多詳情參考下面兩篇博文:protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) { String username = getUsername(request); String password = getPassword(request); if (password==null){ password = ""; } boolean rememberMe = isRememberMe(request); String host = StringUtils.getRemoteAddr((HttpServletRequest)request); String captcha = getCaptcha(request); boolean mobile = isMobileLogin(request); return new UsernamePasswordToken(username, password.toCharArray(), rememberMe, host, captcha, mobile); }