Merge pull request #11647 from cbecker/oauth2-custom-add-none-auth-method

Custom OAuth 2.0: Add NONE auth method needed for some auth servers like Django
This commit is contained in:
Viacheslav Klimov 2024-12-03 11:47:29 +02:00 committed by GitHub
commit a58f3aed65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -43,6 +43,15 @@ public class HybridClientRegistrationRepository implements ClientRegistrationRep
private ClientRegistration toSpringClientRegistration(OAuth2Client oAuth2Client){
String registrationId = oAuth2Client.getUuidId().toString();
// NONE is used if we need pkce-based code challenge
ClientAuthenticationMethod authMethod = ClientAuthenticationMethod.NONE;
if (oAuth2Client.getClientAuthenticationMethod().equals("POST")) {
authMethod = ClientAuthenticationMethod.CLIENT_SECRET_POST;
} else if (oAuth2Client.getClientAuthenticationMethod().equals("BASIC")) {
authMethod = ClientAuthenticationMethod.CLIENT_SECRET_BASIC;
}
return ClientRegistration.withRegistrationId(registrationId)
.clientName(oAuth2Client.getName())
.clientId(oAuth2Client.getClientId())
@ -54,8 +63,7 @@ public class HybridClientRegistrationRepository implements ClientRegistrationRep
.userInfoUri(oAuth2Client.getUserInfoUri())
.userNameAttributeName(oAuth2Client.getUserNameAttributeName())
.jwkSetUri(oAuth2Client.getJwkSetUri())
.clientAuthenticationMethod(oAuth2Client.getClientAuthenticationMethod().equals("POST") ?
ClientAuthenticationMethod.CLIENT_SECRET_POST : ClientAuthenticationMethod.CLIENT_SECRET_BASIC)
.clientAuthenticationMethod(authMethod)
.redirectUri(defaultRedirectUriTemplate)
.build();
}

View File

@ -68,6 +68,7 @@ export interface OAuth2RegistrationInfo {
}
export enum ClientAuthenticationMethod {
NONE = 'NONE',
BASIC = 'BASIC',
POST = 'POST'
}