Hello all,
Here are the steps for setting up SSO on the OPDK version of the developer portal. These steps have been adapted from @gkoli@apigee.com.
-
Download the latest version of the SimpleSAMLphp library from https://simplesamlphp.org/download.
-
Extract the archive to /opt/apigee/apigee-drupal/wwwroot/private/simplesamlphp
-
Create a symlink from /opt/apigee/apigee-drupal/wwwroot
- ln -s ./private/simplesamlphp/www ./simplesaml
-
Download and extract the https://www.drupal.org/project/simplesamlphp_auth module to /opt/apigee/apigee-drupal/wwwroot/sites/all/modules/contrib/simplesamlphp_auth
-
Download and extract the simplesaml_support custom module to /opt/apigee/apigee-drupal/wwwroot/sites/all/modules/custom/simplesaml_support
-
Create an alias in Nginx for simplesaml by adding the following snippet inside the Nginix template for the developer portal. Located at /opt/apigee/apigee-drupal-devportal/source/conf/apigee-drupal-devportal-nginx.conf
location ^~ /simplesaml { index index.php index.html index.htm; alias /opt/apigee/apigee-drupal/wwwroot/private/simplesamlphp/www; location ~ ^(?<prefix>/simplesaml)(?<phpfile>.+?\.php)(?<pathinfo>/.*)?$ { include /opt/nginx/conf/fastcgi_params; fastcgi_pass 127.0.0.1:8888; fastcgi_param SCRIPT_FILENAME $document_root$phpfile; fastcgi_param PATH_INFO $pathinfo if_not_empty; } } -
Indicate the installation directory for simplesaml by adding the following snippet inside the settings.php template for the developer portal. Located at /opt/apigee/apigee-drupal-devportal/source/conf/settings.php
if (php_sapi_name() == 'cli') { // Avoid drush and simplesamlphp conflicts. $conf['simplesamlphp_auth_activate'] = FALSE; } $conf['simplesamlphp_auth_installdir'] = '/opt/apigee/apigee-drupal/wwwroot/private/simplesamlphp'; -
Edit /opt/apigee/apigee-drupal/wwwroot/private/simplesamlphp/config/config.php.
- Add the following snippet to the top of the file.
include '/opt/apigee/apigee-drupal/wwwroot/sites/default/settings.php'; $host = $_SERVER['HTTP_HOST']; $db = $databases['default']['default']; -
Change the âauth.adminpasswordâ value to a different value.
-
Change the âbaseurlpathâ:
'baseurlpath' => 'https://' . $host . '/simplesaml/', -
Set the value of âtempdirâ to a directory where the simplesamlphp library can write temporary files to.
-
Set âstore.typeâ to sql.
-
Set the value of âstore.sql.dsnâ. NOTE: Youâll want to set the port youâve configured for PostgreSQL here:
'store.sql.dsn' => 'pgsql:host=' . $db['host'] . ';port=5432;dbname=' . $db['database'], -
Set the value of âstore.sql.usernameâ and âstore.sql.passwordâ:
'store.sql.username' => $db['username'], 'store.sql.password' => $db['password'], -
Edit /opt/apigee/apigee-drupal/wwwroot/private/simplesamlphp/config/authsources.php
- Set the value of the âentityIDâ which is the unique ID of the SP under default-sp, say for example set âentityIDâ => âdeveloper.client-portal.comâ, this should be something unique to your portal e.g. developer.apigee.com. This is the entity ID that you need to provide during SP definition in your SSO provider.
-
Restart the developer portal.
- /opt/apigee/apigee-service/bin/apigee-service apigee-drupal-devportal restart
-
Log into the developer portal with an administrative account and navigate to /admin/modules. Enable the simplesamlphp_auth and simplesamlphp_support modules.
-
Navigate to /admin/config/development/performance in the developer portal and click âClear all cachesâ.
-
Give the above entity ID and the metadata URL i.e. https://developer.client-portal.com/simplesaml/module.php/saml/sp/metadata.php/default-sp to the identity provider, ask for the identity provider metadata XML, the name of the attributes for email, first name, last name, user name and the unique identifier.
- Alternatively, navigate to /simplesaml in the developer portal and you will see the simplesamlphp libraryâs UI.
- Click the âFederationâ tab and click âShow metadataâ.
- Provide this to the identity provider.
-
Once you receive the metadata from the identity provider navigate to /simplesaml in the developer portal and you will see the simplesamlphp libraryâs UI.
-
Click on the âFederationâ tab and under the tools section click the âXML to simpleSAMLphp metadata converterâ link and paste the XML metadata from the IDP in the form. Then click parse.
-
This will convert the metadata from XML to a PHP array. It will also provide you the names of the files that need to be modified under /opt/apigee/apigee-drupal/wwwroot/private/simplesamlphp /metadata/ directory.
- If it says saml20-idp-remote on the top of the page, copy the metadata in PHP format and paste it in /opt/apigee/apigee-drupal/wwwroot/private/simplesamlphp/metadata/saml20-idp-remote.php
- There might be additional config files under the metadata folder that may need to be updated. Please confirm by scrolling through the metadata generator page.
- The key of the metadata array (e.g. $metadata[âhttps://openidp.feide.noâ]) in this case , âhttps://openidp.feide.no" is the entity ID of the identity provider.
- Copy the key and paste it as the value of âidpâ key in /opt/apigee/apigee-drupal/wwwroot/private/simplesamlphp/config/authsources.php under default-sp eg: âidpâ => âhttps://openidp.feide.noâ
-
Navigate to /admin/config/people/simplesamlphp_auth in the developer portal and configure the settings as follows:
- Check off âActivate authentication via SimpleSAMLphpâ.
- Verify the âInstallation Directoryâ is already correctly set to the simplesamlphp library directory.
- Set authentication source for this SP (default: default-sp) as default-sp.
- Select force https for login links if you have https enabled for your developer portal.
- Under User Info and Syncing enter the names of the respective attributes received from the identity provider.
- Under User provisioning Select âRegister Usersâ if you would like the users to be registered in the developer portal if the account does not exists.
- Under Drupal Authentication select the roles for whom you would like to give login access using Drupal Credentials. It is always good to allow administrator role to login using Drupal credentials.
-
The set up is complete and now you will have to test the setup.
-
Ensure you are logged out of the developer portal, navigate to /saml_login and you will be immediately redirected to the SSO login page of the IDP if everything was setup correctly.
-
Once you enter the login credentials and login you will be redirected back to the developer portal and will be logged in if everything worked fine.