Installations/- och konfigurationsguide SIMPLESAML och SAMLAssertionService

e-legitimation (till exempel mobilt BankId)


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__',
    'auth' => 'example-userpass',
    'assertion.lifetime' => 3500,
    'privatekey' => 'bankid.key',
    'certificate' => ‘bankid.crt',
    'attributes.NameFormat' => 'urn:oasis:names:tc:SAML:2.0:attrname-format:uri',
    'authproc' => array(
        97 => array(
            'class' => 'saml:AuthnContextClassRef',
            'AuthnContextClassRef' => 'urn:oasis:names:tc:SAML:2.0:ac:classes:SoftwarePKI',
        ),
        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.


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 e-leg.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 den 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å på https://localhost/simplesaml/module.php/saml/sp/metadata.php/default-sp?output=xhtml

Bild 2 e-leg.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 Authsources

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

Filen /var/simplesamlphp/config/authsources.php innehåller exempel på användare som eHälsomyndigheten lagt till som 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' => bankid.cer',
       
'privatekey' => bankid.key',
        'signature.algorithm' => 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256',
    ),

'example-userpass' => array(

    'exampleauth:UserPass',

    'PRIVATPERSON:bankid' => array(

        'Subject_SerialNumber' => array('199307122383')

    ),

),

);




2.4       Publika certifikatet

Det publika certifikatet skickas till eHälsomyndigheten, eHälsomyndigheten lagrar certifikatet i sin lista över giltiga BankId.


3.       SAMLAssertionService

3.1       Start av SamlAssertionService

Kör kommando för att starta igång 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 e-leg.png

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

Man ansluter sig emot SamlAssertionService  genom att till exempel köra direkt ifrån en browser.

http://localhost:8080/getSamlResponse?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=PRIVATPERSON&password=bankid


3.2       Användning av enhetstester/exempel

SamlAssertionService har inbyggda testfall som anropar en 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