Home > Back-end >  Spring security
Spring security

Time:09-22

Corresponding maven coordinates: 1.

Org. Springframework. Security
Spring ws-security - web
5.0.5. RELEASE


Org. Springframework. Security
Spring ws-security - config
5.0.5. RELEASE

2. Configuration web. XML
DelegatingFilterProxy framework for integration of third-party
Integration of the name of the filter must be springSecurityFilterChain when Spring Security,
Otherwise it will throw NoSuchBeanDefinitionException abnormal
-->
SpringSecurityFilterChain
Org. Springframework. Web. Filter. DelegatingFilterProxy


SpringSecurityFilterChain
/* & lt;/url - pattern>



Springmvc
Org. Springframework. Web. Servlet. DispatcherServlet


ContextConfigLocation
The classpath: spring ws-security. Xml


1



Springmvc
*. Do

3. Configure spring - security. XML


HTTP: used to define the relevant permissions control
Specify what resources do not need to undertake permission to check, you can use the wildcard
-->
& lt; Security: HTTP security="none" pattern="/js/* */& gt;
Intercept - url: define a blocking rule
Pattern: to control the permissions which url
Access: the corresponding URL request permissions are needed, the default configuration when it should be a comma-separated list of roles,
Requests the users only need to have one of these roles can successfully access the corresponding URL
-->

CSRF: corresponding CsrfFilter filters
Disabled: whether to enable CsrfFilter filter, if you use a custom login page need to shut down the,
Otherwise the login operation will be disabled (403)
-->
& lt; Security: CSRF disabled="true" & gt;


Password - parameter="password"
Login - processing - url="/login. Do
"Default - target - url="./pages/main HTML "
Always use - the default - target="true"
Authentication failure - url="./login HTML
"/>



Authentication - manager: authentication manager for handling the certification
-->

Authentication - provider: authentication provider, perform specific authentication logic
-->

& lt; ! -
User - service: used to get the user information, provide authentication - provider certification (data is written to death, only suitable for testing the demo)
-->

The user to define user information, you can specify a user name, password, character, later can be changed to query the user information from a database
{it} : it means the current use of password for clear
-->
Password="admin" {it}
Authorities="ROLE_ADMIN" & gt;









4. Custom interface of a class implements springsecurity framework UserDetailsService, implement the abstract methods inside loadUserByUsername

Inside the method to obtain the username password and the corresponding privilege set,
Create a collection is used to store permissions and roles
List AuthorityList=new ArrayList<> (a);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related