feat: Add Principal attribute to authorizationBuilder when password authenticate successfully (#1878)

pull/1895/head
guqing 2022-04-22 17:36:11 +08:00 committed by GitHub
parent a7b9433120
commit 9a0dc50653
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package run.halo.app.identity.authentication;
import java.security.Principal;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
@ -78,7 +79,8 @@ public class OAuth2PasswordAuthenticationProvider extends DaoAuthenticationProvi
OAuth2Authorization.Builder authorizationBuilder = new OAuth2Authorization.Builder()
.principalName(authentication.getName())
.authorizationGrantType(AuthorizationGrantType.PASSWORD)
.attribute(OAuth2Authorization.AUTHORIZED_SCOPE_ATTRIBUTE_NAME, scopes);
.attribute(OAuth2Authorization.AUTHORIZED_SCOPE_ATTRIBUTE_NAME, scopes)
.attribute(Principal.class.getName(), authentication);
// ----- Access token -----
OAuth2TokenContext tokenContext =