From c3859fa34f5644a290787a22a2a3ccfb4a465c1a Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Mon, 23 Mar 2015 21:30:56 -0400 Subject: [PATCH] oidc logout and console fixes --- .../broker/oidc/OIDCIdentityProvider.java | 2 +- .../oidc/OIDCIdentityProviderConfig.java | 9 ++++ .../oidc/OIDCIdentityProviderFactory.java | 25 ++++++++++ .../broker/saml/SAMLIdentityProvider.java | 2 +- .../theme/base/admin/resources/js/app.js | 47 +++++++++++++++++++ .../admin/resources/js/controllers/realm.js | 12 ++++- .../realm-identity-provider-oidc.html | 45 ++++++++++++++---- .../realm-identity-provider-saml.html | 12 ++--- .../realm-identity-provider-social.html | 2 +- .../oidc/endpoints/LogoutEndpoint.java | 4 +- .../OIDCConfigurationRepresentation.java | 17 +++++++ 11 files changed, 157 insertions(+), 20 deletions(-) mode change 100644 => 100755 broker/oidc/src/main/java/org/keycloak/broker/oidc/OIDCIdentityProviderFactory.java diff --git a/broker/oidc/src/main/java/org/keycloak/broker/oidc/OIDCIdentityProvider.java b/broker/oidc/src/main/java/org/keycloak/broker/oidc/OIDCIdentityProvider.java index 3e052728cc..6da5e59a8a 100755 --- a/broker/oidc/src/main/java/org/keycloak/broker/oidc/OIDCIdentityProvider.java +++ b/broker/oidc/src/main/java/org/keycloak/broker/oidc/OIDCIdentityProvider.java @@ -103,7 +103,7 @@ public class OIDCIdentityProvider extends AbstractOAuth2IdentityProvider parseConfig(InputStream inputStream) { + OIDCConfigurationRepresentation rep = null; + try { + rep = JsonSerialization.readValue(inputStream, OIDCConfigurationRepresentation.class); + } catch (IOException e) { + throw new RuntimeException("failed to load openid connect metadata", e); + } + OIDCIdentityProviderConfig config = new OIDCIdentityProviderConfig(new IdentityProviderModel()); + config.setIssuer(rep.getIssuer()); + config.setLogoutUrl(rep.getLogoutEndpoint()); + config.setAuthorizationUrl(rep.getAuthorizationEndpoint()); + config.setTokenUrl(rep.getTokenEndpoint()); + config.setUserInfoUrl(rep.getUserinfoEndpoint()); + return config.getConfig(); + + } } diff --git a/broker/saml/src/main/java/org/keycloak/broker/saml/SAMLIdentityProvider.java b/broker/saml/src/main/java/org/keycloak/broker/saml/SAMLIdentityProvider.java index 4ac8177b82..214b155d78 100755 --- a/broker/saml/src/main/java/org/keycloak/broker/saml/SAMLIdentityProvider.java +++ b/broker/saml/src/main/java/org/keycloak/broker/saml/SAMLIdentityProvider.java @@ -118,7 +118,7 @@ public class SAMLIdentityProvider extends AbstractIdentityProvider + */ +module.directive('onoffswitchvalue', function() { + return { + restrict: "EA", + replace: true, + scope: { + name: '@', + id: '@', + value: '=', + ngModel: '=', + ngDisabled: '=', + kcOnText: '@onText', + kcOffText: '@offText' + }, + // TODO - The same code acts differently when put into the templateURL. Find why and move the code there. + //templateUrl: "templates/kc-switch.html", + template: "
", + compile: function(element, attrs) { + /* + We don't want to propagate basic attributes to the root element of directive. Id should be passed to the + input element only to achieve proper label binding (and validity). + */ + element.removeAttr('name'); + element.removeAttr('id'); + + if (!attrs.onText) { attrs.onText = "ON"; } + if (!attrs.offText) { attrs.offText = "OFF"; } + + element.bind('keydown', function(e){ + var code = e.keyCode || e.which; + if (code === 32 || code === 13) { + e.stopImmediatePropagation(); + e.preventDefault(); + $(e.target).find('input').click(); + } + }); + } + } +}); + module.directive('kcInput', function() { var d = { scope : true, diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js index 55b74f0fa7..b030948cdc 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js @@ -643,6 +643,15 @@ module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload $scope.realm = angular.copy(realm); + $scope.initProvider = function() { + if (instance && instance.alias) { + + } else { + $scope.identityProvider.updateProfileFirstLogin = false; + } + + }; + $scope.initSamlProvider = function() { $scope.nameIdFormats = [ { @@ -684,6 +693,7 @@ module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload } else { $scope.identityProvider.config.nameIDPolicyFormat = $scope.nameIdFormats[0].format; + $scope.identityProvider.updateProfileFirstLogin = false; } } @@ -698,7 +708,7 @@ module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload $scope.identityProvider.alias = providerFactory.name; $scope.identityProvider.providerId = providerFactory.id; $scope.identityProvider.enabled = true; - $scope.identityProvider.updateProfileFirstLogin = true; + $scope.identityProvider.updateProfileFirstLogin = false; $scope.identityProvider.authenticateByDefault = false; $scope.newIdentityProvider = true; } diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/realm-identity-provider-oidc.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/realm-identity-provider-oidc.html index df99908842..e89569c2bc 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/realm-identity-provider-oidc.html +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/realm-identity-provider-oidc.html @@ -1,23 +1,42 @@
-
+

-

{{identityProvider.name}} Provider Settings

+

{{identityProvider.alias}} Provider Settings

* Required fields

- +
+
+ +
+ +
+ +
+
+ +
+ + + {{files[0].name}} + +
+
@@ -33,11 +52,18 @@
- +
- +
- + +
+
+ +
+ +
+
@@ -116,7 +142,10 @@
- + + + +
diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/realm-identity-provider-saml.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/realm-identity-provider-saml.html index 4e1d88c4b9..aa0364b76d 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/realm-identity-provider-saml.html +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/realm-identity-provider-saml.html @@ -47,7 +47,7 @@
- +
@@ -71,35 +71,35 @@
- +
- +
- +
- +
- +
diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/realm-identity-provider-social.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/realm-identity-provider-social.html index d37e6a3f31..aa6a5ebe98 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/realm-identity-provider-social.html +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/realm-identity-provider-social.html @@ -1,5 +1,5 @@
-
+

diff --git a/services/src/main/java/org/keycloak/protocol/oidc/endpoints/LogoutEndpoint.java b/services/src/main/java/org/keycloak/protocol/oidc/endpoints/LogoutEndpoint.java index 07b9d0028e..a61c8112e7 100755 --- a/services/src/main/java/org/keycloak/protocol/oidc/endpoints/LogoutEndpoint.java +++ b/services/src/main/java/org/keycloak/protocol/oidc/endpoints/LogoutEndpoint.java @@ -121,7 +121,7 @@ public class LogoutEndpoint { AuthenticationManager.AuthResult authResult = authManager.authenticateIdentityCookie(session, realm, uriInfo, clientConnection, headers, false); if (authResult != null) { userSession = userSession != null ? userSession : authResult.getSession(); - if (redirectUri != null) userSession.setNote(OIDCLoginProtocol.LOGOUT_REDIRECT_URI, redirect); + if (redirect != null) userSession.setNote(OIDCLoginProtocol.LOGOUT_REDIRECT_URI, redirect); if (state != null) userSession.setNote(OIDCLoginProtocol.LOGOUT_STATE_PARAM, state); userSession.setNote(AuthenticationManager.KEYCLOAK_LOGOUT_PROTOCOL, OIDCLoginProtocol.LOGIN_PROTOCOL); return AuthenticationManager.browserLogout(session, realm, authResult.getSession(), uriInfo, clientConnection, headers); @@ -131,7 +131,7 @@ public class LogoutEndpoint { event.user(userSession.getUser()).session(userSession).success(); } - if (redirectUri != null) { + if (redirect != null) { UriBuilder uriBuilder = UriBuilder.fromUri(redirect); if (state != null) uriBuilder.queryParam(OIDCLoginProtocol.STATE_PARAM, state); return Response.status(302).location(uriBuilder.build()).build(); diff --git a/services/src/main/java/org/keycloak/protocol/oidc/representations/OIDCConfigurationRepresentation.java b/services/src/main/java/org/keycloak/protocol/oidc/representations/OIDCConfigurationRepresentation.java index 0e3d4f3490..9245e588b9 100755 --- a/services/src/main/java/org/keycloak/protocol/oidc/representations/OIDCConfigurationRepresentation.java +++ b/services/src/main/java/org/keycloak/protocol/oidc/representations/OIDCConfigurationRepresentation.java @@ -1,8 +1,12 @@ package org.keycloak.protocol.oidc.representations; +import org.codehaus.jackson.annotate.JsonAnyGetter; +import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Set; /** @@ -44,6 +48,8 @@ public class OIDCConfigurationRepresentation { @JsonProperty("response_modes_supported") private List responseModesSupported; + protected Map otherClaims = new HashMap(); + public String getIssuer() { return issuer; } @@ -131,4 +137,15 @@ public class OIDCConfigurationRepresentation { public void setResponseModesSupported(List responseModesSupported) { this.responseModesSupported = responseModesSupported; } + + @JsonAnyGetter + public Map getOtherClaims() { + return otherClaims; + } + + @JsonAnySetter + public void setOtherClaims(String name, Object value) { + otherClaims.put(name, value); + } + }