PI Services

Le blog des collaborateurs de PI Services

Authentification SSO avec l'ADFS et Apache 2.5 (installé sur un windows)

Sur mon blog précédent : https://blog.piservices.fr/post/2017/04/28/authentification-sso-avec-l-adfs-et-apache-2-5-installe-sur-un-linux , j'ai expliqué comment configurer un serveur apache installé sur un linux pour faire du SSO avec l'adfs en utilisant auth_mellon et lasso. Aujourd'hui nous allons voir la même chose mais sur un apache installé sur un Windows. 

Contexte

Apache ne communique pas nativement avec l'ADFS. Pour permettre à des applications web qui tournent sur apache de faire de l'authentification SSO, il faudrait installer SimpleSAMLphp qui contient tous les modules nécessaire pour faire du SAML.

Installation du simpleSAMLphp

1. Depuis le site télécharger la dernière version stable de SimpleSAMLphp. Décompression le fichier et déplacer les contenus dans le répertoire www du serveur apache.

2. Accèder au dossier www\simplesamlphp-1.14.11\www\index.php depuis votre navigateur et une page d'installation et de configuration de SimpleSAMLphp apparaîtra. 

Sélectionner >Configuration et vous verrez que par défaut le protocole SAML 2.0 - Idp est désactivé:

Pour l'activer aller dans le fichier \simplesamlphp-1.14.11\config\config.php et modifier le paramètre 'enable.saml20-idp' en true: 

/*
     * Enable
     *
     * Which functionality in SimpleSAMLphp do you want to enable. Normally you would enable only
     * one of the functionalities below, but in some cases you could run multiple functionalities.
     * In example when you are setting up a federation bridge.
     */
    'enable.saml20-idp' => true,
    'enable.shib13-idp' => false,
    'enable.adfs-idp' => false,
    'enable.wsfed-sp' => false,
    'enable.authmemcookie' => false,

Faire un refresh de la page:

Note: Dans notre cas l'idp est un ADFS donc pas besoin d'activer l'idp sur le serveur apache.

S'assurer que tous les prérequis nécessaires sont installés depuis la page configuration:

3. Créer le certificat SSL (auto-signé) pour le service provider (SP) avec openssl (assurez vous que openssl est installé)

openssl req -new -x509 -days 3652 -nodes -out saml.crt -keyout saml.pem

et entrer les fichiers *.crt et *.pem dans le fichier de configuration \simplesamlphp-1.14.11\config\authsources.php comme indiqué ci-dessous:

    // An authentication source which can authenticate against both SAML 2.0
    // and Shibboleth 1.3 IdPs.
    'default-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' => 'http://testapplication/',

        // 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' => 'https://fs.xxx-xxx.com/federationmetadata/2007-06/federationmetadata.xml',

        // The URL to the discovery service.
        // Can be NULL/unset, in which case a builtin discovery service will be used.
        'discoURL' => null,
		'privatekey' => 'saml.pem',
        'certificate' => 'saml.crt',
  • entityID = l'url de l'application web
  • idp = l'url ou le fichier metadata de l'identity provider (l'idp)
  • privatekey = le fcihier pem créé précédemment
  • certificate = le ficher crt créé précédemment

Génération du fichier service provider (SP) metadata.

Il faudra par la suite générer le fichier metadata du service provider (sp) et l'utiliser pour configuration la fédération ADFS.

Pour générer le fichier sp metadat aller dans sur la page Féderation et cliquer sur [Afficher les métadonnées] de SP SAML 2.0

Une page avec les métadonnées apparaîtra, sauvegarder les tous dans un fichier au format xml. Exemple d'un fichier de metadonnées généré par SimpleSAMLphp:

<?xml version="1.0"?>
<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" entityID="http://testapplication/">
  <md:SPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:1.1:protocol urn:oasis:names:tc:SAML:2.0:protocol">
    <md:KeyDescriptor use="signing">
      <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <ds:X509Data>
          <ds:X509Certificate>MIIEFTCCAv2gAwIBAgIJALEBPyeEV48BMA0GCSqGSIb3DQEBCwUAMIGgMQswCQYDVQQGEwJGUjEMMAoGA1UECAwDSURGMQ4wDAYDVQQHDAVQQVJJUzEUMBIGA1UECgwLQVBQTElDQVRJT04xGzAZBgNVBAsMEkFQUExJQ0FUSU9OIEdST1VQRTEVMBMGA1UEAwwMQVBQTElDQVRJT04xMSkwJwYJKoZIhvcNAQ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NP2VEQjkX3nx6zuY+RE8aZr6Ul2ORPJVrnajrcUooP8f6Rd70Fg2Eaq/gmK1bP6UOm4=</ds:X509Certificate>
        </ds:X509Data>
      </ds:KeyInfo>
    </md:KeyDescriptor>
    <md:KeyDescriptor use="encryption">
      <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <ds:X509Data>
          <ds:X509Certificate>MIIEFTCCAv2gAwIBAgIJALEBPyeEV48BMA0GCSqGSIb3DQEBCwUAMIGgMQswCQYDVQQGEwJGUjEMMAoGA1UECAwDSURGMQ4wDAYDVQQHDAVQQVJJUzEUMBIGA1UECgwLQVBQTElDQVRJT04xGzAZBgNVBAsMEkFQUExJQ0FUSU9OIEdST1VQRTEVMBMGA1UEAwwMQVBQTElDQVRJT04xMSkwJwYJKoZIhvcNAQkBFhptZXZlbi5rYXJ1cHBhbm5hbkBsaXZlLmNvbTAeFw0xNzAyMDgxMTI3MjJaFw0yNzAyMDgxMTI3MjJaMIGgMQswCQYDVQQGEwJGUjEMMAoGA1UECAwDSURGMQ4wDAYDVQQHDAVQQVJJUzEUMBIGA1UECgwLQVBQTElDQVRJT04xGzAZBgNVBAsMEkFQUExJQ0FUSU9OIEdST1VQRTEVMBMGA1UEAwwMQVBQTElDQVRJT04xMSkwJwYJKoZIhvcNAQkBFhptZXZlbi5rYXJ1cHBhbm5hbkBsaXZlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALjKwVm4GtahFeBZXataYQzIWIAqcenA4RjmyGaGnI64uttEXDea8qpY+FYYCG9QIJWksz9CBrmM81bCi63DvQMa/ufGhTR6x99I5XHXdzya2F0DZCG6VuruPzLFuxi7u3p/ViHzmFkdEW9Gv23+s/SNyXnO7w4+YHiazobTadH9OmioPxd9m9Llwiml0I7FeVkfcnmscNOezD0P89eWVKkRnOjH8yccp2skke1nbHAv7Kh37dt3tq8uE/QPxC9gWimgyuJdo8F49RL6b2vE5laAxKYUSCjY6bcMg2MXrTiJMKmnqj0POauS8r9jy7V26+6sGtjNajOerem2X7ShskkCAwEAAaNQME4wHQYDVR0OBBYEFNB6YexsAR7Hy1YRDN54MxBdId5YMB8GA1UdIwQYMBaAFNB6YexsAR7Hy1YRDN54MxBdId5YMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAAG1hkGrJcNCrhmacqKi6sOV05238ix0ynGhtZyHVmIZf2OmJIXj117Xk9SHcCk4pFx26yfHOH4vnqK579UL1ACg1bp21R1POO4GNnhXRQiPwOdhtCOprYt9vq1zP7+aIiU4v6gSDUAcWf7a6nin4dwcYfO0cHAly7TW75tJGQa88eT9/v4s7YIopm+8D/+8skB8HqbkJ7i5E6+iILdHXgKqj1amxojPYjrH5ZFZmxS+tT5Z33+PU+FMwYw5YzmSAV84QfotZamcIc95A7FUNP2VEQjkX3nx6zuY+RE8aZr6Ul2ORPJVrnajrcUooP8f6Rd70Fg2Eaq/gmK1bP6UOm4=</ds:X509Certificate>
        </ds:X509Data>
      </ds:KeyInfo>
    </md:KeyDescriptor>
    <md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="http://localhost/simplesaml/module.php/saml/sp/saml2-logout.php/default-sp"/>
    <md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="http://localhost/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp" index="0"/>
    <md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:1.0:profiles:browser-post" Location="http://localhost/simplesaml/module.php/saml/sp/saml1-acs.php/default-sp" index="1"/>
    <md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact" Location="http://localhost/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp" index="2"/>
    <md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:1.0:profiles:artifact-01" Location="http://localhost/simplesaml/module.php/saml/sp/saml1-acs.php/default-sp/artifact" index="3"/>
  </md:SPSSODescriptor>
</md:EntityDescriptor>

Maintenant il ne reste plus qu'à configuration l'ADFS avec le fichier métadonnées du SP et faire un test. Pour effectuer un test et voir si l'authentification fontionne bien , aller sur la page [Authentifcation] et sélectionner [Tester les sources d'authentification configurées]

Pour accéder à cette page , connecter vous en tant qu'administrateur. Le mot de passe du compte administration est configuration depuis le fichier www\simplesamlphp-1.14.11\config\config.php avec le paramètre 'auth.adminpassword'

/**
     * This password must be kept secret, and modified from the default value 123.
     * This password will give access to the installation page of SimpleSAMLphp with
     * metadata listing and diagnostics pages.
     * You can also put a hash here; run "bin/pwgen.php" to generate one.
     */
    'auth.adminpassword' => '1234',
    'admin.protectindexpage' => false,
    'admin.protectmetadata' => false,

 

Ajouter un commentaire

Loading