Spring Security的HTTP基本验证示例

[导读]当配置了http的基本验证时,浏览器访问时就会显示一个登录框,本人就是展现怎么用Spring Security配置http的最基本的验证。<http> <intercept-url pattern="/welcome*" access="ROLE_USER" /> <http-basic /> </http>最新的Spring Security 实现的一个Hello World例子将会被再次使用... java

当配置了http的基本验证时,浏览器访问时就会显示一个登录框,本人就是展现怎么用Spring Security配置http的最基本的验证。 web

1
2
3
4
<http>
    <intercept-url pattern="/welcome*" access="ROLE_USER" />
    <http-basic />
  </http>

最新的Spring Security 实现的一个Hello World例子将会被再次使用,只不过此次验证的是http. spring

1.Spring Secutiry 浏览器

为了验证基本的http,只须要将“form-login”改为“http-basic”标签便可.
ide

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
    xsi:schemaLocation=" http://www.springframework.org/schema/beans
  
    <!-- HTTP basic authentication in Spring Security -->
    <http>
        <intercept-url pattern="/welcome*" access="ROLE_USER" />
        <http-basic />
    </http>
  
    <authentication-manager>
       <authentication-provider>
           <user-service>
           <user name="mkyong" password="123456" authorities="ROLE_USER" />
           </user-service>
       </authentication-provider>
    </authentication-manager>
  
</beans:beans>

好了,就上面那些。 加密

2.示例 url

当访问加密的连接时,浏览器将会自动跳出登录验证框。
spa

http://localhost:8080/SpringMVC/welcome orm

原创文章,转载请注明出处:http://www.it161.com/article/javaDetail?articleid=140109230722
xml

更多原创内容,请访问:http://www.it161.com/

相关文章
相关标签/搜索