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/

相關文章
相關標籤/搜索