PHPackages                             goodid/goodid-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. goodid/goodid-php-sdk

ActiveLibrary[API Development](/categories/api)

goodid/goodid-php-sdk
=====================

GoodID SDK for PHP

5.1.1(1y ago)330.3k↓35.7%2[2 PRs](https://github.com/idandtrust/goodid-php-sdk/pulls)MITPHPPHP &gt;=7.2

Since Mar 7Pushed 1y agoCompare

[ Source](https://github.com/idandtrust/goodid-php-sdk)[ Packagist](https://packagist.org/packages/goodid/goodid-php-sdk)[ Docs](https://github.com/idandtrust/goodid-php-sdk)[ RSS](/packages/goodid-goodid-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (36)Used By (0)

[![Build Status](https://camo.githubusercontent.com/6b22692f53aaf82d8a09d4a8383595e6da4f72580a2eea5f375a7612012ac503/68747470733a2f2f7472617669732d63692e6f72672f6964616e6474727573742f676f6f6469642d7068702d73646b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/idandtrust/goodid-php-sdk)

GoodID SDK for PHP
==================

[](#goodid-sdk-for-php)

This repository contains our open source PHP SDK that allows you to collect, decrypt and verify the data that you receive from the user.

> **Note:** This version of the GoodID SDK for PHP requires PHP 5.6 or greater.

Installation
------------

[](#installation)

The GoodID PHP SDK can be installed with [Composer](https://getcomposer.org/). Add the GoodID PHP SDK package to your `composer.json` file.

```
{
    "require": {
        "goodid/goodid-php-sdk": "~5.0"
    }
}
```

Prerequisites
-------------

[](#prerequisites)

To provide GoodID login to your users, you need to register at GoodID first. You will receive the followings:

- GoodID mobile app download link
- client id
- client secret
- default keypairs
- suggested claimset

At this point, you also have the chance to generate your own keypairs and send the public key to GoodID.

Download the GoodID app:

[![Alt text](https://camo.githubusercontent.com/578a4e40ed2171606cb69198d283ef25978532d01066118e67ddc375f41d7a41/68747470733a2f2f73332d75732d776573742d322e616d617a6f6e6177732e636f6d2f676f6f6469642f646576656c6f706572732f676f6f6469642d73646b2d6170702d73746f72652e706e67)](https://itunes.apple.com/hu/app/goodid-strong-authentication/id1072149515?mt=8) [![Alt text](https://camo.githubusercontent.com/122502937499f65c67a089a08fbf4528eafe40be56b66112d4d20e12576ca1da/68747470733a2f2f73332d75732d776573742d322e616d617a6f6e6177732e636f6d2f676f6f6469642f646576656c6f706572732f676f6f6469642d73646b2d676f6f676c652d706c61792e706e67)](https://play.google.com/store/apps/details?id=com.idandtrust.goodid)

The GoodID login flow
---------------------

[](#the-goodid-login-flow)

This is a short introduction to the GoodID login flow, to let you know what is the purpose of the endpoints (detailed in the "Endpoints to be implemented" section) that you need to implement.

Brief overview of the GoodID login flow:

1. The Javascript SDK is only responsible to render the "Sign in with GoodID" button. [Read more](https://developers.goodid.net/?page=integration#collapse_2)
2. When the user clicks on the "Sign in with GoodID" button the user agent is navigated to the **GoodID Login Initiation Endpoint** .
3. The **GoodID Login Initiation Endpoint** builds the "Authorization Request" and redirects to the GoodID Authorization EP with the request in the url.
4. The user receives the request into the GoodID mobile app and answers that.
5. Finally the user is redirected to your **Redirect URI** (Landing page), with "code" and "state" parameters that are used by the GoodID PHP SDK to collect, decrypt and verify the information provided by the user.

Endpoints to be implemented
---------------------------

[](#endpoints-to-be-implemented)

### GoodID Login Initiation Endpoint

[](#goodid-login-initiation-endpoint)

The so-called **GoodID Login Initiation endpoint** is a designated endpoint for GoodID. It is analogous to the OpenID Connect Login Initiation endpoint and it is responsible to generate the OpenID authentication request.

You don't have to handle GET/POST parameters, or write a response, this is all done automatically by the GoodID Endpoint that is instantiated in the code snippet.

```
// GoodID Login Initiation Endpoint (e.g. goodid-endpoint.php)

// Load the SDK and other dependencies
require_once __DIR__ . '/vendor/autoload.php';

use GoodID\Authentication\GoodIDEndpointFactory;
use GoodID\Helpers\GoodIDPartnerConfig;
use GoodID\Helpers\Key\RSAPrivateKey;
use GoodID\Helpers\OpenIDRequestSource\OpenIDRequestObject;
use GoodID\Helpers\Request\IncomingRequest;
use GoodID\ServiceLocator;

// -- Basic configuration --
$clientId = 'YOUR-CLIENT-ID';
$clientSecret = 'YOUR-CLIENT-SECRET';
$redirectUri = 'YOUR-REDIRECT-URI';
$scopes = array('YOUR-SCOPES'); // It can be an empty array
$claims = 'YOUR-CLAIMS-JSON-STRING';
$sigPrivKeyPEM = "YOUR-SIG-PRIV-KEY-PEM-STRING";
$sigPrivKeyKeyId = 'KEY-ID-OF-YOUR-SIG-PUB-KEY-ON-JWKS-URI';
$encPrivKeyPEM = "YOUR-ENC-PRIV-KEY-PEM-STRING";
$encPrivKeyKeyId = 'KEY-ID-OF-YOUR-ENC-PUB-KEY-ON-JWKS-URI';
// -- End of Basic configuration --

// -- Set session data handler OPTION 1 --
// You can use our default session data handler.
// In this case you need to start the session first.
session_start();
$serviceLocator = new ServiceLocator();

// -- Set session data handler OPTION 2 --
// Or you can add your own session data handler
// by defining a class which implements \GoodID\Helpers\SessionDataHandlerInterface
// Add that to the $serviceLocator.
$serviceLocator = new ServiceLocator();
$serviceLocator->setSessionDataHandler(new CustomSessionDataHandler());

$encKey = new RSAPrivateKey($encPrivKeyPEM, array('use' => 'enc', 'kid' => $encPrivKeyKeyId));
$sigKey = new RSAPrivateKey($sigPrivKeyPEM, array('use' => 'sig', 'kid' => $sigPrivKeyKeyId));

$goodidEndpoint = GoodIDEndpointFactory::createInitiateLoginEndpoint(
    $serviceLocator,
    new GoodIDPartnerConfig($clientId, $clientSecret, $sigKey, $encKey),
    new OpenIDRequestObject($claims, $scopes),
    $redirectUri,
    new IncomingRequest()
);

$goodidEndpoint->run();
```

### Redirect URI (Landing page)

[](#redirect-uri-landing-page)

The user answers therequest with the GoodID mobile application and redirected to your your so-called **Redirect URI**. The SDK collects, decrypts and verifies the response.

```
// Redirect URI / landing page

require_once __DIR__ . '/vendor/autoload.php';

use GoodID\Authentication\GoodIDEndpointFactory;
use GoodID\Helpers\GoodIDPartnerConfig;
use GoodID\Helpers\Key\RSAPrivateKey;
use GoodID\ServiceLocator;

// -- Basic configuration --
$clientId = 'YOUR-CLIENT-ID';
$clientSecret = 'YOUR-CLIENT-SECRET';
$securityLevel = 'YOUR-SECURITY-LEVEL'; // 'NORMAL' or 'HIGH'
$sigPrivKeyPEM = "YOUR-SIG-PRIV-KEY-PEM-STRING";
$sigPrivKeyKeyId = 'KEY-ID-OF-YOUR-SIG-PUB-KEY-ON-JWKS-URI';
$encPrivKeyPEM = "YOUR-ENC-PRIV-KEY-PEM-STRING";
$encPrivKeyKeyId = 'KEY-ID-OF-YOUR-ENC-PUB-KEY-ON-JWKS-URI';
// -- End of Basic configuration --

// -- Set session data handler OPTION 1 --
// You can use our default session data handler.
// In this case you need to start the session first.
session_start();
$serviceLocator = new ServiceLocator();

// -- Set session data handler OPTION 2 --
// Or you can add your own session data handler
// by defining a class which implements \GoodID\Helpers\SessionDataHandlerInterface
// Add that to the $serviceLocator.
$serviceLocator = new ServiceLocator();
$serviceLocator->setSessionDataHandler(new CustomSessionDataHandler());

$encKey = new RSAPrivateKey($encPrivKeyPEM, array('use' => 'enc', 'kid' => $encPrivKeyKeyId));
$sigKey = new RSAPrivateKey($sigPrivKeyPEM, array('use' => 'sig', 'kid' => $sigPrivKeyKeyId));

try {
    $gidResponse = GoodIDEndpointFactory::getResponse(
        $serviceLocator,
        new GoodIDPartnerConfig($clientId, $clientSecret, $sigKey, $encKey, $securityLevel)
    );

    if ($gidResponse->isSuccessful()) {
        // Subject identifier
        $subjectIdentifier = $gidResponse->getSub();

	if ($securityLevel === 'HIGH') {
	    $userId = $gidResponse->getUserId();
	    $deviceId = $gidResponse->getDeviceId();
	}

        // The data provided by the user
        $claims = $gidResponse->getClaims()->toArray();

        // Now begins the substantial part of the job:
        // You can do your custom validation of claims.
        // You can log in (or register) the user:
        // Read/write your DB, regenerate session id, etc.
        // Good luck :-)
    } else {
        $error = $gidResponse->getError();
        $errorDescription = $gidResponse->getErrorDescription();
        // The login has failed with an OpenID Authentication Error Response
        // For example the user pressed cancel in the app
    }
} catch(\Exception $e) {
    // The login has failed with an exception
    // The identity of the user cannot be verified
}
```

Miscellaneous
-------------

[](#miscellaneous)

These steps may be useful at certain steps of the integration.

### Generating your own keypairs

[](#generating-your-own-keypairs)

If you wish to generate your own keypairs, it is possible as follows, with openssl Installing openssl for Ubuntu:

```
sudo apt-get install openssl

```

Generating keypairs:

```
openssl genrsa -out client-enc_key.pem 2048
openssl rsa -in client-enc_key.pem -pubout > client-enc_key.pub
openssl genrsa -out client-sig_key.pem 2048
openssl rsa -in client-sig_key.pem -pubout > client-sig_key.pub

```

Please send us the followings:

- The new public keypairs (.pub files).
- The request object signed by the new key.

### Generating the content of your JWKs URI

[](#generating-the-content-of-your-jwks-uri)

Your JWKs URI contains your public keys (signing and ecryption) in JSON format (JWK).

If you don't have a JWKs URI yet, you can generate its content like this:

```
use GoodID\Helpers\Key\JwkSetGenerator;
use GoodID\Helpers\Key\RSAPublicKey;

$sigPrivKeyPEM = "YOUR-SIG-PRIV-KEY-PEM-STRING";
$sigPrivKeyId = 'KEY-ID-OF-YOUR-SIG-PUB-KEY-ON-JWKS-URI';
$encPrivKeyPEM = "YOUR-ENC-PRIV-KEY-PEM-STRING";
$encPrivKeyId = 'KEY-ID-OF-YOUR-ENC-PUB-KEY-ON-JWKS-URI';

$encKey = new RSAPrivateKey($encPrivKeyPEM, array('use' => 'enc', 'kid' => $encPrivKeyId));
$sigKey = new RSAPrivateKey($sigPrivKeyPEM, array('use' => 'sig', 'kid' => $sigPrivKeyId));

$jwkSetGenerator = new JwkSetGenerator();
$jwkSetGenerator->addKey($sigKey);
$jwkSetGenerator->addKey($encKey);

$jwkSetGenerator->run();
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~81 days

Recently: every ~301 days

Total

34

Last Release

672d ago

Major Versions

1.1.2 → 2.0.02017-07-20

2.5.1 → 3.0.02019-02-13

3.1.1 → 4.0.02019-11-21

4.3.1 → 5.0.12022-04-26

PHP version history (3 changes)1.0PHP &gt;=5.6.3

1.1.0PHP &gt;=5.6

5.0.1PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/9993c6d0e8980eaa9b8b9de6501468f3a92c504285b006a7ea666385918e6cf6?d=identicon)[idnt-3](/maintainers/idnt-3)

---

Top Contributors

[![idnt-3](https://avatars.githubusercontent.com/u/26144828?v=4)](https://github.com/idnt-3 "idnt-3 (63 commits)")

---

Tags

sdkgoodid

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/goodid-goodid-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/goodid-goodid-php-sdk/health.svg)](https://phpackages.com/packages/goodid-goodid-php-sdk)
```

###  Alternatives

[appwilio/cdek-sdk

CDEK API SDK (cdek.ru)

406.5k](/packages/appwilio-cdek-sdk)[mocking-magician/coinbase-pro-sdk

Library for coinbase pro API calls

223.2k](/packages/mocking-magician-coinbase-pro-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
