mehr-als-nix/zf2-saml

SAML Authentication module for ZF-2.

dev-develop 2016-10-15 13:40 UTC

This package is auto-updated.

Last update: 2020-07-30 01:08:22 UTC


README

SAML authentication module for ZF2.

Build Status

This module uses onelogin/php-saml internally and wrap the function in services.

Installation

Just require mehr-als-nix/zf-saml in your composer.json.

Enable it in application.config.php

    'modules' => array (
        // ---8<---
        'ZF\ApiProblem',
        'ZF\ContentNegotiation',
        'MehrAlsNix\ZF\SAML',
        // --->8---
    ),

Configuration

Copy saml.local.php.dist to config/autoload/saml.local.php

Services

MehrAlsNix\ZF\SAML\Service\SAML2Auth

Provides an instance of OneLogin_Saml2_Auth

MehrAlsNix\ZF\SAML\Service\SAML2AuthnRequest

Provides an instance of OneLogin_Saml2_AuthnRequest

MehrAlsNix\ZF\SAML\Service\SAML2Metadata

Provides an instance of OneLogin_Saml2_Metadata

MehrAlsNix\ZF\SAML\Service\SAML2Response

Provides an instance of OneLogin_Saml2_Response

MehrAlsNix\ZF\SAML\Service\SAML2Settings

Provides an instance of OneLogin_Saml2_Settings

API protection

Assume $this->samlAuth contains an instance of OneLogin_Saml2_Auth, then you would be able to protect your API.

    if (!$this->samlAuth->isAuthenticated()) {
        $this->getResponse()->setStatusCode(401);
        return;
    }