SAML Single Sign-On (SSO) for Drupal using SimpleSAML as IDP

SAML Single Sign-On (SSO) for Drupal using SimpleSAML as IDP

Drupal SAML SP Single Sign-On module gives the ability to enable SAML Single Sign-On for your Drupal sites. Our module is compatible with all the SAML compliant Identity providers. Here we will go through a step-by-step guide to configure SSO between Drupal site and SimpleSAMLphp by considering SimpleSAMLphp as IdP.

Follow the steps below to configure SimpleSAML as IdP

Step 1: Setup SimpleSAML as Identity Provider

miniorange img Configure SimpleSAML as IdP

  • In the miniOrange SAML Module, navigate to  Service Provider Metadata tab. Here, you can find the SP metadata such as SP Entity ID and ACS (AssertionConsumerService) URL which are required to configure the Identity Provider
  • drupal saml sp-service provider metadata
  • Enabling the Identity Provider functionality
    • The first that must be done is to enable the identity provider functionality. This is done by editing  config/config.php (You can find this file in your simplesaml installation directory). The option  enable.saml20-idp controls whether SAML 2.0 IdP support is enabled. Enable it by assigning  true to them
    • Example: ‘enable.saml20-idp’ => true
  • Configuring the authentication module:
    • The  exampleauth:UserPass authentication module is part of the exampleauth module. This module isn't enabled by default, so you will have to enable it. This is done by creating a file named enable (file name) in modules/exampleauth/.
      On unix, this can be done by running (from the SimpleSAMLphp installation directory):
    • The next step is to create an authentication source with this module. An authentication source is an authentication module with a specific configuration. Each authentication source has a name, which is used to refer to this specific configuration in the IdP configuration. Configuration for authentication sources can be found in config/authsources.php.
    • In this setup, this file should contain a single entry:
          <?php     $config = [     'example-userpass' => [     'exampleauth:UserPass',     'student:studentpass' => [     'uid' => ['student'],     'eduPersonAffiliation' => ['member', 'student'],     ],     'employee:employeepass' => [     'uid' => ['employee'],     'eduPersonAffiliation' => ['member', 'employee'],     ],     ],     ];
    • This configuration creates two users - student and employee, with the passwords studentpass and employeepass. The username and password are stored in the array index (student:studentpass for the student-user). The attributes for each user are configured in the array referenced by the index. So for the student user, these are:
      [ 'uid' => ['student'], 'eduPersonAffiliation' => ['member', 'student'], ],
    • The attributes will be returned by the IdP when the user logs on.
  • Creating a self-signed certificate :-
    The IdP needs a certificate to sign its SAML assertions with. Here is an example of an openssl-command which can be used to generate a new private key and the corresponding self-signed certificate. The private key and certificate go into the directory defined in the certdir setting (defaults to cert/)

    This key and certificate can be used to sign SAML messages: openssl req -newkey rsa:3072 -new -x509 -days 3652 -nodes -out example.org.crt -keyout example.org.pem The certificate above will be valid for 10 years.

    OR
    You can generate it by using any online Tools and add them in cert directory.
    The extension should be like:
        example.org.crt //(Public Key)    example.org.pem //(Private Key)
    Note:-
    SimpleSAMLphp will only work with RSA certificates. DSA certificates are not supported.
  • Configuring the IdP:-
    The SAML 2.0 IdP is configured by the metadata stored in metadata/saml20-idp-hosted.php. This is a minimal configuration:     <?php    $metadata['__DYNAMIC:1__'] = [    /*    * The hostname for this IdP. This makes it possible to run multiple    * IdPs from the same configuration. '__DEFAULT__' means that this one    * should be used by default.    */    'host' => '__DEFAULT__',        /*    * The private key and certificate to use when signing responses.     * These are stored in the cert-directory.    */    'privatekey' => 'example.org.pem',    'certificate' => 'example.org.crt',     /*     * The authentication source which should be used to authenticate the     * user. This must match one of the entries in config/authsources.php.     */    'auth' => '' Example:- 'example-userpass', // You can find this in Step Number 3    ];
  • Adding SPs to the IdP:-
    The identity provider you are configuring needs to know about the service providers you are going to connect to it. This is configured by metadata stored in metadata/saml20-sp-remote.php. This is a minimal example of a metadata/saml20-sp-remote.php metadata file for a SimpleSAMLphp SP:

    Replace example.com with your Drupal domain name.

        <?php        $metadata['https://example.com/plugins/authentication/miniorangesaml/'] = [         'AssertionConsumerService' => 'https://example.com/samlassertion',         'SingleLogoutService' => 'https://example.com/user/logout',        'NameIDFormat' => 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress',        'simplesaml.nameidattribute' => 'mail',        'simplesaml.attributes' => true,        'attributes' => array('mail', 'givenname', 'sn', 'memberOf'),        ];
    Note that the URI in the entityID and the URLs to the AssertionConsumerService and Single Logout Service endpoints change between different service providers. If you have the metadata of the remote SP as an XML file, you can use the built-in XML to SimpleSAMLphp metadata converter, which by default is available as /admin/metadata-converter.php  in your SimpleSAMLphp installation.

    • Here, you can also add user attributes you want to send from SimpleSAML to your Service Provider i.e Drupal.
    • Go to SimpleSAMLphp homepage of installation.
    • The URL of an installation can be e.g.: https://service.example.com/simplesaml/ where service.example.com has to be replaced by your SimpleSAMLphp path.
    • (Note: The installation page URL may differ depending on how SimpleSAML installation has been done)
    • Now go to Federation Tab and click on Show Metadata for SAML 2.0 IdP Metadata.
    • drupal saml sp-simple saml installation
    • You can get the IdP metadata from here which will be required to configure the plugin.

Step 2: Configuring Drupal as Service Provider (SP)

  • In miniOrange SAML plugin, go to Service Provider Setup Tab.
    • SimpleSAML, sso setup Manual Configuration :

      • Provide the required settings (i.e. IdP Entity ID or Issuer, Single Sign-On Service URL, X.509 Certificate) and save it.
      • Single Sign-On Service URL Identity Provider Sign-in URL from Identity Provider Info in your Simple SAML APP.
        IdP Entity ID or Issuer Issuer from Identity Provider Info in your Simple SAML App
        X.509 Certificate:Open the .cer certificate file in notepad and copy/paste the entire content of the file.

Miniorange Drupal SAML Single sign-on supports multiple known IDPs like ADFS, Azure AD, Salesforce, Shibboleth, Onelogin, Okta, SimpleSamlPhp, Google apps, Bitium, OpenAM, miniorange IDP, Centrify and many more.


Business Trial For Free

If you don't find what you are looking for, please contact us at drupalsupport@xecurify.com or call us at +1 978 658 9387.