2017 © Pedro Peláez
 

library openid-connect-php

Bare-bones OpenID Connect client

image

kdoyen/openid-connect-php

Bare-bones OpenID Connect client

  • Monday, August 14, 2017
  • by kdoyen
  • Repository
  • 1 Watchers
  • 2 Stars
  • 3,330 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 145 Forks
  • 3 Open issues
  • 5 Versions
  • 42 % Grown

The README.md

PHP OpenID Connect Basic Client

(This package is a fork of rask/openid-connect-php.), (*1)

A simple library that allows an application to authenticate a user through the basic OpenID Connect flow. This library hopes to encourage OpenID Connect use by making it simple enough for a developer with little knowledge of the OpenID Connect protocol to setup authentication., (*2)

A special thanks goes to Justin Richer and Amanda Anganes for their help and support of the protocol., (*3)

This package was originally created by Michael Jett and extensively modified by Otto Rask., (*4)

Requirements

  1. PHP 5.4 or greater
  2. CURL extension
  3. JSON extension

Install

Install library using composer, (*5)

composer require kdoyen/openid-connect-php

Then include composer autoloader, (*6)

<?php

require '/vendor/autoload.php';

Example 1: Basic Client

<?php

use OpenIdConnectClient\OpenIdConnectClient;

$oidc = new OpenIDConnectClient([
        'provider_url' => 'https://id.provider.com/',
        'client_id' => 'ClientIDHere',
        'client_secret' => 'ClientSecretHere'
    ]);

$oidc->authenticate();
$name = $oidc->requestUserInfo('given_name');

See openid spec for available user attributes., (*7)

Example 2: Dynamic Registration

<?php

use OpenIdConnectClient\OpenIdConnectClient;

$oidc = new OpenIDConnectClient([
        'provider_url' => 'https://id.provider.com/'
    ]);

$oidc->register();
$client_id = $oidc->getClientID();
$client_secret = $oidc->getClientSecret();

Be sure to add logic to store the client id and client secret inside your application., (*8)

Example 3: Network and Security

<?php

// Configure a proxy
$oidc->setHttpProxy('http://my.proxy.com:80/');

// Configure a cert
$oidc->setCertPath('/path/to/my.cert');

Example 4: Request Client Credentials Token

<?php

use OpenIdConnectClient\OpenIdConnectClient;

$oidc = new OpenIDConnectClient([
        'provider_url' => 'https://id.provider.com/',
        'client_id' => 'ClientIDHere',
        'client_secret' => 'ClientSecretHere'
    ]);

$oidc->providerConfigParam([
    'token_endpoint' => 'https://id.provider.com/connect/token'
]);

$oidc->addScope('my_scope');

// This assumes success (to validate check if the access_token
// property is there and a valid JWT):
$clientCredentialsToken = $oidc->requestClientCredentialsToken()->access_token;

Example 5: Token Introspection

<?php

use OpenIdConnectClient\OpenIdConnectClient;

$oidc = new OpenIDConnectClient([
        'provider_url' => 'https://id.provider.com/',
        'client_id' => 'ClientIDHere',
        'client_secret' => 'ClientSecretHere'
    ]);

// Provide access token to introspect.
// Can take an optional second parameter to set the token_type_hint.
$introspectionResponse = $oidc->introspectToken('provided_access_token');

// Check if the response/token is active and valid (based on exp and nbf).
$introspectionResponse->isActive();

// Get a list of allowed scopes.
$scopeArray = $introspectionResponse->getScopes();

// Simple boolean response if response has scope provided.
$introspectionResponse->hasScope('profile');

Todo

  • Dynamic registration does not support registration auth tokens and endpoints.
  • Re-factor/replace $_SESSION usage.
  • Re-factor/complete test coverage.

License & authors information

This package is licensed with Apache License 2.0., (*9)

The Versions

14/08 2017

dev-develop

dev-develop

Bare-bones OpenID Connect client

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Otto Rask
by Kristopher Doyen

14/08 2017

dev-master

9999999-dev

Bare-bones OpenID Connect client

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Otto Rask
by Kristopher Doyen

14/08 2017

v0.1.1

0.1.1.0

Bare-bones OpenID Connect client

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Otto Rask
by Kristopher Doyen

10/02 2017

dev-updating_readme

dev-updating_readme

Bare-bones OpenID Connect client

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Otto Rask
by Kristopher Doyen

09/02 2017

v0.1.0

0.1.0.0

Bare-bones OpenID Connect client

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Otto Rask
by Kristopher Doyen