Tian Shuai's Spring Security Tutorial Chapter 2: Custom Login Authentication Process

Customize the authentication process

1. Customize the login page

1.1 Modify the security configuration file

security has a form login page by default. If we do not specify it will jump to the default. Since the page does not meet the needs of our development, we need to customize a page.

When we define what authentication method to use when intercepting http requests, we can specify a login page.

1.2 Create an html page under the resource resource package

1.3 Access your browser.

When we visit the browser task page, it will report an error. The error is too many jumps.
Reason for the error: When we enter a page arbitrarily in the browser, security will intercept it. and jump to the login page specified above. But security will also intercept this login page and jump to this login page again. So it will cause an infinite loop.

Solution: You need to modify the content of security next time and

set a matcher to match the login page. And set his permissions to everyone can access. This will solve the problem.

1.4 Modify the content of the login page

Add a form to the login page and set the access path.

2. Custom login success handling

3. Customize login failure handling





Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326055855&siteId=291194637