Return 404 when trying to retrieve non-existing external IDP token
This commit is contained in:
parent
83147a67a0
commit
69c114288d
1 changed files with 9 additions and 0 deletions
|
@ -474,6 +474,10 @@ public class IdentityBrokerService implements IdentityProvider.AuthenticationCal
|
|||
return corsResponse(badRequest("User [" + authResult.getUser().getId() + "] is not associated with identity provider [" + providerId + "]."), clientModel);
|
||||
}
|
||||
|
||||
if (identity.getToken() == null) {
|
||||
return corsResponse(notFound("No token stored for user [" + authResult.getUser().getId() + "] with associated identity provider [" + providerId + "]."), clientModel);
|
||||
}
|
||||
|
||||
this.event.success();
|
||||
|
||||
return corsResponse(identityProvider.retrieveToken(session, identity), clientModel);
|
||||
|
@ -1224,6 +1228,11 @@ public class IdentityBrokerService implements IdentityProvider.AuthenticationCal
|
|||
return ErrorResponse.error(message, Response.Status.FORBIDDEN);
|
||||
}
|
||||
|
||||
private Response notFound(String message) {
|
||||
fireErrorEvent(message);
|
||||
return ErrorResponse.error(message, Response.Status.NOT_FOUND);
|
||||
}
|
||||
|
||||
public static IdentityProvider getIdentityProvider(KeycloakSession session, RealmModel realm, String alias) {
|
||||
IdentityProviderModel identityProviderModel = realm.getIdentityProviderByAlias(alias);
|
||||
|
||||
|
|
Loading…
Reference in a new issue