Download the PHP package joandysson/hyperf-oidc without Composer

On this page you can find all versions of the php package joandysson/hyperf-oidc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package hyperf-oidc

Hyperf OIDC

Generic OpenID Connect adapter for Hyperf applications.

You can use it to integrate login with any compatible OIDC/OAuth2 provider, including Google, Facebook, GitHub, Microsoft Entra ID, Keycloak, Auth0, Ory Hydra and other providers. Each provider still needs its own client credentials, redirect URI and supported endpoint configuration.

The package handles the common OIDC/OAuth2 calls your application needs:

It does not include provider-specific admin APIs. User creation, realm management and provider administration should be handled by each provider's own SDK or API.

Requirements

Install

Publish Config

The published file is:

Published config:

Configuration Reference

Key Default Description
default default Provider name used when Oidc::class is resolved directly from the Hyperf container.
providers default provider Map of named provider configurations. Add more entries when the same app needs multiple OIDC providers.
providers.*.issuer OIDC_ISSUER Base issuer URL for the provider. For Keycloak, this is usually the realm URL, such as https://idp.example.com/realms/my-realm.
providers.*.client_id OIDC_CLIENT_ID OAuth/OIDC client identifier registered in the provider.
providers.*.client_secret OIDC_CLIENT_SECRET OAuth/OIDC client secret. Set to null or an empty value for public clients.
providers.*.redirect_uri OIDC_REDIRECT_URI Callback URL registered in the provider and used by the authorization code flow.
providers.*.timeout 0 Guzzle request timeout in seconds. 0 keeps Guzzle's default no-timeout behavior.
providers.*.scope openid Default scopes sent in authorization, password and client credentials flows. Extra scopes passed to methods are appended to this value.
providers.*.discovery.enabled true Enables OIDC Discovery through the provider metadata document.
providers.*.discovery.url null Optional custom discovery URL. When empty, the adapter uses {issuer}/.well-known/openid-configuration.
providers.*.endpoints.authorization /authorize Manual authorization endpoint fallback used to build login URLs when discovery is disabled or does not provide authorization_endpoint.
providers.*.endpoints.token /token Manual token endpoint fallback used for authorization code, refresh token, password and client credentials flows.
providers.*.endpoints.introspection /introspect Manual introspection endpoint fallback used by introspect().
providers.*.endpoints.end_session /logout Manual logout/end-session endpoint fallback used by logout().

Environment

For a generic provider whose endpoints are directly under the issuer:

For Keycloak:

When discovery is enabled, the adapter reads endpoints from OIDC_ISSUER/.well-known/openid-configuration. If discovery fails or the provider does not expose a specific endpoint, the manual endpoint values are used as fallback. If an endpoint value is an absolute URL, it is used as-is. If it is a relative path, it is appended to OIDC_ISSUER.

For providers where discovery is disabled or unavailable, configure endpoints manually:

Usage

Resolve the adapter from the Hyperf container:

Login URL

Use this URL to redirect the user to the provider login page.

The scope argument appends scopes to the configured default scope. If OIDC_SCOPE is openid, passing scope: 'profile email' sends openid profile email.

Request-specific values such as state, extra scopes and PKCE verifiers are passed as method arguments. The adapter does not store them on the service instance, so it remains safe when resolved as a long-lived container service.

PKCE

PKCE is optional and can be enabled per authorization request:

Store $codeVerifier in the user's session. The login URL will include code_challenge and code_challenge_method=S256.

Authorization Callback

After login, your provider redirects back to OIDC_REDIRECT_URI with a code.

If PKCE was used, pass the stored verifier:

Refresh Token

Password Grant

Only use this flow when your provider and security model explicitly allow it.

Client Credentials

Use this flow for service-to-service authentication.

Token Introspection

The second argument is optional:

Logout

Most providers invalidate the session/token and return 200 or 204.

Multiple Providers

You can configure more than one provider and choose the default one:

The default adapter instance uses the configured default provider. To use a specific provider at runtime, use the factory:

Public Clients

If your provider uses a public client, set client_secret to null:

When the secret is null or empty, the adapter omits client_secret from token, introspection and logout requests.

Returned Responses

All network methods return Psr\Http\Message\ResponseInterface.

Use tokenPayload() when the response must contain access_token:

Exceptions

All package-specific exceptions extend Joandysson\HyperfOidc\Exceptions\OidcException.

Current exception types:

Guzzle exceptions may still be thrown for transport-level failures.

Testing

Install dependencies:

Run unit tests:

Run static analysis:

Run coverage. This requires a coverage driver such as Xdebug:

The coverage script fails when statement coverage is below 90%.

Notes


All versions of hyperf-oidc with dependencies

PHP Build Version
Package Version
Requires guzzlehttp/guzzle Version ^7.0
php Version >= 8.1
hyperf/config Version ^3.1
hyperf/contract Version ^3.1
hyperf/guzzle Version ^3.1
hyperf/support Version ^3.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package joandysson/hyperf-oidc contains the following files

Loading the files please wait ...