spring oauth Role and Authority and scope
使用hasRole
class Grant implements GrantedAuthority{
@Override
public String getAuthority() {
return "ROLE_ADMIN";
}
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
authorities.add(new Grant());
return authorities;
}
匹配
.antMatchers("/hotel/**").access("hasRole('ADMIN')")
使用hasAnyAuthority
class Grant implements GrantedAuthority{
@Override
public String getAuthority() {
return "ADMIN";
}
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
authorities.add(new Grant());
return authorities;
}
匹配
.antMatchers("/hotel/**").access("hasAnyAuthority('ADMIN')")
使用scope
{
"access_token": "3e261513-943c-497e-95b8-703ba96101ed",
"token_type": "bearer",
"expires_in": 199,
"scope": "write resource-server-read"
}
匹配
.antMatchers("/hotel/**").access("#oauth2.hasScope('resource-server-read')")
使用resource id
client中的 resource id信息
匹配
@Override
public void configure(ResourceServerSecurityConfigurer resources) {
// @formatter:off
resources
.resourceId("resource");
// @formatter:on
}
总结 ROLE 和 authority 是用户 自己的属性
scope 是 client的属性
spring oauth Role and Authority and scope的更多相关文章
- Spring boot --- Spring Oauth(一)
文章部分图片来自参考资料,这篇文章主要讲 spring security oauth 概述 上一篇我们学习了 SS 中重要的工作原理和几个大概的认证和授权过程.而 spring securit ...
- spring mvc 的Controller类默认Scope是单例(singleton)的
使用Spring MVC有一段时间了,之前一直使用Struts2,在struts2中action都是原型(prototype)的, 说是因为线程安全问题,对于Spring MVC中bean默认都是(s ...
- Spring学习(二):Spring支持的5种Bean Scope
序言 Scope是定义Spring如何创建bean的实例的.Spring容器最初提供了两种bean的scope类型:singleton和prototype,但发布2.0以后,又引入了另外三种scope ...
- spring中的bean的属性scope
spring中bean的scope属性,有如下5种类型: singleton 表示在spring容器中的单例,通过spring容器获得该bean时总是返回唯一的实例 prototype表示每次获得be ...
- Spring boot --- Spring Oauth(三)
本节将学习 spring security oauth 实现单点登录 概述 首先我们来了解什么是单点登录.看下面两张图就明白了. 很明显,单点登录最重要解决的就是登录和注销的功能,今天的例子,可以用 ...
- Spring配置文件中<bean>标签的scope属性
转自:https://fj-sh-chz.iteye.com/blog/1775149 singleton (默认属性) Spring将Bean放入Spring IOC容器的缓存池中,并将Bean引 ...
- (三)Spring 高级装配 bean的作用域@Scope
1.默认情况下,spring通过@Autowared注入的bean是单例的bean,但有些情况是不满足的,例如:购物车,每个会话,或每个用户登录使用的购物车都是独立的 spring的定义的作用域: a ...
- 【Spring】bean的作用域(@Scope) - singleton、prototype
已知spring 3+已拥有多种不同的作用域: singleton(默认).prototype.request.session.global session.(参考: spring中scope作用域( ...
- 【Spring注解驱动开发】使用@Scope注解设置组件的作用域
写在前面 Spring容器中的组件默认是单例的,在Spring启动时就会实例化并初始化这些对象,将其放到Spring容器中,之后,每次获取对象时,直接从Spring容器中获取,而不再创建对象.如果每次 ...
随机推荐
- docker常用命令 状态图
http://blog.csdn.net/permike/article/details/51879578
- Word绘制跨行表格
如图“用户评价电影数目”,我们需要均分第一行,选中这三个个,设置了表个高度0.5cm,但是发现上面的一个比较考上,我们需要找到水平竖直居中,那么双击表格,打开表格工具,有设计和布局,切换到布局就找到了 ...
- 关于shape和selector和layer-list的drawable详细说明
在Android开发中,但凡涉及控件的的特效问题,<shape>,<selector>以及<layer-list>都是不可或缺的drawable.但是发现有同事并不 ...
- virtualenv、virtualenvwrapper安装和使用;Mac os的特殊性
[sudo] pip install virtualenv 或者[sudo] pip3 install virtualenv [sudo]可用可不用 pip/pip3 install virtuale ...
- PHP中使用XMLRPC
PHP中简单使用XMLRPC,服务器端和客户端都为PHP代码实现. 这里使用的XML-RPC完整包括client和server的XML-RPC实现. 客户端和服务器端分别由 xmlrpc_client ...
- MyEclipse中快捷键
------------------------------------- MyEclipse 快捷键1(CTRL) ------------------------------------- Ctr ...
- 多个客户端连接socket
import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import ...
- 解读Spark Streaming RDD的全生命周期
本节主要内容: 一.DStream与RDD关系的彻底的研究 二.StreamingRDD的生成彻底研究 Spark Streaming RDD思考三个关键的问题: RDD本身是基本对象,根据一定时间定 ...
- 实现一个JDK代理demo
JDK代理,非常简单地实现了动态代理(首先是实现对应的InvocationHandler:然后,以接口来为被调用目标构建代理对象,代理对象简介运行调用目标,并提供额外逻辑插入) 缺点:它是只能以接口为 ...
- idea Tomcat 部署 war和war exploded的区别
idea Tomcat 部署 war和war exploded的区别 学习了:https://blog.csdn.net/linjpg/article/details/73322881 explode ...