一、

What if you wanted to restrict access to certain roles only on Tuesday?

Using the access() method, you can also use SpEL as a means for declaring access requirements. For example, here’s how you could use a SpEL expression to require ROLE_SPITTER access for the /spitter/me URL pattern:

.antMatchers("/spitter/me").access("hasRole('ROLE_SPITTER')")

This security constraint placed on /spitter/me is equivalent to the one we started
with, except that now it uses SpEL to express the security rules. The hasRole() expres-
sion evaluates to true if the current user has been granted the given authority.

With Spring Security’s SpEL expressions at your disposal, you can do more than just
limit access based on a user’s granted authorities. For example, if you wanted to lock
down the /spitter/me URL s to not only require ROLE_SPITTER , but to also only be
allowed from a given IP address, you might call the access() method like this:

.antMatchers("/spitter/me")
.access("hasRole('ROLE_SPITTER') and hasIpAddress('192.168.1.2')")

最新文章

  1. html(一)
  2. Table 'performance_schema.session_variables' doesn't exist
  3. c++对象成员的引用---12
  4. PHP网络操作函数汇总
  5. Objdump-查看汇编指令
  6. m3u8文件简介
  7. 【转】可执行程序包括BSS段、数据段、代码段
  8. BZOJ 3969 Low Power 解题报告
  9. Ajax核心——XMLHttpRequest基础
  10. android 使用android.support.v7 添加ActionBar
  11. 子类重载父类的方法“parent:方法名”
  12. android分享到新浪微博,认证+发送微博,
  13. vi、vim 配置上下左右方向键和删除键
  14. 前端学习笔记之HTML body内常用标签
  15. PHP基础笔记
  16. 如何简单地理解Python中的if __name__ == '__main__'
  17. 第十一节,利用yolov3训练自己的数据集
  18. 软件测试-chapter2-homework2
  19. nginx 本地映射
  20. [转] HTML5之FileReader的使用

热门文章

  1. 常用DOM笔记
  2. 打包并发布自己的Android应用(eclipse)
  3. 常用到的Tomcat的修改方法
  4. int组成时间值
  5. libevent 初试
  6. Apple MDM Supported configurable settings
  7. Mysql 数据库安装配置
  8. Projected Coordinate Systems
  9. sql server返回插入数据表的id,和插入时间
  10. UserControl eventhander 注册问题