Skip to content

Commit

Permalink
CLOUDSTACK-8457: SAML auth plugin improvements for production usage
Browse files Browse the repository at this point in the history
* Move config options to SAML plugin
  This moves all configuration options from Config.java to SAML auth manager. This
  allows us to use the config framework.
* Make SAML2UserAuthenticator validate SAML token in httprequest
* Make logout API use ConfigKeys defined in saml auth manager
* Before doing SAML auth, cleanup local states and cookies
* Fix configurations in 4.5.1 to 4.5.2 upgrade path
* Fail if idp has no sso URL defined
* Add a default set of SAML SP cert for testing purposes
  Now to enable and use saml, one needs to do a deploydb-saml after doing a deploydb
* UI remembers login selections, IDP server

- CLOUDSTACK-8458:
    * On UI show dropdown list of discovered IdPs
    * Support SAML Federation, where there may be more than one IdP
        - New datastructure to hold metadata of SP or IdP
        - Recursive processing of IdP metadata
        - Fix login/logout APIs to get new interface and metadata data structure
        - Add org/contact information to metadata
        - Add new API: listIdps that returns list of all discovered IdPs
        - Refactor and cleanup code and tests

- CLOUDSTACK-8459:
    * Add HTTP-POST binding to SP metadata
    * Authn requests must use either HTTP POST/Artifact binding

- CLOUDSTACK-8461:
    * Use unspecified x509 cert as a fallback encryption/signing key
      In case a IDP's metadata does not clearly say if their certificates need to be
      used as signing or encryption and we don't find that, fallback to use the
      unspecified key itself.

- CLOUDSTACK-8462:
    * SAML Auth plugin should not do authorization
      This removes logic to create user if they don't exist. This strictly now
      assumes that users have been already created/imported/authorized by admins.
      As per SAML v2.0 spec section 4.1.2, the SP provider should create authn requests using
      either HTTP POST or HTTP Artifact binding to transfer the message through a
      user agent (browser in our case). The use of HTTP Redirect was one of the reasons
      why this plugin failed to work for some IdP servers that enforce this.
    * Add new User Source
      By reusing the source field, we can find if a user has been SAML enabled or not.
      The limitation is that, once say a user is imported by LDAP and then SAML
      enabled - they won't be able to use LDAP for authentication
    * UI should allow users to pass in domain they want to log into, though it is
      optional and needed only when a user has accounts across domains with same
      username and authorized IDP server
    * SAML users need to be authorized before they can authenticate
        - New column entity to track saml entity id for a user
        - Reusing source column to check if user is saml enabled or not
        - Add new source types, saml2 and saml2disabled
        - New table saml_token to solve the issue of multiple users across domains and
          to enforce security by tracking authn token and checking the samlresponse for
          the tokens
        - Implement API: authorizeSamlSso to enable/disable saml authentication for a
          user
        - Stubs to implement saml token flushing/expiry

- CLOUDSTACK-8463:
    * Use username attribute specified in global setting
      Use username attribute defined by admin from a global setting
      In case of encrypted assertion/attributes:
      - Decrypt them
      - Check signature if provided to check authenticity of message using IdP's
        public key and SP's private key
      - Loop through attributes to find the username

- CLOUDSTACK-8538:
    * Add new global config for SAML request sig algorithm

- CLOUDSTACK-8539:
    * Add metadata refresh timer task and token expiring
        - Fix domain path and save it to saml_tokens
        - Expire hour old saml tokens
        - Refresh metadata based on timer task
        - Fix unit tests

This closes apache#489

(cherry picked from commit 20ce346)
Signed-off-by: Rohit Yadav <[email protected]>

Conflicts:
	client/WEB-INF/classes/resources/messages_hu.properties
	plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckHealthCommandWrapper.java
	plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java
	ui/scripts/ui-custom/login.js
  • Loading branch information
rohityadavcloud committed Jun 29, 2015
1 parent 527d6ee commit 107595a
Show file tree
Hide file tree
Showing 54 changed files with 2,152 additions and 546 deletions.
7 changes: 6 additions & 1 deletion api/src/com/cloud/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public interface User extends OwnedBy, InternalIdentity {

public enum Source {
LDAP, UNKNOWN
LDAP, SAML2, SAML2DISABLED, UNKNOWN
}

public static final long UID_SYSTEM = 1;
Expand Down Expand Up @@ -84,4 +84,9 @@ public enum Source {

public Source getSource();

void setSource(Source source);

public String getExternalEntity();

public void setExternalEntity(String entity);
}
4 changes: 4 additions & 0 deletions api/src/com/cloud/user/UserAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,8 @@ public interface UserAccount extends InternalIdentity {
int getLoginAttempts();

public User.Source getSource();

public String getExternalEntity();

public void setExternalEntity(String entity);
}
3 changes: 2 additions & 1 deletion api/src/org/apache/cloudstack/api/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ public class ApiConstants {
public static final String ISOLATION_METHODS = "isolationmethods";
public static final String PHYSICAL_NETWORK_ID = "physicalnetworkid";
public static final String DEST_PHYSICAL_NETWORK_ID = "destinationphysicalnetworkid";
public static final String ENABLE = "enable";
public static final String ENABLED = "enabled";
public static final String SERVICE_NAME = "servicename";
public static final String DHCP_RANGE = "dhcprange";
Expand Down Expand Up @@ -518,7 +519,7 @@ public class ApiConstants {
public static final String VMPROFILE_ID = "vmprofileid";
public static final String VMGROUP_ID = "vmgroupid";
public static final String CS_URL = "csurl";
public static final String IDP_URL = "idpurl";
public static final String IDP_ID = "idpid";
public static final String SCALEUP_POLICY_IDS = "scaleuppolicyids";
public static final String SCALEDOWN_POLICY_IDS = "scaledownpolicyids";
public static final String SCALEUP_POLICIES = "scaleuppolicies";
Expand Down
5 changes: 4 additions & 1 deletion client/WEB-INF/classes/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ label.action.attach.iso=Attach ISO
label.action.cancel.maintenance.mode.processing=Cancelling Maintenance Mode....
label.action.cancel.maintenance.mode=Cancel Maintenance Mode
label.action.change.password=Change Password
label.action.configure.samlauthorization=Configure SAML SSO Authorization
label.action.change.service.processing=Changing Service....
label.action.change.service=Change Service
label.action.copy.ISO.processing=Copying ISO....
Expand Down Expand Up @@ -763,7 +764,9 @@ label.local.storage=Local Storage
label.local=Local
label.login=Login
label.logout=Logout
label.saml.login=SAML Login
label.saml.enable=Authorize SAML SSO
label.saml.entity=Identity Provider
label.add.LDAP.account=Add LDAP Account
label.LUN.number=LUN \#
label.lun=LUN
label.make.project.owner=Make account project owner
Expand Down
1 change: 0 additions & 1 deletion client/WEB-INF/classes/resources/messages_fr_FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,6 @@ label.s3.nfs.server=Serveur NFS S3
label.s3.secret_key=Cl\u00e9 Priv\u00e9e
label.s3.socket_timeout=D\u00e9lai d\\'expiration de la socket
label.s3.use_https=Utiliser HTTPS
label.saml.login=Identifiant SAML
label.saturday=Samedi
label.save.and.continue=Enregistrer et continuer
label.save=Sauvegarder
Expand Down
1 change: 0 additions & 1 deletion client/WEB-INF/classes/resources/messages_hu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,6 @@ label.s3.nfs.server=S3 NFS kiszolg\u00e1l\u00f3
label.s3.secret_key=Titkos kulcs
label.s3.socket_timeout=Kapcsolat id\u0151t\u00fall\u00e9p\u00e9s
label.s3.use_https=HTTPS haszn\u00e1lata
label.saml.login=SAML bejelentkez\u00e9s
label.saturday=Szombat
label.save.and.continue=Ment\u00e9s \u00e9s folytat\u00e1s
label.save=Ment\u00e9s
Expand Down
3 changes: 3 additions & 0 deletions client/tomcatconf/commands.properties.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ logout=15
samlSso=15
samlSlo=15
getSPMetadata=15
listIdps=15
authorizeSamlSso=7
listSamlAuthorization=7

### Account commands
createAccount=7
Expand Down
5 changes: 0 additions & 5 deletions developer/developer-prefill.sql
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,4 @@ INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
VALUES ('Advanced', 'DEFAULT', 'management-server',
'developer', 'true');

-- Enable SAML plugin for developers by default
INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
VALUES ('Advanced', 'DEFAULT', 'management-server',
'saml2.enabled', 'true');

commit;
63 changes: 63 additions & 0 deletions developer/developer-saml.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing,
-- software distributed under the License is distributed on an
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-- KIND, either express or implied. See the License for the
-- specific language governing permissions and limitations
-- under the License.

-- SAML keystore for testing, allows testing on ssocirlce and other public IdPs
-- with pre-seeded SP metadata
USE cloud;

-- Enable SAML plugin for developers by default
INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
VALUES ('Advanced', 'DEFAULT', 'SAML2-PLUGIN',
'saml2.enabled', 'true')
ON DUPLICATE KEY UPDATE value=VALUES(value);

INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
VALUES ('Advanced', 'DEFAULT', 'SAML2-PLUGIN',
'saml2.default.idpid', 'https://idp.bhaisaab.org/idp/shibboleth')
ON DUPLICATE KEY UPDATE value=VALUES(value);

INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
VALUES ('Advanced', 'DEFAULT', 'SAML2-PLUGIN',
'saml2.idp.metadata.url', 'http://idp.bhaisaab.org/idp/shibboleth')
ON DUPLICATE KEY UPDATE value=VALUES(value);

-- Enable LDAP source
INSERT INTO `cloud`.`ldap_configuration` (hostname, port)
VALUES ('idp.bhaisaab.org', 389);

-- Fix ldap configs
INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
VALUES ('Advanced', 'DEFAULT', 'management-server',
'ldap.basedn', 'ou=people,dc=idp,dc=bhaisaab,dc=org')
ON DUPLICATE KEY UPDATE value=VALUES(value);

INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
VALUES ('Advanced', 'DEFAULT', 'management-server',
'ldap.bind.principal', 'cn=admin,dc=idp,dc=bhaisaab,dc=org')
ON DUPLICATE KEY UPDATE value=VALUES(value);

INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
VALUES ('Advanced', 'DEFAULT', 'management-server',
'ldap.bind.password', 'password')
ON DUPLICATE KEY UPDATE value=VALUES(value);

-- Add default set of certificates for testing
LOCK TABLES `keystore` WRITE;
/*!40000 ALTER TABLE `keystore` DISABLE KEYS */;
INSERT INTO `keystore` VALUES (1,'SAMLSP_KEYPAIR','MIIJRAIBADANBgkqhkiG9w0BAQEFAASCCS4wggkqAgEAAoICAQDQDirtAajTrScXCUgXrsOBgQ++y+IUcyzXwUGEYBlM9kBCmcdlbt5zuYQ8pOvoOQz6CAVqSjYNbnbg1ph37Zfv/tzGUg2V5cpB5BfEyt2KY0mBFNbwa0LKnCAYlBlarm4XZF+oZ0maH6cdboHdHiEqNRscylnXYA2zHKU3YoEfOR+9acl4z54PAyuPjr9SWUPTAyYf326i0q+h3J4nT6FwBFK+yKSC1PeVG/viYQ0otU1UUDkQ3pX81qfJfN/6Ih7W4v73LgUlZsTBMzlu/kJzMuP5Wc5IkU6Mt+8EHMZeLnN0ZErkMk0DCQE14hG8W7S8/inUJpwJlmb5E634Zq8u0I1zVUmSmAGqvvqKJBGnqY5X/j2bsA8B2qFsrcxasIlkKaWLvY+AvXD5X0OHwIZzRbuuCtguSz671C7Cwok8R3N+e9ATDHmG9gC10NJaB6dUBA9p2UdA82TR73x6nGe8pLJnGyecEQfxz1+ptPVAENj1Rl3Wrwu/dbPd/X6inlYpuwlsnWi3LYrkguT/9W3Z2uuq5PTVT04zcyev+50gVnDPzTrNCZfHpmMNQIqZGFmFKz4m+VUZmzZOdg1Vx51t9+t7iHGHqFk6/vnqqWiyEuTEFAaC9krm1VNzGvno5LyNm5Dk9JGAHFfjgNV++viGTpSPLeEeMnlvPuQJy5OJMwIDAQABAoICABME6Imn+C35izRA5fU8RaUGDlFrw+wIp1XF1d5rBoURkchE1ISCQRWlJOCCVwpwhK4qo4wW4qARtA5Tr7Zu4s/OpZH/mDxWuEmTt1SHEv9+mg6RwCBUPdPVt91nVHYEsg2zYEc9we2z7Qv0uSxkf7WjCypzmQjmP/paqQPKHnGjQDKJhCBmIlXO/WFvNDAr9tZIWGjbfPqndeS/DTocvm5GBuZn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4K94jAX3lsdg6zDaBiQWl7P3t50AKtP384Qsb/33uXcbTyw/TkzvPcbmsgTbEUTZIOv44CxMstFrUCyT7ptrzLvDk7Iy2cMgWghULgDvKT3esPE9pleyHG8bkjGt9ypDF/Lmp7j/kILYbF7eq1wIbHOSam4p8WyddVsW4nesu6fqLiCGXum9paChIfvL3To/VHFFKduhJd0Y7LMgWO7pXxWh7XfgRmzQaEN1eJmj5315HEYTS2wXWjptwYDrhiobKuCbpADfOQks8xNKJFLMnXp+IvAqz+ZjkNOz60MLuQ3hvKLTo6nQcTYTfZZxo3Aap30/hA2GtxxSXK/xpBDm58jcVoudgCdxML/OqERBfcADBLvIw5h9+DlXjPUg25IefU0oA336YtnzftJ6cfQfatrc0tBqNEeXdAAFWC41MDk=','','samlsp-x509cert',NULL);
/*!40000 ALTER TABLE `keystore` ENABLE KEYS */;
UNLOCK TABLES;
58 changes: 58 additions & 0 deletions developer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,64 @@
</plugins>
</build>
</profile>
<profile>
<!-- saml deploydb property -->
<id>deploydb-saml</id>
<activation>
<property>
<name>deploydb-saml</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${cs.mysql.version}</version>
</dependency>
</dependencies>
<version>1.2.1</version>
<executions>
<execution>
<phase>process-resources</phase>
<id>create-schema-simulator</id>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.cloud.upgrade.DatabaseCreator</mainClass>
<includePluginDependencies>true</includePluginDependencies>
<arguments>
<!-- db properties file -->
<argument>${basedir}/../utils/conf/db.properties</argument>
<argument>${basedir}/../utils/conf/db.properties.override</argument>
<!-- simulator sql files -->
<argument>${basedir}/developer-saml.sql</argument>
<!-- upgrade -->
<argument>com.cloud.upgrade.DatabaseUpgradeChecker</argument>
<argument>--rootpassword=${db.root.password}</argument>
</arguments>
<systemProperties>
<systemProperty>
<key>catalina.home</key>
<value>${basedir}/../utils</value>
</systemProperty>
<systemProperty>
<key>paths.script</key>
<value>${basedir}/target/db</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- simulator deploydb property -->
<id>deploydb-simulator</id>
Expand Down
11 changes: 11 additions & 0 deletions engine/schema/src/com/cloud/user/UserAccountVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ public class UserAccountVO implements UserAccount, InternalIdentity {
@Enumerated(value = EnumType.STRING)
private User.Source source;

@Column(name = "external_entity", length = 65535)
private String externalEntity = null;

public UserAccountVO() {
}

Expand Down Expand Up @@ -296,4 +299,12 @@ public User.Source getSource() {
public void setSource(User.Source source) {
this.source = source;
}

public String getExternalEntity() {
return externalEntity;
}

public void setExternalEntity(String externalEntity) {
this.externalEntity = externalEntity;
}
}
10 changes: 10 additions & 0 deletions engine/schema/src/com/cloud/user/UserVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public class UserVO implements User, Identity, InternalIdentity {
@Enumerated(value = EnumType.STRING)
private Source source;

@Column(name = "external_entity", length = 65535)
private String externalEntity;

public UserVO() {
this.uuid = UUID.randomUUID().toString();
}
Expand Down Expand Up @@ -283,4 +286,11 @@ public void setSource(Source source) {
this.source = source;
}

public String getExternalEntity() {
return externalEntity;
}

public void setExternalEntity(String externalEntity) {
this.externalEntity = externalEntity;
}
}
4 changes: 4 additions & 0 deletions engine/schema/src/com/cloud/user/dao/UserAccountDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
import com.cloud.user.UserAccountVO;
import com.cloud.utils.db.GenericDao;

import java.util.List;

public interface UserAccountDao extends GenericDao<UserAccountVO, Long> {
List<UserAccountVO> getAllUsersByNameAndEntity(String username, String entity);

UserAccount getUserAccount(String username, Long domainId);

boolean validateUsernameInDomain(String username, Long domainId);
Expand Down
19 changes: 15 additions & 4 deletions engine/schema/src/com/cloud/user/dao/UserAccountDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
// under the License.
package com.cloud.user.dao;

import javax.ejb.Local;

import org.springframework.stereotype.Component;

import com.cloud.user.UserAccount;
import com.cloud.user.UserAccountVO;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import org.springframework.stereotype.Component;

import javax.ejb.Local;
import java.util.List;

@Component
@Local(value = {UserAccountDao.class})
Expand All @@ -38,6 +38,17 @@ public UserAccountDaoImpl() {
userAccountSearch.done();
}

@Override
public List<UserAccountVO> getAllUsersByNameAndEntity(String username, String entity) {
if (username == null) {
return null;
}
SearchCriteria<UserAccountVO> sc = createSearchCriteria();
sc.addAnd("username", SearchCriteria.Op.EQ, username);
sc.addAnd("externalEntity", SearchCriteria.Op.EQ, entity);
return listBy(sc);
}

@Override
public UserAccount getUserAccount(String username, Long domainId) {
if ((username == null) || (domainId == null)) {
Expand Down
5 changes: 5 additions & 0 deletions plugins/user-authenticators/saml2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,10 @@
<artifactId>cloud-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-framework-config</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@
<property name="name" value="SAML2Auth"/>
</bean>

<bean id="samlTokenDao" class="org.apache.cloudstack.saml.SAMLTokenDaoImpl">
</bean>

</beans>
Loading

0 comments on commit 107595a

Please sign in to comment.