use of org.keycloak.models.ClientModel in project keycloak by keycloak.
the class OpenShiftTokenReviewEndpoint method authorizeClient.
private void authorizeClient() {
try {
ClientModel client = AuthorizeClientUtil.authorizeClient(session, event, null).getClient();
event.client(client);
if (client == null || client.isPublicClient()) {
error(401, Errors.INVALID_CLIENT, "Public client is not permitted to invoke token review endpoint");
}
} catch (ErrorResponseException ere) {
error(401, Errors.INVALID_CLIENT_CREDENTIALS, ere.getErrorDescription());
} catch (Exception e) {
error(401, Errors.INVALID_CLIENT_CREDENTIALS, null);
}
}
use of org.keycloak.models.ClientModel in project keycloak by keycloak.
the class SamlSessionUtils method getSessionIndex.
public static String getSessionIndex(AuthenticatedClientSessionModel clientSession) {
UserSessionModel userSession = clientSession.getUserSession();
ClientModel client = clientSession.getClient();
return userSession.getId() + DELIMITER + client.getId();
}
use of org.keycloak.models.ClientModel in project keycloak by keycloak.
the class DeclarativeUserProfileProvider method requestedScopePredicate.
/**
* Method used for predicate which returns true if any of the configuredScopes is requested in current auth flow.
*
* @param context to get current auth flow from
* @param configuredScopes to be evaluated
* @return
*/
private static boolean requestedScopePredicate(AttributeContext context, Set<String> configuredScopes) {
KeycloakSession session = context.getSession();
AuthenticationSessionModel authenticationSession = session.getContext().getAuthenticationSession();
if (authenticationSession == null) {
return false;
}
String requestedScopesString = authenticationSession.getClientNote(OIDCLoginProtocol.SCOPE_PARAM);
ClientModel client = authenticationSession.getClient();
return getRequestedClientScopes(requestedScopesString, client).map((csm) -> csm.getName()).anyMatch(configuredScopes::contains);
}
use of org.keycloak.models.ClientModel in project keycloak by keycloak.
the class DefaultClientValidationProvider method validatePairwise.
private void validatePairwise(ValidationContext<ClientModel> context, String sectorIdentifierUri) {
ClientModel client = context.getObjectToValidate();
String rootUrl = client.getRootUrl();
Set<String> redirectUris = new HashSet<>();
if (client.getRedirectUris() != null)
redirectUris.addAll(client.getRedirectUris());
try {
PairwiseSubMapperValidator.validate(context.getSession(), rootUrl, redirectUris, sectorIdentifierUri);
} catch (ProtocolMapperConfigException e) {
context.addError("pairWise", e.getMessage(), e.getMessageKey());
}
}
use of org.keycloak.models.ClientModel in project keycloak by keycloak.
the class RoleResolveUtil method addToToken.
private static void addToToken(AccessToken token, RoleModel role) {
AccessToken.Access access = null;
if (role.getContainer() instanceof RealmModel) {
access = token.getRealmAccess();
if (token.getRealmAccess() == null) {
access = new AccessToken.Access();
token.setRealmAccess(access);
} else if (token.getRealmAccess().getRoles() != null && token.getRealmAccess().isUserInRole(role.getName()))
return;
} else {
ClientModel app = (ClientModel) role.getContainer();
access = token.getResourceAccess(app.getClientId());
if (access == null) {
access = token.addAccess(app.getClientId());
if (app.isSurrogateAuthRequired())
access.verifyCaller(true);
} else if (access.isUserInRole(role.getName()))
return;
}
access.addRole(role.getName());
}
Aggregations