使用 Spring OAuth2 访问租户信息

Accessing Tenant Information with Spring OAuth2

我有一个应用程序需要根据每个方法提取租户信息。我正在使用 Cloud Foundry 的 UAA 服务器来满足我的身份验证和授权需求。我尝试通过执行以下操作来访问租户信息:

@RequestMapping("/")
@PreAuthorize("#oauth2.hasScope('project.retrieveItems')")
public List<ItemDto> retrieveAll(OAuth2Authentication token) {
    ... Code here to retrieve Identity Zone and use it to filter results. 
}

OAuth2Authentication 对象没有任何关于租户的信息,只有范围和授权。有没有办法从方法中获取这些信息?

感谢您的帮助。

IdentityZoneHolder.get()

将 return UAA 中正在访问的当前租户(如果您在 UAA 本身中编码)

但我认为您是在询问您的应用程序,核心 Spring Security Oauth2 实现不知道 tenants

它只知道一个令牌url和一个校验令牌url。