Commit 576070b5 authored by Mario Hernandez's avatar Mario Hernandez 💬

Update Integrating_SimpleSAMLphp_with_ADFS_2012R2/Integrating_SimpleSAMLphp_with_ADFS_2012R2.md

parent 6064124b
......@@ -55,3 +55,102 @@ Note: Did you notice the pattern? We copied the data from the saml20-idp-remote
9. Paste the converted metadata at the bottom of the file then save it.
![Image4](/Integrating_SimpleSAMLphp_with_ADFS_2012R2/Integrating SimpleSAMLphp with ADFS 2012R2 - lewisroberts.com_html_9bca4f9ad3bcc559.png)
Create a service provider configuration in SimpleSAMLphp
-----------------------------------------------------------
1. Navigate to your SimpleSAMLphp installation folder on the IIS server and open the config folder.
![Image4](/Integrating_SimpleSAMLphp_with_ADFS_2012R2/Integrating SimpleSAMLphp with ADFS 2012R2 - lewisroberts.com_html_bc29ae2157b093ad.png)
2. Open authsources.php in your favourite text editor.
![Image4](/Integrating_SimpleSAMLphp_with_ADFS_2012R2/Integrating SimpleSAMLphp with ADFS 2012R2 - lewisroberts.com_html_1f3abe463a5168e3.png)
3. I’m not going to repeat much of what I wrote in the post preceding this one where I added a Service Provider for Azure AD. Here, we will create a service provider configuration that uses our ADFS server. There are some differences in the configuration between Azure AD and ADFS 2012R2. The name of your SP is your choice, mine is called transishun-sp.
```php
// An authentication source which can authenticate against both SAML 2.0
// and Shibboleth 1.3 IdPs. If you make any configuration changes, you will need
// to update the RPT at the IdP.
'transishun-sp' => array(
'saml:SP',
// The entity ID of this SP.
// Can be NULL/unset, in which case an entity ID is generated based on the metadata URL.
'entityID' => null,
// The entity ID of the IdP this should SP should contact.
// Can be NULL/unset, in which case the user will be shown a list of available IdPs.
'idp' => 'http://fs.transishun.co.uk/adfs/services/trust',
// The URL to the discovery service.
// Can be NULL/unset, in which case a builtin discovery service will be used.
'discoURL' => null,
// ADFS 2012R2 requires signing of the logout - the others are optional (may be overhead you don't want.)
'sign.logout' => TRUE,
'redirect.sign' => TRUE,
'assertion.encryption' => TRUE,
// We now need a certificate and key. The following command (executed on Linux usually)
// creates a self-signed cert and key, using SHA256, valid for 2 years.
// openssl req -x509 -nodes -sha256 -days 730 -newkey rsa:2048 -keyout my.key -out my.pem
'privatekey' => 'my.key',
'certificate' => 'my.pem',
// Enforce the use of SHA-256 by default.
'signature.algorithm' => 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'
),
```
4. Here is how the code looks inside my authsources.php file.
![Image4](/Integrating_SimpleSAMLphp_with_ADFS_2012R2/Integrating SimpleSAMLphp with ADFS 2012R2 - lewisroberts.com_html_2c0e0def3940b89f.png)
5. You will notice that the SP code defines that we must sign.logout, redirect.sign and assertion.encryption. All of these declarations mean we need a certificate and key to sign and encrypt these communications. We’ll create the certificate and key in the next section.
6. The final declaration enforces the use of SHA-256 which is best practice.
Creating a certificate and key file for signing and encryption
------------------------------------------------------------------
I mentioned in the requirements that you would need a Linux machine. Again, if you need one, just spin one up on Azure, I did.
![Image4](/Integrating_SimpleSAMLphp_with_ADFS_2012R2/Integrating SimpleSAMLphp with ADFS 2012R2 - lewisroberts.com_html_25cc946b8ec1e5da.png)
1. Log on to your Linux machine. Use Putty to log on via SSH.
![Image4](/Integrating_SimpleSAMLphp_with_ADFS_2012R2/Integrating SimpleSAMLphp with ADFS 2012R2 - lewisroberts.com_html_80081f6d78a1c40a.png)
2. Create a directory called cert and change in to it.
![Image4](/Integrating_SimpleSAMLphp_with_ADFS_2012R2/Integrating SimpleSAMLphp with ADFS 2012R2 - lewisroberts.com_html_305e52eeeabe70fe.png)
3. If you recall from the SP definition code at the end of previous section, I provided an example command for generating a two year certificate and key:
```sh
openssl req -x509 -nodes -sha256 -days 730 -newkey rsa:2048 -keyout my.key -out my.pem
```
I extrapolated this from the documentation on the SimpleSAMLphp website in section 1.1. If you’re using this in a production environment, generate a key and cert that will last. The SimpleSAMLphp documentation suggests 10 years.
4. Run the command to create the key and certificate. You will be asked a number of questions, answer these however you like, this cert and key is only used for signing and encrypting on the SP. My run through is shown below.
![Image4](/Integrating_SimpleSAMLphp_with_ADFS_2012R2/Integrating SimpleSAMLphp with ADFS 2012R2 - lewisroberts.com_html_440e7d63336464d6.png)
5. Now you need to download the my.key and my.pem files. There’s a number of ways but since they’re just text, I usually just cat them to screen and copy/paste from the Putty console in to a file on my local machine.
![Image4](/Integrating_SimpleSAMLphp_with_ADFS_2012R2/Integrating SimpleSAMLphp with ADFS 2012R2 - lewisroberts.com_html_d2955f66a71f804e.png)
6. NB: Don’t get too excited, this is an example key, I don’t use this one myself.
Navigate to the SimpleSAMLphp installation folder and create a folder called cert.
![Image4](/Integrating_SimpleSAMLphp_with_ADFS_2012R2/Integrating SimpleSAMLphp with ADFS 2012R2 - lewisroberts.com_html_a1865969e0eeb8c4.png)
7. Copy the my.key and my.pem files in to the cert folder. These are the two files that we declared when we created the Service Provider configuration in authsources.php. The cert folder is the default location for certs and keys in SimpleSAMLphp as mentioned in the documentation.
![Image4](/Integrating_SimpleSAMLphp_with_ADFS_2012R2/Integrating SimpleSAMLphp with ADFS 2012R2 - lewisroberts.com_html_23488ae1952b763f.png)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment