Spring security 5 Authorize Configuration
2024-09-30 21:01:04
1. Spring Security 核心请求,认证配置类 WebSecurityConfigurerAdapter
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().authenticated()
.and()
.formLogin()
.and()
.httpBasic();
}
- Ensures that any request to our application requires the user to be authenticated
- Allows users to authenticate with form based login
- Allows users to authenticate with HTTP Basic authentication
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/resources/**", "/signup", "/about").permitAll()
.antMatchers("/admin/**").hasRole("ADMIN")
.antMatchers("/db/**").access("hasRole('ADMIN') and hasRole('DBA')")
.anyRequest().authenticated()
.and()
// ...
.formLogin();
}
protected void configure(HttpSecurity http) throws Exception {
http
.logout()
.logoutUrl("/my/logout")
.logoutSuccessUrl("/my/index")
.logoutSuccessHandler(logoutSuccessHandler)
.invalidateHttpSession(true)
.addLogoutHandler(logoutHandler)
.deleteCookies(cookieNamesToClear)
.and()
...
}
最新文章
- web页面的加载顺序
- python-->;基础-->;002-->;input &; raw_input
- 数据结构(树链剖分,线段树):SDOI 2016 游戏
- MySQL数据库如何解决大数据量存储问题
- linuxsocket通信recv研究缓存机制
- MongoDB基本shell操作
- KVM(二):KVM应用
- mysql命令行大全
- AXI-Lite总线及其自定义IP核使用分析总结
- (PMP)第5章-----项目范围管理
- node-sass:npm install node-sass --save
- jQuery自己定义绑定的魔法升级版
- PHPWord 打印 快递单/合同
- Java-JUC(七):同步锁的几种方式
- InstallShield卸载不彻底,残留大量dll文件
- Golang实现一个密码生成器
- MySQL不能启动 Can't start server : Bind on unix socke
- 关于window.onload和body onload冲突的解决办法
- jq的图片放大镜效果
- 〖Linux〗Bash快捷键使用
热门文章
- JS动态加载JS
- node.js开发错误——DeprecationWarning: Mongoose: mpromise
- bzoj 1999: [Noip2007]Core树网的核【树的直径+单调队列】
- 一些常见的iOS面试问题,一眼就能看出 初级和高级工程师的区别
- 微信小程序获取自定义属性值
- 使用nginx加zuul配置
- JavaScript--编程练习2
- 仓鼠找sugar II
- DFS BestCoder Round #49 ($) 1001 Untitled
- C# 文件压缩方法