Download the PHP package uqi/cognito-token without Composer

On this page you can find all versions of the php package uqi/cognito-token. 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 cognito-token

Cognito Token

A PHP library for verifying AWS Cognito JWT tokens (ID tokens and Access tokens).

Overview

The CognitoTokenVerifier class provides functionality to verify JSON Web Tokens (JWTs) issued by AWS Cognito. It handles:

Installation

Requirements

Implementation Options

You have two options for implementing token verification in your application:

Option 1: Use this library directly

The simplest approach is to use this library as-is, which provides a complete solution for Cognito token verification.

Option 2: Create your own implementation

If you need custom functionality or want to integrate with specific systems, you can create your own implementation based on the principles in this library:

  1. Fetch the JWKS (JSON Web Key Set) from Cognito
  2. Parse and verify the JWT signature using the appropriate JWK
  3. Validate token claims (expiration, issuer, audience, etc.)

This approach gives you more control but requires deeper understanding of JWT verification.

Basic Usage

Caching

The library supports caching of JWKS (JSON Web Key Sets) to improve performance. By default, it uses a no-cache implementation, but you can provide your own cache implementation:

Implementing a Cache Driver

Create a class that implements the CacheInterface:

Laravel Integration

For Laravel users, a ready-to-use cache implementation is included with the library:

Usage with Laravel:

Error Handling

The library throws CognitoTokenException with specific error codes:

Error Code Description
JWKS_FETCH_FAILED Failed to fetch JWKS from the remote URL
JWKS_INVALID_FORMAT Invalid JWKS format - 'keys' not found
NO_KID_IN_TOKEN No 'kid' found in JWT header
NO_JWK_FOR_KID No matching JWK found for the specified kid
SIGNATURE_VERIFICATION_FAILED JWT signature verification failed
TOKEN_PAYLOAD_DECODING_FAILED Failed to decode JWT payload
INVALID_TOKEN Invalid token
INVALID_ISSUER Invalid issuer in token
TOKEN_EXPIRED Token is expired
INVALID_AUDIENCE Invalid audience in ID token
MISSING_SUBJECT Missing subject (sub) claim in ID token
INVALID_CLIENT_ID_ACCESS Invalid client_id in access token

Example error handling:

Class Reference

CognitoTokenVerifier

Constructor

Methods

CacheInterface

License

MIT


All versions of cognito-token with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
web-token/jwt-framework 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 uqi/cognito-token contains the following files

Loading the files please wait ...