Download the PHP package hytale-community/hytale-auth-php without Composer

On this page you can find all versions of the php package hytale-community/hytale-auth-php. 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 hytale-auth-php

Hytale Auth PHP

Framework-agnostic PHP library for Sign in with Hytale using OpenID Connect, Authorization Code flow and PKCE.

The package provides the core authentication flow without depending on Laravel, Symfony or another framework. It uses PSR HTTP interfaces so the HTTP implementation remains up to the consuming application.

Package: hytale-community/hytale-auth-php

Features

Requirements

Installation

The core package depends on PSR interfaces only. Your application must provide compatible HTTP implementations.

For example, with Guzzle:

Hytale endpoints

By default, the library uses the official Hytale OpenID Connect issuer:

The library retrieves and validates Hytale's provider metadata through:

UserInfo and JWKS URLs are read from that metadata. Authorization, token and revocation requests use Hytale's standard issuer paths documented above.

Configuration

For a confidential client, provide the client secret:

Confidential clients authenticate against the token endpoint using HTTP Basic authentication. The client secret is never sent in the form body.

Creating the client

The package accepts PSR-compatible HTTP dependencies.

Using Guzzle:

Starting an authentication flow

openid is automatically included when it is missing.

Before redirecting the user, persist these values in your session or another temporary server-side store:

Then redirect the user to:

Available scopes

Enum Hytale scope
Scope::OpenId openid
Scope::Profile hytale:profile
Scope::SharedSource account:shared_source
Scope::GameOwnership account:game_ownership
Scope::ParentalManaged account:parental_managed
Scope::Offline offline

Use Scope::Offline when your Hytale application is allowed to receive refresh tokens.

Handling the callback

Pass the callback query parameters and the values stored before the redirect:

The library will:

  1. Handle OAuth errors returned by Hytale.
  2. Validate the callback state.
  3. Exchange the authorization code using PKCE.
  4. Discover Hytale's OpenID configuration.
  5. Retrieve Hytale's JWKS.
  6. Validate the ID token signature and claims.
  7. Return the validated tokens and claims.

Authentication result

Validated identity claims are available through:

Tokens are available through:

Subject vs profile UUID

The OIDC sub claim is the stable user identifier for your Hytale application:

It should normally be used as the primary external account identifier in your application. The value is application-specific, so the same Hytale account can have a different sub in another third-party application.

A Hytale profile UUID is a separate public profile identity:

When hytale:profile is requested, the user selects a Hytale profile during authentication. The profile UUID represents that selected public profile rather than the application-specific account identifier.

UserInfo

You can retrieve the current claims associated with an access token:

Then access:

Refresh tokens

If refresh tokens are enabled for your Hytale application and the offline scope was requested:

Hytale refresh tokens rotate. When a refresh succeeds, replace the stored refresh token with the new one returned by Hytale:

Do not reuse the old refresh token after a successful refresh. Reusing an old rotated token may invalidate the refresh token chain.

Revoking a token

Revoke a token when disconnecting a Hytale account or invalidating an authenticated session:

Error handling

OAuth errors returned by Hytale are exposed through OAuthException:

Hytale may return OAuth errors such as:

Validation failures such as an invalid state, nonce, issuer, audience or malformed response are rejected by the library.

Malformed or incomplete JSON responses from Hytale are exposed through UnexpectedResponseException:

Security notes

Always store state, nonce and the PKCE code_verifier server-side between the authorization redirect and callback.

Never expose a confidential client secret to browser or frontend code.

Redirect URIs registered with Hytale must match exactly. localhost and 127.0.0.1 are different redirect URIs.

Access tokens are opaque. Do not parse them. Use the validated ID token claims or the UserInfo endpoint instead.

ID tokens are validated against Hytale's RS256 JWKS and checked for the expected issuer, audience, expiration and nonce.

Authorization codes are short-lived and single-use. Exchange them immediately and never attempt to reuse them.

Local development

A local redirect URI can use HTTP when using localhost or 127.0.0.1, provided that exact URI is registered in your Hytale application.

Example:

When developing this package alongside another Composer project, you can use a path repository:

Then require the local development version:

Testing

Install development dependencies and run:

Apply the configured PHP CS Fixer rules with:

The test suite mocks Hytale's HTTP endpoints and covers PKCE, authorization callbacks, token exchange, refresh-token rotation, revocation, malformed responses, ID token validation, UserInfo and public/confidential client behavior without contacting the real Hytale authentication service.

Framework integrations

This package intentionally contains no framework-specific session, cache, routing or persistence code.

A dedicated Laravel integration can build on top of this package while keeping the PHP SDK framework-agnostic.

License

MIT


All versions of hytale-auth-php with dependencies

PHP Build Version
Package Version
Requires firebase/php-jwt Version ^7.1
php Version ^8.2
psr/http-client Version ^1.0
psr/http-factory Version ^1.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 hytale-community/hytale-auth-php contains the following files

Loading the files please wait ...