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()
...
}

最新文章

  1. web页面的加载顺序
  2. python-->基础-->002-->input & raw_input
  3. 数据结构(树链剖分,线段树):SDOI 2016 游戏
  4. MySQL数据库如何解决大数据量存储问题
  5. linuxsocket通信recv研究缓存机制
  6. MongoDB基本shell操作
  7. KVM(二):KVM应用
  8. mysql命令行大全
  9. AXI-Lite总线及其自定义IP核使用分析总结
  10. (PMP)第5章-----项目范围管理
  11. node-sass:npm install node-sass --save
  12. jQuery自己定义绑定的魔法升级版
  13. PHPWord 打印 快递单/合同
  14. Java-JUC(七):同步锁的几种方式
  15. InstallShield卸载不彻底,残留大量dll文件
  16. Golang实现一个密码生成器
  17. MySQL不能启动 Can't start server : Bind on unix socke
  18. 关于window.onload和body onload冲突的解决办法
  19. jq的图片放大镜效果
  20. 〖Linux〗Bash快捷键使用

热门文章

  1. JS动态加载JS
  2. node.js开发错误——DeprecationWarning: Mongoose: mpromise
  3. bzoj 1999: [Noip2007]Core树网的核【树的直径+单调队列】
  4. 一些常见的iOS面试问题,一眼就能看出 初级和高级工程师的区别
  5. 微信小程序获取自定义属性值
  6. 使用nginx加zuul配置
  7. JavaScript--编程练习2
  8. 仓鼠找sugar II
  9. DFS BestCoder Round #49 ($) 1001 Untitled
  10. C# 文件压缩方法