Spring security 在构建uaa服务器时,我应该在令牌中生成什么内容?
我已经阅读了OAuth2(RFC6749),现在我想构建自己的uaa 我选择spring授权服务器,这是我的计划 我的本机应用使用资源所有者密码凭据授权类型。 第三方软件使用授权码授权类型。 但是,spring授权服务器将不支持资源所有者密码凭据授予 因此,我将只在我的本机应用程序中使用JWT令牌 但我在这里面临一个问题Spring security 在构建uaa服务器时,我应该在令牌中生成什么内容?,spring-security,Spring Security,我已经阅读了OAuth2(RFC6749),现在我想构建自己的uaa 我选择spring授权服务器,这是我的计划 我的本机应用使用资源所有者密码凭据授权类型。 第三方软件使用授权码授权类型。 但是,spring授权服务器将不支持资源所有者密码凭据授予 因此,我将只在我的本机应用程序中使用JWT令牌 但我在这里面临一个问题 Collection<? extends GrantedAuthority> authorities = userDetails.getAuthorities();
Collection<? extends GrantedAuthority> authorities = userDetails.getAuthorities();
if (!CollectionUtils.isEmpty(authorities)){
for (GrantedAuthority grantedAuthority:authorities){
scopes.add(grantedAuthority.getAuthority());
}
}
//generate token ...
在这种情况下,JWT代币仍然是一个好计划吗
或者我应该只返回令牌中的角色吗
我想学习如何建立一个好的用户帐户和身份验证服务器的最佳实践
谢谢你的时间
{
"sub": "messaging-client",
"aud": "messaging-client",
"nbf": 1621495065,
"authorities": [
"message.read",
"message.write",
"a1",
"a2",
"a3",
...
...
...
//to many here
...
...
],
"iss": "http://auth-server:9000",
"exp": 1621495365,
"iat": 1621495065,
"jti": "49fb7601-53de-402c-b5d9-4ee328c24007"
}