Skip to content

Commit

Permalink
fix: skip login form if kc idp hint is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
NithinKuruba committed Dec 6, 2024
1 parent c41304d commit 7e85347
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.keycloak.authentication.Authenticator;
import org.keycloak.constants.AdapterConstants;

import jakarta.ws.rs.core.MultivaluedHashMap;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
Expand Down Expand Up @@ -49,8 +51,13 @@ public void authenticate(AuthenticationFlowContext context) {
}
}

// if only one IDP is enabled, skip the form
if (!idpContext.isEmpty() && idpContext.size() == 1) {
String hintIdp = "";

if (context.getUriInfo().getQueryParameters().containsKey(AdapterConstants.KC_IDP_HINT)) {
hintIdp = context.getUriInfo().getQueryParameters().getFirst(AdapterConstants.KC_IDP_HINT);

// if only one IDP is enabled or hint IDP is passed, skip the form
if (!idpContext.isEmpty() && (idpContext.size() == 1 || (hintIdp != null && !hintIdp.equals("")))) {
context.attempted();
return;
}
Expand Down

0 comments on commit 7e85347

Please sign in to comment.