Skip to content
This repository has been archived by the owner on Oct 12, 2020. It is now read-only.

Update to Keycloak 9.0.0 and apply API change #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
- docker

env:
- KEYCLOAK_VERSION=7.0.0
- KEYCLOAK_VERSION=9.0.0

before_install:
- if [ "$TRAVIS_EVENT_TYPE" != "cron" ]; then docker pull quay.io/keycloak/keycloak:$KEYCLOAK_VERSION; fi
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>org.keycloak</groupId>
<artifactId>keycloak-protocol-cas</artifactId>
<version>7.0.0</version>
<version>9.0.0</version>
<name>Keycloak CAS Protocol</name>
<description />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void backchannelLogout(UserSessionModel userSession, AuthenticatedClientS
sendSingleLogoutRequest(logoutUrl, serviceTicket);
}
ClientModel client = clientSession.getClient();
new ResourceAdminManager(session).logoutClientSession(uriInfo.getRequestUri(), realm, client, clientSession);
new ResourceAdminManager(session).logoutClientSession(realm, client, clientSession);
}

private void sendSingleLogoutRequest(String logoutUrl, String serviceTicket) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected void checkClient(String service) {

client = realm.getClients().stream()
.filter(c -> CASLoginProtocol.LOGIN_PROTOCOL.equals(c.getProtocol()))
.filter(c -> RedirectUtils.verifyRedirectUri(session.getContext().getUri(), service, realm, c) != null)
.filter(c -> RedirectUtils.verifyRedirectUri(session, service, c) != null)
.findFirst().orElse(null);
if (client == null) {
event.error(Errors.CLIENT_NOT_FOUND);
Expand Down Expand Up @@ -153,7 +153,7 @@ protected void checkTicket(String ticket, boolean requireReauth) {
protected Map<String, Object> getUserAttributes() {
UserSessionModel userSession = clientSession.getUserSession();
// CAS protocol does not support scopes, so pass null scopeParam
ClientSessionContext clientSessionCtx = DefaultClientSessionContext.fromClientSessionAndScopeParameter(clientSession, null);
ClientSessionContext clientSessionCtx = DefaultClientSessionContext.fromClientSessionAndScopeParameter(clientSession, null, session);

Set<ProtocolMapperModel> mappings = clientSessionCtx.getProtocolMappers();
KeycloakSessionFactory sessionFactory = session.getKeycloakSessionFactory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private void checkClient(String service) {

client = realm.getClients().stream()
.filter(c -> CASLoginProtocol.LOGIN_PROTOCOL.equals(c.getProtocol()))
.filter(c -> RedirectUtils.verifyRedirectUri(session.getContext().getUri(), service, realm, c) != null)
.filter(c -> RedirectUtils.verifyRedirectUri(session, service, c) != null)
.findFirst().orElse(null);
if (client == null) {
event.error(Errors.CLIENT_NOT_FOUND);
Expand All @@ -76,7 +76,7 @@ private void checkClient(String service) {
throw new ErrorPageException(session, Response.Status.BAD_REQUEST, Messages.CLIENT_DISABLED);
}

redirectUri = RedirectUtils.verifyRedirectUri(session.getContext().getUri(), service, realm, client);
redirectUri = RedirectUtils.verifyRedirectUri(session, service, client);

event.client(client.getClientId());
event.detail(Details.REDIRECT_URI, redirectUri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ private void checkClient(String service) {

client = realm.getClients().stream()
.filter(c -> CASLoginProtocol.LOGIN_PROTOCOL.equals(c.getProtocol()))
.filter(c -> RedirectUtils.verifyRedirectUri(session.getContext().getUri(), service, realm, c) != null)
.filter(c -> RedirectUtils.verifyRedirectUri(session, service, c) != null)
.findFirst().orElse(null);
if (client != null) {
redirectUri = RedirectUtils.verifyRedirectUri(session.getContext().getUri(), service, realm, client);
redirectUri = RedirectUtils.verifyRedirectUri(session, service, client);

session.getContext().setClient(client);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.keycloak.protocol.cas.representations;

public interface SAMLCASConstants {

String AUTH_METHOD_PASSWORD = "urn:oasis:names:tc:SAML:1.0:am:password";

String FORMAT_EMAIL_ADDRESS = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress";

String FORMAT_UNSPECIFIED = "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified";

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static SAML11ResponseType successResponse(String issuer, String username,
conditions.setNotOnOrAfter(factory.newXMLGregorianCalendar(GregorianCalendar.from(nowZoned.plusMinutes(5))));
}));
assertion.add(applyTo(new SAML11AuthenticationStatementType(
URI.create(SAML11Constants.AUTH_METHOD_PASSWORD),
URI.create(SAMLCASConstants.AUTH_METHOD_PASSWORD),
now
), stmt -> stmt.setSubject(toSubject(username))));
assertion.addAllStatements(toAttributes(username, attributes));
Expand Down Expand Up @@ -141,8 +141,8 @@ private static SAML11SubjectType toSubject(String username) {

private static URI nameIdFormat(String username) {
return URI.create(Validation.isEmailValid(username) ?
SAML11Constants.FORMAT_EMAIL_ADDRESS :
SAML11Constants.FORMAT_UNSPECIFIED
SAMLCASConstants.FORMAT_EMAIL_ADDRESS :
SAMLCASConstants.FORMAT_UNSPECIFIED
);
}

Expand Down