raegmaen/openid-connect-php

OpenID Connect client

0.2.1 2018-11-21 13:28 UTC

This package is not auto-updated.

Last update: 2024-04-28 02:27:04 UTC


README

PHP library to authenticate users against an identity provider using the OpenId Connect protocol.
Use cases implemented:

  1. Authentication using the Authorization Code Flow
  2. Refreshing access token with refresh token

Requirements

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

Install

Composer

composer require raegmaen/openid-connect-php

License

Apache License, Version 2.0

Example:

$openIdConnectClient = OpenIdConnectFactory::create(
    $providerUrl,
    $clientId,
    $clientSecret,
    $callbackUrl
);

$authenticationResult = $this->openIdConnectClient->authenticate($requestData);
if ($authenticationResult instanceof UserRedirect) {
    // Redirect user to given Url
}

$claims = $authenticationResult->getIdToken()->getClaims();

$name = $claims->get('given_name');