Spring基本身份验证不起作用

尝试使用spring在网络应用中设置基本身份验证。我正在仿照此示例所做的工作:http : //howtodoinjava.com/2013/04/16/custom-userdetailsservice-example-for-spring-3-security/我正在使用Spring 4。

行为是我的HttpRequestHandler运行,从不要求输入密码。LoginDao永远不会运行。

弹簧配置:

<security:http auto-config="true"  use-expressions="true">
    <security:intercept-url pattern="/*" access="hasRole('ROLE_USER')" />
    <security:http-basic />
</security:http>

<security:authentication-manager>
    <security:authentication-provider user-service-ref="loginDao" />
</security:authentication-manager>

<bean id="loginDao" class="weight.dao.LoginDao" />

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="/WEB-INF/wt.properties" />
</bean>
斯特凡

本教程中缺少的是必须添加到web.xml中的条目。这些将加载您的安全上下文,并将安全过滤器链添加到整个应用程序(这是Spring Security的主要支柱):

 <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        classpath:/your-security-context-file.xml
        classpath:/your-other-context-files.xml
        ...
    </param-value>
</context-param>

<filter>
    <display-name>Spring Security Filter</display-name>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用RestTemplate的Spring 4.0.0基本身份验证

使用spring restTemplate的REST API的基本身份验证

HTTP基本身份验证在Spring Security中不起作用

使用Spring Sleuth Zipkin配置基本身份验证

基本的jdbc身份验证,授权不起作用

Spring Security在基本身份验证后抛出403

iOS-Alamofire v2基本身份验证不起作用

超薄基本身份验证

用于HTTP基本身份验证的UnityWebRequest嵌入用户+密码数据在Android上不起作用

Spring Security自动身份验证不起作用

Laravel +基本身份验证,除了一个文件夹不起作用

更改rest_url_prefix使基本身份验证不起作用

Android Spring 1.0.1使用基本身份验证删除

具有基本身份验证的Angular 5 http似乎不起作用

如果从脚本运行tracd,则基本身份验证不起作用

Yowsup身份验证不起作用

基本身份验证在WebSphere 7上不起作用

jQuery基本身份验证失败

Apache 2.4基本身份验证不起作用

HttpWebRequest身份验证不起作用

在Spring Security中接收令牌的基本身份验证

用户名和密码中的基本身份验证标头在AFNetworking 2.0中不起作用

身份验证不起作用

Spring Security 条件基本身份验证

基本身份验证在 node-rest-client 节点中不起作用

招摇:基本身份验证不起作用

PHP 基本身份验证不起作用

traefik v2 仪表板基本身份验证在 AWS elb 后面不起作用

当基本身份验证和 cookie-jar 不起作用时访问身份验证后面的 URL