{"id":13549310,"url":"https://github.com/jumbojett/OpenID-Connect-PHP","last_synced_at":"2025-04-02T22:31:40.479Z","repository":{"id":5900372,"uuid":"7119031","full_name":"jumbojett/OpenID-Connect-PHP","owner":"jumbojett","description":"Minimalist OpenID Connect client","archived":false,"fork":false,"pushed_at":"2025-03-03T22:06:11.000Z","size":510,"stargazers_count":650,"open_issues_count":110,"forks_count":381,"subscribers_count":33,"default_branch":"master","last_synced_at":"2025-03-25T19:14:30.353Z","etag":null,"topics":["authentication","authorization","identity-verification","openid","openid-connect","protocol"],"latest_commit_sha":null,"homepage":"https://github.com/jumbojett/OpenID-Connect-PHP","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jumbojett.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-12-11T20:44:02.000Z","updated_at":"2025-03-21T10:26:34.000Z","dependencies_parsed_at":"2023-12-13T13:25:52.969Z","dependency_job_id":"d2953e0b-70ea-4f89-96a0-a81011faefbf","html_url":"https://github.com/jumbojett/OpenID-Connect-PHP","commit_stats":{"total_commits":348,"total_committers":99,"mean_commits":3.515151515151515,"dds":0.8505747126436781,"last_synced_commit":"e46f108adf9be166f232edfe1e5315e6fcf168e5"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumbojett%2FOpenID-Connect-PHP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumbojett%2FOpenID-Connect-PHP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumbojett%2FOpenID-Connect-PHP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumbojett%2FOpenID-Connect-PHP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jumbojett","download_url":"https://codeload.github.com/jumbojett/OpenID-Connect-PHP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246905157,"owners_count":20852812,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","authorization","identity-verification","openid","openid-connect","protocol"],"created_at":"2024-08-01T12:01:20.518Z","updated_at":"2025-04-02T22:31:40.191Z","avatar_url":"https://github.com/jumbojett.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"PHP OpenID Connect Basic Client\n========================\nA simple library that allows an application to authenticate a user through the basic OpenID Connect flow.\nThis library hopes to encourage OpenID Connect use by making it simple enough for a developer with little knowledge of\nthe OpenID Connect protocol to set up authentication.\n\nA special thanks goes to Justin Richer and Amanda Anganes for their help and support of the protocol.\n\n# Requirements #\n 1. PHP 7.0 or greater\n 2. CURL extension\n 3. JSON extension\n\n## Install ##\n1. Install library using composer\n```\ncomposer require jumbojett/openid-connect-php\n```\n\n2. Include composer autoloader\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n```\n\n## Example 1: Basic Client ##\n\n```php\nuse Jumbojett\\OpenIDConnectClient;\n\n$oidc = new OpenIDConnectClient('https://id.provider.com',\n                                'ClientIDHere',\n                                'ClientSecretHere');\n$oidc-\u003esetCertPath('/path/to/my.cert');\n$oidc-\u003eauthenticate();\n$name = $oidc-\u003erequestUserInfo('given_name');\n\n```\n\n[See openid spec for available user attributes][1]\n\n## Example 2: Dynamic Registration ##\n\n```php\nuse Jumbojett\\OpenIDConnectClient;\n\n$oidc = new OpenIDConnectClient(\"https://id.provider.com\");\n\n$oidc-\u003eregister();\n$client_id = $oidc-\u003egetClientID();\n$client_secret = $oidc-\u003egetClientSecret();\n\n// Be sure to add logic to store the client id and client secret\n```\n\n## Example 3: Network and Security ##\n```php\n// Configure a proxy\n$oidc-\u003esetHttpProxy(\"http://my.proxy.com:80/\");\n\n// Configure a cert\n$oidc-\u003esetCertPath(\"/path/to/my.cert\");\n```\n\n## Example 4: Request Client Credentials Token ##\n\n```php\nuse Jumbojett\\OpenIDConnectClient;\n\n$oidc = new OpenIDConnectClient('https://id.provider.com',\n                                'ClientIDHere',\n                                'ClientSecretHere');\n$oidc-\u003eproviderConfigParam(['token_endpoint'=\u003e'https://id.provider.com/connect/token']);\n$oidc-\u003eaddScope(['my_scope']);\n\n// this assumes success (to validate check if the access_token property is there and a valid JWT) :\n$clientCredentialsToken = $oidc-\u003erequestClientCredentialsToken()-\u003eaccess_token;\n\n```\n\n## Example 5: Request Resource Owners Token (with client auth) ##\n\n```php\nuse Jumbojett\\OpenIDConnectClient;\n\n$oidc = new OpenIDConnectClient('https://id.provider.com',\n                                'ClientIDHere',\n                                'ClientSecretHere');\n$oidc-\u003eproviderConfigParam(['token_endpoint'=\u003e'https://id.provider.com/connect/token']);\n$oidc-\u003eaddScope(['my_scope']);\n\n//Add username and password\n$oidc-\u003eaddAuthParam(['username'=\u003e'\u003cUsername\u003e']);\n$oidc-\u003eaddAuthParam(['password'=\u003e'\u003cPassword\u003e']);\n\n//Perform the auth and return the token (to validate check if the access_token property is there and a valid JWT) :\n$token = $oidc-\u003erequestResourceOwnerToken(TRUE)-\u003eaccess_token;\n\n```\n\n## 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) ##\n\n```php\nuse Jumbojett\\OpenIDConnectClient;\n\n$oidc = new OpenIDConnectClient('https://id.provider.com',\n                                'ClientIDHere',\n                                'ClientSecretHere');\n$oidc-\u003esetResponseTypes(['id_token']);\n$oidc-\u003esetAllowImplicitFlow(true);\n$oidc-\u003eaddAuthParam(['response_mode' =\u003e 'form_post']);\n$oidc-\u003esetCertPath('/path/to/my.cert');\n$oidc-\u003eauthenticate();\n$sub = $oidc-\u003egetVerifiedClaims('sub');\n\n```\n\n## Example 7: Introspection of an access token (see https://tools.ietf.org/html/rfc7662) ##\n\n```php\nuse Jumbojett\\OpenIDConnectClient;\n\n$oidc = new OpenIDConnectClient('https://id.provider.com',\n                                'ClientIDHere',\n                                'ClientSecretHere');\n$data = $oidc-\u003eintrospectToken('an.access-token.as.given');\nif (!$data-\u003eactive) {\n    // the token is no longer usable\n}\n\n```\n\n## Example 8: PKCE Client ##\n\n```php\nuse Jumbojett\\OpenIDConnectClient;\n\n$oidc = new OpenIDConnectClient('https://id.provider.com',\n                                'ClientIDHere',\n                                null);\n$oidc-\u003esetCodeChallengeMethod('S256');\n$oidc-\u003eauthenticate();\n$name = $oidc-\u003erequestUserInfo('given_name');\n\n```\n\n## Example 9: Back-channel logout ##\n\nBack-channel authentication assumes you can end a session on the server side on behalf of the user (without relying\non their browser). The request is a POST from the OP direct to your RP. In this way, the use of this library can\nensure your RP performs 'single sign out' for the user even if they didn't have your RP open in a browser or other\ndevice, but still had an active session there.\n\nEither the sid or the sub may be accessible from the logout token sent from the OP. You can use either\n`getSidFromBackChannel()` or `getSubjectFromBackChannel()` to retrieve them if it is helpful to match them to a session\nin order to destroy it.\n\nThe below ensures the use of this library to ensure validation of the back-channel logout token, but is afterward\njust a hypothetical way of finding such a session and destroying it. Adjust it to the needs of your RP.\n\n```php\n\nfunction handleLogout() {\n    // NOTE: assumes that $this-\u003eoidc is an instance of OpenIDConnectClient()\n    if ($this-\u003eoidc-\u003everifyLogoutToken()) {\n        $sid = $this-\u003eoidc-\u003egetSidFromBackChannel();\n\n        if (isset($sid)) {\n            // Somehow find the session based on the $sid and\n            // destroy it. This depends on your RP's design,\n            // there is nothing in the OIDC spec to mandate how.\n            //\n            // In this example, we find a Redis key, which was\n            // previously stored using the sid we obtained from\n            // the access token after login.\n            //\n            // The value of the Redis key is that of the user's\n            // session ID specific to this hypothetical RP app.\n            //\n            // We then switch to that session and destroy it.\n            $this-\u003eredis-\u003econnect('127.0.0.1', 6379);\n            $session_id_to_destroy = $this-\u003eredis-\u003eget($sid);\n            if ($session_id_to_destroy) {\n                session_commit();\n                session_id($session_id_to_destroy); // switches to that session\n                session_start();\n                $_SESSION = []; // effectively ends the session\n            }\n        }\n    }\n}\n\n```\n\n## Example 10: Enable Token Endpoint Auth Methods ##\n\nBy default, only `client_secret_basic` is enabled on client side which was the only supported for a long time.\nRecently `client_secret_jwt` and `private_key_jwt` have been added, but they remain disabled until explicitly enabled.\n\n```php\nuse Jumbojett\\OpenIDConnectClient;\n\n$oidc = new OpenIDConnectClient('https://id.provider.com',\n                                'ClientIDHere',\n                                null);\n# enable 'client_secret_basic' and 'client_secret_jwt'                                \n$oidc-\u003esetTokenEndpointAuthMethodsSupported(['client_secret_basic', 'client_secret_jwt']);\n\n# for 'private_key_jwt' in addition also the generator function has to be set.\n$oidc-\u003esetTokenEndpointAuthMethodsSupported(['private_key_jwt']);\n$oidc-\u003esetPrivateKeyJwtGenerator(function(string $token_endpoint) {\n    # TODO: what ever is necessary\n})\n```\n\n\n## Development Environments ##\nIn some cases you may need to disable SSL security on your development systems.\nNote: This is not recommended on production systems.\n\n```php\n$oidc-\u003esetVerifyHost(false);\n$oidc-\u003esetVerifyPeer(false);\n```\n\nAlso, your local system might not support HTTPS, so you might disable upgrading to it:\n\n```php\n$oidc-\u003esetHttpUpgradeInsecureRequests(false);\n```\n\n### Todo ###\n- Dynamic registration does not support registration auth tokens and endpoints\n\n  [1]: http://openid.net/specs/openid-connect-basic-1_0-15.html#id_res\n  \n## Contributing ###\n - All pull requests, once merged, should be added to the CHANGELOG.md file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjumbojett%2FOpenID-Connect-PHP","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjumbojett%2FOpenID-Connect-PHP","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjumbojett%2FOpenID-Connect-PHP/lists"}