01-spring Security Framework Learning--Getting Started (ii)

Source: Internet
Author: User

I. Introductory case spring Security Custom Login interface

With the previous section 01-spring Security framework Learning-a simple demonstration of getting Started (i), Spring security uses the login interface that comes with the framework, and the following case will use the login page of your own definition.

Basic steps
    1. Add the following page:
    • Login interfacesrc/main/webapp/login.html
   <!DOCTYPE html>   
    • Login Results Pagesrc/main/webapp/login_error.html
    <!DOCTYPE html>    
    1. Modify Spring-security.xml configuration
      src/main/resources/spring/spring-security.xml
    <?xml version= "1.0" encoding= "UTF-8"?> <beans:beans xmlns= "http://www.springframework.org/schema/security "Xmlns:beans=" Http://www.springframework.org/schema/beans "xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "Xsi:schemalocation=" Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ Spring-beans.xsd http://www.springframework.org/schema/security Http://www.springframework.org/schema/securi Ty/spring-security.xsd "> <!--settings no need to login rules (Note: The path before the '/' symbol must not be omitted)--
Run effect

Operational issues
    1. The following error:HTTP Status 403 - Invalid CSRF Token ‘null‘ was found on the request parameter ‘_csrf‘ or header ‘X-CSRF-TOKEN‘.

      This is because spring security is enabled by default to prevent CSRF attacks, and the demo demo is now closed.
Ii. Summary of Spring Security
    1. Through the simple configuration on the road, Spring Security will do us a lot of things:

      • Authentication is required for each URL in your app
      • To create a landing form for you
      • Allow users to submit Username user names in the form and Password password to Password for authentication
      • Allow user to log off
      • Guard against CSRF attacks
      • Prevent session Fixation
      • Integrated Security Header
    2. Basic principles of Spring security

      Spring intercepts HTTP requests via the Servlet interceptor, which is user authentication and authorization under the action of this filter chain.

If you want to learn more about the principle process, please go.

01-spring Security Framework Learning--Getting Started (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.