Browse Source
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
pull/12172/head
Viacheslav Klimov
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
11 additions and
2 deletions
-
dao/src/main/java/org/thingsboard/server/dao/oauth2/HybridClientRegistrationRepository.java
-
ui-ngx/src/app/shared/models/oauth2.models.ts
|
|
|
@ -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(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -68,6 +68,7 @@ export interface OAuth2RegistrationInfo { |
|
|
|
} |
|
|
|
|
|
|
|
export enum ClientAuthenticationMethod { |
|
|
|
NONE = 'NONE', |
|
|
|
BASIC = 'BASIC', |
|
|
|
POST = 'POST' |
|
|
|
} |
|
|
|
|