首页 > 编程语言 > 详细

SpringSecurity配置文件

时间:2020-07-08 21:19:39      阅读:63      评论:0      收藏:0      [点我收藏+]
@EnableWebSecurity
public class seccurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        //首页所有人可以访问,功能也只有对应有权限的人才能访问
        http.authorizeRequests()
                .antMatchers("/").permitAll()
                .antMatchers("/templates下的文件夹/**表示所有文件").hasRole("")
                .antMatchers("/templates下的文件夹/**表示所有文件").hasRole("");
        //没有权限跳到登录页面,需要开启登录的页面
        http.formLogin();
    }

}

官方的

    protected void configure(HttpSecurity http) throws Exception {
     *         http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin()
     *                 .usernameParameter("username") // default is username
     *                 .passwordParameter("password") // default is password
     *                 .loginPage("/authentication/login") // default is /login with an HTTP get
     *                 .failureUrl("/authentication/login?failed") // default is /login?error
     *                 .loginProcessingUrl("/authentication/login/process"); // default is /login
     *                                                                         // with an HTTP
     *                                                                         // post
     *     }

 

SpringSecurity配置文件

原文:https://www.cnblogs.com/HezhenbinGoGo/p/13268614.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!