Le blog technique

Toutes les astuces #tech des collaborateurs de PI Services.

#openblogPI

Retrouvez les articles à la une

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:

<pre class="wp-block-syntaxhighlighter-code"><?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>MIIEFTCCAv2gAwIBAgIJALEBPyeEV48BMA0GCSqGSIb3DQEBCwUAMIGgMQswCQYDVQQGEwJGUjEMMAoGA1UECAwDSURGMQ4wDAYDVQQHDAVQQVJJUzEUMBIGA1UECgwLQVBQTElDQVRJT04xGzAZBgNVBAsMEkFQUExJQ0FUSU9OI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1amxojPYjrH5ZFZmxS+tT5Z33+PU+FMwYw5YzmSAV84QfotZamcIc95A7FUNP2VEQjkX3nx6zuY+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></pre>

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,

 

Changement d’UPN en mode hybride directement dans O365

Dans un environnement hybride, avec des utilisateurs synchronisés depuis l’Active Directory vers O365, il n’est actuellement pas possible de changer l’UPN directement par le portail d’administration O365.

Cependant avec les commandes Powershell suivante, il est possible de modifier l’UPN directement dans O365:

Set-MsolUserPrincipalName -UserPrincipalName first.lastname@contoso.fr -NewUserPrincipalName first.lastname@contoso.onmicrosoft.com

 

Set-MsolUserPrincipalName -UserPrincipalName first.lastname@contoso.onmicrosoft.com -NewUserPrincipalName first.lastname@contoso.com

 

Il faut passer par l’adresse technique pour changer l’UPN de l’utilisateur d’un domaine à un autre, il faut cependant que l’UPN final soit égal à la valeur présente dans l’Active Directory Onpremise.

Sécurité : Windows KB pour Wanna Cry

 

Suite à l’attaque du virus Wanna Cry, tout le monde a souhaité corriger la faille de sécurité au plus vite.

Avec tout ce qu’on a pu lire ou trouver sur internet on ne sait plus vraiment qui fait quoi et si nous sommes réellement protégé.

Liste des KB de Sécurité

Voici la liste des KB de sécurité couvrants la faille (pour information les KB se remplacent d’un mois à l’autre : exemple la KB du mois d’avril remplace celle de Mars):

  1. Pour Windows XP, Vista, 8, Windows Server 2003 et 2008 : 
    1. Mars 2017
      1. KB4012598
  2. Pour Windows 7 SP1 et Windows Server 2008 R2 SP1:
    1. Mars 2017
      1. Security only update : KB4012212
      2. Monthly Rollup : KB4012215
      3. Preview of Monthly Rollup : KB4012218
    2. Avril 2017
      1. Security only update : KB4015546
      2. Monthly Rollup : KB4015549
      3. Preview of Monthly Rollup : KB4015552
    3. Mai 2017
      1. Security only update : KB4019263
      2. Monthly Rollup : KB4019264
      3. Preview of Monthly Rollup : KB4019265
  3. Pour Windows Server 2012 :
    1. Mars 2017
      1. Security only update : KB4012214
      2. Monthly Rollup : KB4012217
      3. Preview of Monthly Rollup : KB4012220
    2. Avril 2017
      1. Security only update : KB4015548
      2. Monthly Rollup : KB4015551
      3. Preview of Monthly Rollup : KB4015554
    3. Mai 2017
      1. Security only update : KB4019214
      2. Monthly Rollup : KB4019216
      3. Preview of Monthly Rollup : KB4019218
  4. Pour Windows 8.1 et Windows 2012 R2 :
    1. Mars 2017
      1. Security only update : KB4012213
      2. Monthly Rollup : KB4012216
      3. Preview of Monthly Rollup : KB4012219
    2. Avril 2017
      1. Security only update : KB4015547
      2. Monthly Rollup : KB4015550
      3. Preview of Monthly Rollup : KB4015553
    3. Mai 2017
      1. Security only update : KB4019213
      2. Monthly Rollup : KB4019215
      3. Preview of Monthly Rollup : KB4019217
  5. Pour Windows 10 (Release 1511) :
    1. Mars 2017
      1. KB4013198
      2. KB4016636
    2. Avril 2017
      1. KB4015219
    3. Mai 2017
      1. KB4019473
  6. Pour Windows 10 (Release 1607) :
    1. Mars 2017 
      1. KB4013429
      2. KB4015438
      3. KB4016635
    2. Avril 2017
      1. KB4015217
    3. Mai 2017
      1. KB4019472
      2. KB4023680
  7. Pour Windows 10 LTSB : 
    1. Mars 2017 
      1. KB4012606
      2. KB4016637
    2. Avril 2017
      1. KB4015221
    3. Mai 2017
      1. KB4019474

En espérant que cela pourra vous servir.

Pour télécharger les KB : http://www.catalog.update.microsoft.com/home.aspx