2017 © Pedro Peláez
 

library openid-connect-php

Bare-bones OpenID Connect client based on jumbojett/openid-connect-php

image

grossrucker/openid-connect-php

Bare-bones OpenID Connect client based on jumbojett/openid-connect-php

  • Friday, May 11, 2018
  • by grossrucker
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 147 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

PHP OpenID Connect Basic Client

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., (*1)

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

Requirements

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

Install

  1. Install library using composer
composer require grossrucker/openid-connect-php
  1. Include composer autoloader
require __DIR__ . '/vendor/autoload.php';

CHANGES to the original repo

added the functions, (*3)

public function verifyJWT($id_token)
private function verifyJWTclaimsWONonce($claims)```

Example:
```php
use Gumba\OpenIDConnectClient;

$oidc = new OpenIDConnectClient(
    'issuer',
    'client_id'
);

$token="header.claims.signature";
var_dump($oidc->verifyJWT($token));

Example 1: Basic Client

use Jumbojett\OpenIDConnectClient;

$oidc = new OpenIDConnectClient('https://id.provider.com',
                                'ClientIDHere',
                                'ClientSecretHere');
$oidc->setCertPath('/path/to/my.cert');
$oidc->authenticate();
$name = $oidc->requestUserInfo('given_name');

[See openid spec for available user attributes][1], (*4)

Example 2: Dynamic Registration

use Jumbojett\OpenIDConnectClient;

$oidc = new OpenIDConnectClient("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

Example 3: Network and Security

// 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

use Jumbojett\OpenIDConnectClient;

$oidc = new OpenIDConnectClient('https://id.provider.com',
                                'ClientIDHere',
                                'ClientSecretHere');
$oidc->providerConfigParam(array('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: Request Resource Owners Token (with client auth)

use Jumbojett\OpenIDConnectClient;

$oidc = new OpenIDConnectClient('https://id.provider.com',
                                'ClientIDHere',
                                'ClientSecretHere');
$oidc->providerConfigParam(array('token_endpoint'=>'https://id.provider.com/connect/token'));
$oidc->addScope('my_scope');

//Add username and password
$oidc->addAuthParam(array('username'=>'<Username>'));
$oidc->addAuthParam(array('password'=>'<Password>'));

//Perform the auth and return the token (to validate check if the access_token property is there and a valid JWT) :
$token = $oidc->requestResourceOwnerToken(TRUE)->access_token;

Example 6: Basic client for implicit flow e.g. with Azure AD B2C (see http://openid.net/specs/openid-connect-core-1_0.html#ImplicitFlowAuth)

use Jumbojett\OpenIDConnectClient;

$oidc = new OpenIDConnectClient('https://id.provider.com',
                                'ClientIDHere',
                                'ClientSecretHere');
$oidc->setResponseTypes(array('id_token'));
$oidc->addScope(array('openid'));
$oidc->setAllowImplicitFlow(true);
$oidc->addAuthParam(array('response_mode' => 'form_post'));
$oidc->setCertPath('/path/to/my.cert');
$oidc->authenticate();
$sub = $oidc->getVerifiedClaims('sub');

Development Environments

In some cases you may need to disable SSL security on on your development systems. Note: This is not recommended on production systems., (*5)

$oidc->setVerifyHost(false);
$oidc->setVerifyPeer(false);

Todo

  • Dynamic registration does not support registration auth tokens and endpoints

Contributing

  • All pull requests, once merged, should be added to the changelog.md file.

The Versions

11/05 2018

dev-master

9999999-dev

Bare-bones OpenID Connect client based on jumbojett/openid-connect-php

  Sources   Download

The Requires

 

09/04 2018

v0.5.0

0.5.0.0

Bare-bones OpenID Connect client

  Sources   Download

The Requires

 

16/02 2018

0.4.1

0.4.1.0

Bare-bones OpenID Connect client

  Sources   Download

The Requires

 

15/02 2018

0.4.0

0.4.0.0

Bare-bones OpenID Connect client

  Sources   Download

The Requires

 

20/02 2017

0.3.0

0.3.0.0

Bare-bones OpenID Connect client

  Sources   Download

The Requires

 

13/08 2016

0.2.0

0.2.0.0

Bare-bones OpenID Connect client

  Sources   Download

The Requires

 

04/03 2016

0.1.0

0.1.0.0

Bare-bones OpenID Connect client

  Sources   Download

The Requires

 

04/09 2015

dev-add-license

dev-add-license

Bare-bones OpenID Connect client

  Sources   Download

The Requires