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 c136c1dbe1..625424bc42 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 @@ -301,20 +301,20 @@ public class SAMLIdentityProvider extends AbstractIdentityProvider\n" + + " \n" + " " + getConfig().getNameIDPolicyFormat() + "\n" + " \n" + // todo single logout service description // " \n" + " \n"; if (getConfig().isWantAuthnRequestsSigned()) { descriptor += diff --git a/broker/saml/src/main/java/org/keycloak/broker/saml/SAMLIdentityProviderFactory.java b/broker/saml/src/main/java/org/keycloak/broker/saml/SAMLIdentityProviderFactory.java old mode 100644 new mode 100755 index 613e8fc15e..2370a16215 --- a/broker/saml/src/main/java/org/keycloak/broker/saml/SAMLIdentityProviderFactory.java +++ b/broker/saml/src/main/java/org/keycloak/broker/saml/SAMLIdentityProviderFactory.java @@ -19,9 +19,12 @@ package org.keycloak.broker.saml; import org.keycloak.broker.provider.AbstractIdentityProviderFactory; import org.keycloak.models.IdentityProviderModel; +import org.picketlink.common.constants.JBossSAMLConstants; +import org.picketlink.common.constants.JBossSAMLURIConstants; import org.picketlink.common.exceptions.ParsingException; import org.picketlink.common.util.DocumentUtil; import org.picketlink.identity.federation.core.parsers.saml.SAMLParser; +import org.picketlink.identity.federation.saml.v2.metadata.EndpointType; import org.picketlink.identity.federation.saml.v2.metadata.EntitiesDescriptorType; import org.picketlink.identity.federation.saml.v2.metadata.EntityDescriptorType; import org.picketlink.identity.federation.saml.v2.metadata.IDPSSODescriptorType; @@ -53,7 +56,7 @@ public class SAMLIdentityProviderFactory extends AbstractIdentityProviderFactory } @Override - public Map parseConfig(InputStream inputStream) { + public Map parseConfig(InputStream inputStream) { try { Object parsedObject = new SAMLParser().parse(inputStream); EntityDescriptorType entityType; @@ -76,11 +79,22 @@ public class SAMLIdentityProviderFactory extends AbstractIdentityProviderFactory if (idpDescriptor != null) { SAMLIdentityProviderConfig samlIdentityProviderConfig = new SAMLIdentityProviderConfig(); - - samlIdentityProviderConfig.setSingleSignOnServiceUrl(idpDescriptor.getSingleSignOnService().get(0).getLocation().toString()); + String singleSignOnServiceUrl = null; + boolean postBinding = false; + for (EndpointType endpoint : idpDescriptor.getSingleSignOnService()) { + if (endpoint.getBinding().toString().equals(JBossSAMLURIConstants.SAML_HTTP_POST_BINDING.get())) { + singleSignOnServiceUrl = endpoint.getLocation().toString(); + postBinding = true; + break; + } else if (endpoint.getBinding().toString().equals(JBossSAMLURIConstants.SAML_HTTP_REDIRECT_BINDING.get())){ + singleSignOnServiceUrl = endpoint.getLocation().toString(); + } + } + samlIdentityProviderConfig.setSingleSignOnServiceUrl(singleSignOnServiceUrl); samlIdentityProviderConfig.setWantAuthnRequestsSigned(idpDescriptor.isWantAuthnRequestsSigned()); samlIdentityProviderConfig.setValidateSignature(idpDescriptor.isWantAuthnRequestsSigned()); - samlIdentityProviderConfig.setPostBindingResponse(true); + samlIdentityProviderConfig.setPostBindingResponse(postBinding); + samlIdentityProviderConfig.setPostBindingAuthnRequest(postBinding); List keyDescriptor = idpDescriptor.getKeyDescriptor(); String defaultCertificate = null; diff --git a/distribution/modules/src/main/resources/modules/org/keycloak/keycloak-broker-saml/main/module.xml b/distribution/modules/src/main/resources/modules/org/keycloak/keycloak-broker-saml/main/module.xml index 646ab63642..d51fd74323 100755 --- a/distribution/modules/src/main/resources/modules/org/keycloak/keycloak-broker-saml/main/module.xml +++ b/distribution/modules/src/main/resources/modules/org/keycloak/keycloak-broker-saml/main/module.xml @@ -5,9 +5,14 @@ + + + + + diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/realm.js b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/realm.js index 8ca40a8702..42562dd285 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/realm.js +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/realm.js @@ -638,7 +638,7 @@ module.controller('RealmDefaultRolesCtrl', function ($scope, Realm, realm, appli }); -module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload, realm, instance, providerFactory, IdentityProvider, serverInfo, $location, Notifications) { +module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload, $http, realm, instance, providerFactory, IdentityProvider, serverInfo, $location, Notifications) { console.log('RealmIdentityProviderCtrl'); $scope.realm = angular.copy(realm); @@ -678,6 +678,7 @@ module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload $scope.files = []; $scope.importFile = false; + $scope.importUrl = false; $scope.onFileSelect = function($files) { $scope.importFile = true; @@ -685,6 +686,7 @@ module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload }; $scope.clearFileSelect = function() { + $scope.importUrl = false; $scope.importFile = false; $scope.files = null; } @@ -694,7 +696,7 @@ module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload for (var i = 0; i < $scope.files.length; i++) { var $file = $scope.files[i]; $scope.upload = $upload.upload({ - url: authUrl + '/admin/realms/' + realm.realm + '/identity-provider/', + url: authUrl + '/admin/realms/' + realm.realm + '/identity-provider/import', // method: POST or PUT, // headers: {'headerKey': 'headerValue'}, withCredential: true, data: $scope.identityProvider, @@ -714,6 +716,24 @@ module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload } }; + $scope.importFrom = function() { + $scope.identityProvider.fromUrl = $scope.fromUrl; + $http.post(authUrl + '/admin/realms/' + realm.realm + '/identity-provider/import', $scope.identityProvider) + .success(function(data, status, headers) { + $location.url("/realms/" + realm.realm + "/identity-provider-settings"); + Notifications.success("The " + $scope.identityProvider.name + " provider has been created."); + }).error(function() { + Notifications.error("The provider can not be imported. Please verify the url."); + }); + }; + $scope.$watch('fromUrl', function(newVal, oldVal){ + if ($scope.fromUrl && $scope.fromUrl.length > 0) { + $scope.importUrl = true; + } else{ + $scope.importUrl = false; + } + }); + $scope.$watch('configuredProviders', function(configuredProviders) { if (configuredProviders) { $scope.configuredProviders = angular.copy(configuredProviders); diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/services.js b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/services.js index 763838331a..4b53346c25 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/services.js +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/services.js @@ -1102,7 +1102,7 @@ module.factory('PasswordPolicy', function() { }); module.factory('IdentityProvider', function($resource) { - return $resource(authUrl + '/admin/realms/:realm/identity-provider/:id', { + return $resource(authUrl + '/admin/realms/:realm/identity-provider/instances/:id', { realm : '@realm' }, { create : { @@ -1118,7 +1118,7 @@ module.factory('IdentityProvider', function($resource) { }); module.factory('IdentityProviderExport', function($resource) { - var url = authUrl + '/admin/realms/:realm/identity-provider/:id/export'; + var url = authUrl + '/admin/realms/:realm/identity-provider/instances/:id/export'; return { url : function(parameters) { diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-identity-provider-saml.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-identity-provider-saml.html index dbe80fdb25..576f3d3c88 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-identity-provider-saml.html +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-identity-provider-saml.html @@ -25,8 +25,15 @@ -
- +
+ +
+ +
+ +
+
+
Icon: UploadChoose a File... @@ -37,14 +44,14 @@
-
+
-
+