Installations/- och konfigurationsguide SIMPLESAML och SAMLAssertionService

Sambi

1.       Installation SIMPLESAML

För installation av SimpleSAML och Apache httpd följ guiden för SkolFederationen:

https://fedwiki.atlassian.net/wiki/spaces/SKOL/pages/1605859/1.+SimpleSAMLphp+installation


2.       Konfiguration

eHälsomyndigheten har valt att använda en statisk username/password-validering för att skapa olika typer av SAML-intyg.

2.1       Konfiguration en Identity Provider

För guiden för skolfederationen: https://fedwiki.atlassian.net/wiki/spaces/SKOL/pages/2326540/1.1.+SimpleSAMLphp+IdP

Gör därefter följande anpassningar:

2.1.1         Saml20-idp-hosted

För att modifiera den hostade IdP:n lägg till följande uppgifter i Er Idp. Editera fil metadata/saml20-idp-hosted.php

$metadata['__DYNAMIC:1__'] = array(
    'host' => '__DEFAULT__',
    'customIdp' => 'http://www.ehalsomyndigheten.se/idp',
    'auth' => 'example-userpass',
    'assertion.lifetime' => 3500,
    'privatekey' => 'server.key',
    'certificate' => ‘server.crt',
    'attributes.NameFormat' => 'urn:oasis:names:tc:SAML:2.0:attrname-format:uri',
    'authproc' => array(
        97 => array(
            'class' => 'saml:AuthnContextClassRef',
            'AuthnContextClassRef' => 'http://id.sambi.se/loa/loa3',
        ),
        100 => array(
            'class' => 'core:AttributeMap',
            'name2oid'
        ),
    ),
    'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient'
);

'assertion.lifetime' sätter giltighetstiden på saml-intyget.


CustomIdp skall endast användas om man som aktör vill installera en IdP på en annan URL och den som SIMPLESAML som default skapar. Se Kapitel 3.2


2.1.2        Saml20-idp-remote

För att modifiera remote IdP:n lägg till följande uppgifter i Er Idp. Editera fil metadata/saml20-idp-remote.php 

Om filen inte finns, skapa den genom att gå till https://localhost/simplesaml/saml2/idp/metadata.php?output=xhtml

Bild 1 Sambi.png

                                                                                             Figur 1 Saml20-idp-remote innehåll

Klistra in innehållet som i figuren ovan. OBS! Figuren är ett exempel.


2.2       Konfiguration av Service provider

2.2.1         Saml20-sp-remote

För att modifiera remote IdP:n lägg till följande uppgifter i er Idp. Editera fil metadata/saml20-sp-remote.php. 

Om filen inte finns skapa den genom att gå till https://localhost/simplesaml/module.php/saml/sp/metadata.php/default-sp?output=xhtml


Bild 2 Sambi.png

                                                                                  Figur 2 Saml20-sp-remote innehåll

Klistra in innehållet som i figuren ovan. OBS! Figuren är ett exempel.



2.3       Konfiguration av CustomIdp fält

I de fall man sätter upp en IdP och SP som man sedan vill ladda upp på Sambi-federationens testmiljö kan man bortse från denna ändring.

CustomIdp skall endast användas om man som aktör vill installera en IdP på en annan URL och den som SIMPLESAML som default skapar.

Editera filen /var/simplesamlphp/modules/saml/lib/IdP/SAML2.php 

Ändra raden

$a->setIssuer($idpMetadata->getString('entityid'));


till

$a->setIssuer($idpMetadata->getString('customIdp'));

 


2.4       Konfiguration av Authsources

Demon har valt att använda sig av user/password exempel som kommer med installationen av SimpleSAML.

Filen /var/simplesamlphp/config/authsources.php innehåller exempel på användare som eHälsomyndigheten lagt till. Dessa kommer att användas som roller.

De tillagda attributen är det som sedan kommer med en SAMLResponse.

<?php
$config = array(
    // This is a authentication source which handles admin authentication.
    'admin' => array(
        // The default is to use core:AdminPassword, but it can be replaced with
        // any authentication source.
        'core:AdminPassword',
    ),
    // 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://www.ehalsomyndigheten.se',
        // 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' => NULL,
        // The URL to the discovery service.
        // Can be NULL/unset, in which case a builtin discovery service will be used.
        'discoURL' => null,
        'certificate' => 'ehmsigneringscertifikat2.cer',
       
'privatekey' => 'ehmsigneringscertifikat2.key',
    ),
'example-userpass' => array(

    'exampleauth:UserPass',
    'FARMACEUT_APOTEK:sambi' => array(
        'http://sambi.se/attributes/1/healthcareProfessionalLicense' => array('AP'),
        'http://sambi.se/attributes/1/healthcareProfessionalLicenseIdentityNumber' => array('920003'),
                                                    'http://sambi.se/attributes/1/pharmacyIdentifier' => array('7350046611966')
    ),
    'FARMACEUT_APOTEK_PNR:sambi' => array(
        'http://sambi.se/attributes/1/pharmacyIdentifier' => array('7350046611966'),
        'http://sambi.se/attributes/1/personalIdentityNumber' => array('189110219806'),
                                                    'http://sambi.se/attributes/1/pharmacyIdentifier' => array('7350046611966')
    ),
    'PERSONAL_APOTEK:sambi' => array(
        'http://sambi.se/attributes/1/personalIdentityNumber' => array('199006012398'),
                                                    'http://sambi.se/attributes/1/occupationalCode' => array('RE'),
                                                    'http://sambi.se/attributes/1/pharmacyIdentifier' => array('7350046611966'),
    ),
    'LEGITIMERAD_PERSONAL:sambi' => array(
        'http://sambi.se/attributes/1/healthcareProfessionalLicense' => array('LK', 'BM'),
        'http://sambi.se/attributes/1/personalIdentityNumber' => array('199101282391'),
    ),
    'FORSKRIVARE:sambi' => array(
        'http://sambi.se/attributes/1/personalPrescriptionCode' => array('9000027'),
        'http://sambi.se/attributes/1/healthcareProfessionalLicense' => array('LK'),
    ),

    'SJUKSKOTERSKA:sambi' => array(
        'http://sambi.se/attributes/1/personalPrescriptionCode' => array('9001363'),
        'http://sambi.se/attributes/1/healthcareProfessionalLicense' => array('SJ'),
    ),

    'BARNMORSKA:sambi' => array(
        'http://sambi.se/attributes/1/personalPrescriptionCode' => array('9000019'),
        'http://sambi.se/attributes/1/healthcareProfessionalLicense' => array('BM'),
    ),
    'FORSKRIVARE_AT:sambi' => array(
        'http://sambi.se/attributes/1/groupPrescriptionCode' => array('9000001'),
        'http://sambi.se/attributes/1/personalIdentityNumber' => array('199104142394'),
        'http://sambi.se/attributes/1/occupationalCode' => array('AL'),
    ),
    'SJUKSKOTERSKA_GRUPPFORSKRIVARKOD:sambi' => array(
        'http://sambi.se/attributes/1/groupPrescriptionCode' => array('9600008'),
        'http://sambi.se/attributes/1/healthcareProfessionalLicenseIdentityNumber' => array('403900'),
        'http://sambi.se/attributes/1/healthcareProfessionalLicense' => array('SJ'),
    ),
    'LEG_VARDPERSONAL_SJUKSKOTERSKA:sambi' => array(
        'http://sambi.se/attributes/1/healthcareProfessionalLicenseIdentityNumber' => array('900226'),
        'http://sambi.se/attributes/1/healthcareProfessionalLicense' => array('SJ'),
    ),
                          'LEG_VARDPERSONAL_FARMACEUT:sambi' => array(
        'http://sambi.se/attributes/1/healthcareProfessionalLicenseIdentityNumber' => array('900226'),
        'http://sambi.se/attributes/1/healthcareProfessionalLicense' => array('AP'),
        'http://sambi.se/attributes/1/healthcareProviderId' => array('123456789'),
        'http://sambi.se/attributes/1/healthCareProviderHsaId' => array('HSA123456789'),
    ),
    'EJ_LEGITIMERAD_VARDPERSONAL:sambi' => array(
        'http://sambi.se/attributes/1/personalIdentityNumber' => array('199101282391'),
        'http://sambi.se/attributes/1/occupationalCode' => array('VP'),
    ),
    'ADMIN_DOSPATIENTUPPGIFTER:sambi' => array(
        'http://sambi.se/attributes/1/personalIdentityNumber' => array('199101282391'),
        'http://sambi.se/attributes/1/occupationalCode' => array('AD'),
    ),
),
);




2.5       Konfiguration av Federation

För guide till skolfederationen: https://fedwiki.atlassian.net/wiki/spaces/SKOL/pages/2326545/1.3.+Manage+the+Federation+Metadata

Använd SAMBI trial metadatafil istället för SkolFederationens metadata.

Ändra i filen config/config-metarefresh.php.

Följande uppgifter finns på Sambis hemsida https://www.sambi.se/teknik/:

Vad federationsfunktionen kommer att göra är att skapa två filer; federation/saml20-idp-remote.php och federation/saml20-sp-remote.php baserat på metadatafilen.


2.5.1         Metadata till federationsoperatören SAMBI

För att kunna skicka en aktörs metadata till federationsoperatören SAMBI behövs inget medlemskap men en anmälan krävs. 

Mer information finns att läsa på SAMBI:s hemsida https://www.sambi.se/teknik/metadata/lamna-nytt-metadata.

 

3.       SAMLAssertionService

3.1       Start av SamlAssertionService

Kör kommando för att starta tjänsten.

java -jar SamlAssertionService-1.0.0.jar


SAMLAssertionService är en Spring Boot applikation. Det applikationen gör är att ansluta sig emot IdP:n och authentiserar sig. 

Efterföljande steg är att extrahera ut en SAML Assertion ifrån en SAML Response.


Bild 3 Sambi.png
                                                                               Figur 3


I applikationen finns även enhetstester som ansluter mot eHälsomyndighetens Service Provider. Applikationen konsumerar eHälsomyndighetens referens applikation.

Anslutning mot SamlAssertionService görs till exempel genom att köra direkt ifrån en browser.

http://localhost:8080/getSamlAssertion?idp=https://localhost/simplesaml/saml2/idp/SSOService.php?spentityid=http%3A%2F%2Fwww.ehalsomyndigheten.se&loginUrl=https://localhost/simplesaml/module.php/core/loginuserpass.php&username=FARMACEUT_APOTEK&password=sambi


3.2       Användning av enhetstester/exempel

SamlAssertionService har inbyggda testfall som anropar egen Spring Boot server för att hämta SAML Assertion. 

SAML Assertion skickas in som en SoapHeader till eHälsomyndigheten Service Provider för validering.



​Version ​Datum ​Kommentar
1.0​ ​2019-02-08 ​​Ny