2017 © Pedro Peláez
 

library micro-auth

Authentication implementation including support for LDAP and OpenID-connet

image

gyselroth/micro-auth

Authentication implementation including support for LDAP and OpenID-connet

  • Tuesday, June 19, 2018
  • by raffis
  • Repository
  • 2 Watchers
  • 0 Stars
  • 837 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 18 % Grown

The README.md

Lightweight authentication library

Build Status Scrutinizer Code Quality Latest Stable Version GitHub release GitHub license, (*1)

Description

This is a lightweight authentication library. It is adapter based and comes with support for LDAP and OpenID-connect. It can handle multiple adapter of the same or different types. This library contains no storage mechanism. If you wish to store the authentication you need to store the identity object in your sessesion storage., (*2)

Requirements

The library is only >= PHP7.1 compatible., (*3)

Download

The package is available at packagist: https://packagist.org/packages/gyselroth/micro-auth, (*4)

To install the package via composer execute:, (*5)

composer require gyselroth/micro-auth

Documentation

Simple example usage

Create authentication instance and inject an LDAP and OpenID-connect adapter:, (*6)

use Micro\Auth;

$logger = new \My\Psr\Logger()
$auth = new Auth\Auth(\Psr\Log\LoggerInterface $logger);
$auth->injectAdapter(new Auth\Adapter\Basic\Ldap(new Auth\Ldap([
    'uri' => 'ldap://myldap.local:398',
    'binddn' => 'cn=admin,dc=test,dc=com',
    'bindpw' => '1234',
    'basedn' => 'dc=test,dc=com',
    'tls' => true
]), $logger, [
    'account_filter' => '(&(objectClass=posixAccount)(uid=%s))'
]), 'my_ldap_server');

$auth->injectAdapter(new Auth\Adapter\Oidc([
    'provider_url' => 'https://accounts.google.com',
    'identity_attribute' => 'email'
], $logger), 'google_oidc_server');

if($auth->requireOne()) {
    $identity = $auth->getIdentity();
    printf('Hello %s', $identity->getIdentifier());
} else {
    //Authentication failed
}

Define attribute map

So far so good but usually just authenticate is not enaugh, mostly you like to request user attributes of a given identity. Let us create an attribute map for our ldap server my_ldap_server., (*7)

use Micro\Auth;

$auth->injectAdapter(new Auth\Adapter\Basic\Ldap(new Auth\Ldap([
    'uri' => 'ldap://myldap.local:398',
    'binddn' => 'cn=admin,dc=test,dc=com',
    'bindpw' => '1234',
    'basedn' => 'dc=test,dc=com',
    'tls' => true
]), $logger, [
    'account_filter' => '(&(objectClass=posixAccount)(uid=%s))',
    'attribute_map' => [
        'firstname' => [
            'attr' => 'firstname',
            'type' => 'string',
        ],
        'lastname' => [
            'attr' => 'surname',
            'type' => 'string',
        ],
        'mail' => [
            'attr' => 'mail',
            'type' => 'string'
        ]
    ]
]), 'my_ldap_server');

if($auth->requireOne()) {
    $attributes = $auth->getIdentity()->getAttributes();
    var_dump($attributes);
} else {
    //Authentication failed
}

Given that, you can define an attribute map for each authentication adapter and map all attributes to the same attribute names you would like to use., (*8)

The Versions

19/06 2018

dev-dev

dev-dev http://www.github.com/gyselroth/micro-auth

Authentication implementation including support for LDAP and OpenID-connet

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raffael Sahli

micro ldap openid-connect http-basic

15/06 2018

dev-master

9999999-dev http://www.github.com/gyselroth/micro-auth

Authentication implementation including support for LDAP and OpenID-connet

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raffael Sahli

micro ldap openid-connect http-basic

15/06 2018

v0.0.6

0.0.6.0 http://www.github.com/gyselroth/micro-auth

Authentication implementation including support for LDAP and OpenID-connet

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raffael Sahli

micro ldap openid-connect http-basic

21/03 2018

v0.0.5

0.0.5.0 http://www.github.com/gyselroth/micro-auth

Authentication implementation including support for LDAP and OpenID-connet

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raffael Sahli

micro ldap openid-connect http-basic

03/02 2018

v0.0.4

0.0.4.0 http://www.github.com/gyselroth/micro-auth

Authentication implementation including support for LDAP and OpenID-connet

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raffael Sahli

micro ldap openid-connect http-basic

18/01 2018

v0.0.3

0.0.3.0 http://www.github.com/gyselroth/micro-auth

Authentication implementation including support for LDAP and OpenID-connet

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raffael Sahli

micro ldap openid-connect http-basic

18/01 2018

v0.0.2

0.0.2.0 http://www.github.com/gyselroth/micro-auth

Authentication implementation including support for LDAP and OpenID-connet

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raffael Sahli

micro ldap openid-connect http-basic

21/11 2017

v0.0.1

0.0.1.0 http://www.github.com/gyselroth/micro-auth

Authentication implementation including support for LDAP and OpenID-connet

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raffael Sahli

micro ldap openid-connect http-basic