首页 > 其他分享 >CloudFoundry User Account and Authentication (UAA) Server‘s Scope System

CloudFoundry User Account and Authentication (UAA) Server‘s Scope System

时间:2022-10-30 18:36:24浏览次数:39  
标签:Account System CloudFoundry token client user scope 权限 字段


文章目录

  • ​​导读​​
  • ​​UAA 里所有可以配置权限的地方​​
  • ​​UAA 里关于权限的几个概念​​
  • ​​5分钟学会 UAA 的权限配置​​
  • ​​请求 access token 的方式对权限配置的影响​​
  • ​​利用 access token 交换权限信息的方式对权限配置的影响​​

导读

本文说明 CloudFoundry User Account and Authentication (UAA) Server 的 权限系统是如何工作的。看完此文,您就会配置 UAA 的 Client 和 User 的权限,从而生成一个您需要的权限的 access token 了。

UAA 里所有可以配置权限的地方

  • users 表的 authorities 字段,这个字段暂时虽然叫权限,但是暂时没啥用
  • userinfo 表的 info 字段的 roles 属性
  • user group + external group 模块 + zone default groups
  • oauth_client_details 表的 authorities 字段和 scope 字段

UAA 里关于权限的几个概念

  • client scope :client crediential时取client的authorities字段,其他方式时,使用client表的scope字段
  • user scope:group模块 + zone default user group
  • request scope:client scope 和 user scope 和 用户请求的scope的交集

user scope 这个说法,就是 user 的 authority,注意不是 user 表的 authorities 字段存储的值,而是 group 模块存储的权限 zone default groups 的并集;users 表的 authorities 的值暂时没发现有任何作用。

5分钟学会 UAA 的权限配置

要怎么配置权限,首先看客户端请求 access token 和 利用 access token 得到权限信息的方式。

请求 access token 的方式对权限配置的影响

从 UaaAuthorizationRequestManager 中可以得出如下的结论,Access Token 上的 Scope 的计算过程如下:

  1. client scope的取值逻辑
    当为client_credentials类型时,client scope来源为client的authorities字段;如果是其他类型的话,client scope的来源为为client表中scope字段的值;
    如果用户输入了scopes,则client的scopes值为用户输入的scopes值剔除不在client scope来源中的scope,;如果用户没有传递scopes,
    当为client_credentials类型时,client scope的值为client的authorities字段的值;如果是其他类型的话,token的scope的值为client表中scope字段的值;
  2. user scope的取值逻辑为
    当为client_credentials类型时,此时没有用户参与,也就没有user scope;如果是其他类型的,user scope 为group模块存储的权限 + zone default groups的并集;
  3. 取交集client scope和user scope的交集;

结论就是,access token 的 scope 字段是 client scope 和 user scope 的交集;如果是 client_credential 模式,则就是 client scope;

也就是说:

如果客户端使用 client_credential 的模式,此时没有用户参与,token scope = client scope[client_credentials]=oauth_client_details 表的 authorities 字段;

如果客户端不是 client_credential 模式,此时有用户参与,那此时 token scope = client scope[!client_credentials] 和 user scope 的交集 = oauth_client_details 表的 scope 字段的值 和 user group 模块计算得出的 group 的交集;

利用 access token 交换权限信息的方式对权限配置的影响

从 ​​OAuth2 and Friends Resource Server​​ 一文可以看到,客户端获取用户的信息有三种方式,本地解密 access token ,check token endpoint 和 userinfo endpoint。

在 UAA 中,本地解密 access token ,check token endpoint 这两种方式本质上都是读取的 access token 里的 scope 字段,而 userinfo endpoint 接口读取的是 userinfo 表的 info 字段的 JSON 格式的值得 roles 属性。


标签:Account,System,CloudFoundry,token,client,user,scope,权限,字段
From: https://blog.51cto.com/xichenguan/5807692

相关文章