package com.example.mina.config; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; /** * @author dy * @date 2021/2/25 */ @Configuration public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { // 首页所有人都可以访问,功能也只有对应有权限的人才能访问到 // 请求授权的规则 // http.authorizeRequests() // .antMatchers("/").permitAll() // .antMatchers("/level1/**").hasRole("vip1") // .antMatchers("/level2/**").hasRole("vip2") // .antMatchers("/level3/**").hasRole("vip3"); // 开启自动配置的登录功能 http.formLogin(); } }