Ldap 组作为范围是否适用于 cloud foundry uaa authorization_code 授权类型?
Do Ldap Groups as Scopes work for cloud foundry uaa authorization_code grant type?
我正在尝试让微服务环境正常工作。我已经设置了 config-server、eureka-server、zuul-server 和服务。为了处理安全问题,我安装了 Cloud Foundry 的 UAA 服务器和 运行。
按照关于如何设置 UAA 服务器的文档,可以选择 Ldap Groups as Scopes 我有,我可以看到它们是如何在 UAA 服务器日志上创建的,但它们没有进入智威汤逊令牌。 Zuul 正确代理到 UAA 服务器,我在 UAA 上执行身份验证过程并在 Zuul 上获取 JWT 令牌,然后 zuul 将代理添加到它背后的服务,但没有登录用户的 groups/scopes 只有 openid客户端配置上的范围。我错过了什么吗?或者这就是事情的运作方式,我将不得不实施一个解决方法,即从令牌中获取用户的用户名,并在每个服务的每个请求中获取他的访问权限?
这是我的 uaa.yml:
spring_profiles: ldap,mysql
disableInternalUserManagement: true
zones:
internal:
hostnames:
- sso.example.com
oauth:
user:
authorities:
- openid
- scim.me
- password.write
- scim.userids
- uaa.user
- approvals.me
- oauth.approvals
clients:
sso:
secret: changeme!
authorized-grant-types: authorization_code, refresh_token
# How do I add the user groups as scopes?
# Is it possible with this grant type?
scope: openid
authorities: uaa.resource
ldap:
profile:
file: ldap/ldap-search-and-bind.xml
base:
url: ldap://ldap.example.com:389
mailAttributeName: mail
mailSubstitute: '{0}@example.com'
mailSubstituteOverridesLdap: true
userDn: 'CN=Example User,OU=Admins,DC=example,DC=com'
password: 'changeme!'
searchBase: 'dc=example,dc=com'
searchFilter: 'sAMAccountName={0}'
groups:
file: ldap/ldap-groups-as-scopes.xml
searchBase: 'dc=example,dc=com'
groupRoleAttribute: cn
searchSubtree: true
groupSearchFilter: 'member={0}'
maxSearchDepth: 1
autoAdd: true
attributeMappings:
first_name: 'givenName'
last_name: 'sn'
smtp:
host: mail.example.com
port: 25
database:
url: jdbc:mysql://mysql.example.com/uaa
username: uaa
password: changeme!
jwt:
token:
verification-key: |
-----BEGIN PUBLIC KEY-----
-----END PUBLIC KEY-----
signing-key: |
-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----
login:
url: https://sso.example.com/uaa/login
branding:
companyName: 'Example Company'
您的问题源于未在客户端上配置范围。只有该客户端范围列表中的范围才能出现在用户 JWT 上。将范围添加到此列表将不允许用户获得他们没有的范围,也不会导致这些范围出现在客户端的客户端凭据令牌上。
如果您配置了组作为范围,则您的客户端需要在其允许范围列表中配置您希望它使用的每个范围。
我正在尝试让微服务环境正常工作。我已经设置了 config-server、eureka-server、zuul-server 和服务。为了处理安全问题,我安装了 Cloud Foundry 的 UAA 服务器和 运行。
按照关于如何设置 UAA 服务器的文档,可以选择 Ldap Groups as Scopes 我有,我可以看到它们是如何在 UAA 服务器日志上创建的,但它们没有进入智威汤逊令牌。 Zuul 正确代理到 UAA 服务器,我在 UAA 上执行身份验证过程并在 Zuul 上获取 JWT 令牌,然后 zuul 将代理添加到它背后的服务,但没有登录用户的 groups/scopes 只有 openid客户端配置上的范围。我错过了什么吗?或者这就是事情的运作方式,我将不得不实施一个解决方法,即从令牌中获取用户的用户名,并在每个服务的每个请求中获取他的访问权限?
这是我的 uaa.yml:
spring_profiles: ldap,mysql
disableInternalUserManagement: true
zones:
internal:
hostnames:
- sso.example.com
oauth:
user:
authorities:
- openid
- scim.me
- password.write
- scim.userids
- uaa.user
- approvals.me
- oauth.approvals
clients:
sso:
secret: changeme!
authorized-grant-types: authorization_code, refresh_token
# How do I add the user groups as scopes?
# Is it possible with this grant type?
scope: openid
authorities: uaa.resource
ldap:
profile:
file: ldap/ldap-search-and-bind.xml
base:
url: ldap://ldap.example.com:389
mailAttributeName: mail
mailSubstitute: '{0}@example.com'
mailSubstituteOverridesLdap: true
userDn: 'CN=Example User,OU=Admins,DC=example,DC=com'
password: 'changeme!'
searchBase: 'dc=example,dc=com'
searchFilter: 'sAMAccountName={0}'
groups:
file: ldap/ldap-groups-as-scopes.xml
searchBase: 'dc=example,dc=com'
groupRoleAttribute: cn
searchSubtree: true
groupSearchFilter: 'member={0}'
maxSearchDepth: 1
autoAdd: true
attributeMappings:
first_name: 'givenName'
last_name: 'sn'
smtp:
host: mail.example.com
port: 25
database:
url: jdbc:mysql://mysql.example.com/uaa
username: uaa
password: changeme!
jwt:
token:
verification-key: |
-----BEGIN PUBLIC KEY-----
-----END PUBLIC KEY-----
signing-key: |
-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----
login:
url: https://sso.example.com/uaa/login
branding:
companyName: 'Example Company'
您的问题源于未在客户端上配置范围。只有该客户端范围列表中的范围才能出现在用户 JWT 上。将范围添加到此列表将不允许用户获得他们没有的范围,也不会导致这些范围出现在客户端的客户端凭据令牌上。
如果您配置了组作为范围,则您的客户端需要在其允许范围列表中配置您希望它使用的每个范围。