我试图使用Spring安全(4.2.3),以securize我的应用程序(春季4.3.10 + Hibernate的5.2.10)。Spring Security没有显示登录页面
我配置弹簧安全与摘要认证方法通过以下方式:
弹簧的security.xml:
<security:http create-session="stateless" use-expressions="true" >
<security:intercept-url pattern="/**" access="isAuthenticated()"/>
<security:intercept-url pattern="/login*" access="isAnonymous()" />
<security:http-basic/>
<security:form-login login-page="/login" authentication-failure-url="/login"/>
<security:custom-filter ref="digestFilter" after="BASIC_AUTH_FILTER"/>
</security:http>
<bean id="digestEntryPoint" class="org.springframework.security.web.authentication.www.DigestAuthenticationEntryPoint">
<property name="realmName" value="my_realm"/>
<property name="key" value="my_key"/>
</bean>
<bean id="digestFilter" class="org.springframework.security.web.authentication.www.DigestAuthenticationFilter">
<property name="userDetailsService" ref="jdbcDaoImpl"/>
<property name="authenticationEntryPoint" ref="digestEntryPoint"/>
</bean>
<bean id="jdbcDaoImpl" class="org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl">
<property name="dataSource" ref="dataSource"/>
</bean>
我添加的DelegatingFilterProxy在web.xml中:
<filter>
<filter-name>digestFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>digestFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
我创建了一个基本的控制器来显示登录PA GE(没有设法使用默认的一个):
@Controller
@RequestMapping("/login")
public class LoginController {
@GetMapping
public String login() {
return "login";
}
}
我还有的login.jsp中包含表单的WEB-INF,和MySQL默认模式为用户和当局如表在参考文档中进行描述。
我的问题是Spring Security从未显示登录页面。我把一个断点到DigestAuthentificationFilter的doFilter方法,它似乎是头“授权”为空,春季只是继续过滤器链没有做任何事情。看来,过滤器被期待摘要头部...
我的问题是那么,谁把这个Authorization头?为什么春天不要求验证是头是空的? 我觉得有些东西我不明白...
感谢您的帮助!
胡乱猜测:/登录默认情况下从春天提供的默认登录页面,你可以尝试调用它除登录 –
无法运作的别的东西: ( – user3890394