首页>代码>基于Spring Boot+Spring Data Jpa+apache shiro+easyui+bootstrap开发的电影推酷网站源码>/src/main/java/com/java1234/config/WebSecurityConfig.java
package com.java1234.config; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; /** * spring security配置 * @author user * */ @Configuration @EnableGlobalMethodSecurity(prePostEnabled = true)//开启security注解 public class WebSecurityConfig extends WebSecurityConfigurerAdapter{ /** * 请求授权 */ @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable().cors().disable().headers().disable() .authorizeRequests() .antMatchers("/","/film/**","/webSite/**","/webSiteInfo/**","/aboutMe","/static/**").permitAll() //其他地址的访问均需验证权限 .anyRequest().authenticated() .and() .formLogin() //指定登录页是"/login" .loginPage("/login") .defaultSuccessUrl("/admin")//登录成功后默认跳转到"/hello" .permitAll() .and() .logout() .logoutSuccessUrl("/login")//退出登录后的默认url是"/home" .permitAll(); } /** * 用户认证 */ @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth .inMemoryAuthentication() .withUser("java1234") .password("123456") .roles("ADMIN"); } }
最近下载更多
admin_z LV22
2023年12月26日
huyuxin LV3
2023年12月10日
chj173 LV1
2023年5月30日
qiangmin1223 LV11
2023年4月22日
计算机暴龙战士 LV16
2023年4月2日
admin115 LV6
2022年11月19日
1025490081 LV2
2022年11月7日
testuser1234567 LV24
2022年6月30日
877549024 LV8
2022年4月21日
AlanLi LV18
2022年4月8日
最近浏览更多
Denck1111
昨天
暂无贡献等级
zolscy LV11
3月24日
ming_123_9715 LV23
3月8日
微信网友_6872834902118400
2月19日
暂无贡献等级
fzlzxc LV10
1月23日
小草12345
2023年12月26日
暂无贡献等级
pangzhihui LV11
2023年12月24日
admin_z LV22
2023年12月22日
huyuxin LV3
2023年12月10日
fff2003 LV6
2023年11月17日