Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public AuthMethodCatalog(OAuth2ClientProperties oAuth2ClientProperties,
public List<AuthProviderResponse> listOAuthProviders(String returnTo) {
String sanitizedReturnTo = OAuthLoginRedirectSupport.sanitizeReturnTo(returnTo);
return new ArrayList<>(oAuth2ClientProperties.getRegistration().entrySet().stream()
.filter(entry -> isValidOAuthProvider(entry.getValue()))
.sorted(Comparator.comparing(entry -> entry.getKey()))
.map(entry -> new AuthProviderResponse(
entry.getKey(),
Expand All @@ -54,6 +55,19 @@ public List<AuthProviderResponse> listOAuthProviders(String returnTo) {
.toList());
}

/**
* Check if an OAuth provider has valid configuration (non-empty client-id that is not a placeholder).
*/
private boolean isValidOAuthProvider(OAuth2ClientProperties.Registration registration) {
String clientId = registration.getClientId();
if (clientId == null || clientId.isBlank()) {
return false;
}
// Filter out placeholder values used in dev/test configs
String lowerClientId = clientId.toLowerCase();
return !lowerClientId.contains("placeholder") && !lowerClientId.contains("local-placeholder");
}

public List<AuthMethodResponse> listMethods(String returnTo) {
String sanitizedReturnTo = OAuthLoginRedirectSupport.sanitizeReturnTo(returnTo);
List<AuthMethodResponse> methods = new ArrayList<>();
Expand All @@ -67,6 +81,7 @@ public List<AuthMethodResponse> listMethods(String returnTo) {
));

oAuth2ClientProperties.getRegistration().entrySet().stream()
.filter(entry -> isValidOAuthProvider(entry.getValue()))
.sorted(Comparator.comparing(entry -> entry.getKey()))
.forEach(entry -> methods.add(new AuthMethodResponse(
"oauth-" + entry.getKey(),
Expand Down
Loading