Download the PHP package cube43/slim-jwt-auth without Composer

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

Slim JWT Auth

Build Status Type Coverage Type Coverage Latest Stable Version License

PSR-7 and PSR-15 Middleware for JWT Authentication. This is a strict-typed, modern rewrite of the popular JWT middleware, designed for Slim Framework and other PSR-15 compliant frameworks.

Installation

Install via Composer:

Usage

This library splits the JWT logic into two separate middlewares to provide better flexibility:

  1. JwtAuthentication: Parses and validates the token. If valid, it attaches the decoded token to the request tokenAttributeNames. It does not block the request if the token is missing (it acts as a hydrator).
  2. JwtAuthentificationFirewall: Checks if the request requires authentication (based on rules). If it does, and no valid token was found by the previous middleware, it returns a 401 Unauthorized response.

Complete Example

Here is a complete example setup for Slim 4, including custom handlers and rules:

Important: In Slim, middleware is executed Last-In-First-Out. You must ensure JwtAuthentication runs before JwtAuthentificationFirewall so the token is available when the firewall checks for it.

Configuration Options

The JwtAuthenticationOption class uses a fluent interface for configuration.

Token Extraction

You define how the token is extracted when creating the JwtAuthentication middleware. You can pass multiple extractors.

Firewall Rules

To define which requests require authentication, pass RuleInterface implementations to the JwtAuthentificationFirewall constructor.

Path Rule

Restrict authentication to specific paths, or ignore specific paths.

Method Rule

Ignore specific HTTP methods (e.g., OPTIONS).

Handlers

You can customize behavior using handlers.

Before Handler

Modify the request after the token is decoded but before the next middleware.

After Handler

Modify the response before returning it.

Unauthorized Handler

Customize the response when authentication fails (used by the Firewall).

Security

By default, the middleware throws a RuntimeException if you attempt to use it over HTTP (insecure). To allow HTTP for development, use withAllowedInsecureHosts:


All versions of slim-jwt-auth with dependencies

PHP Build Version
Package Version
Requires php Version ~8.1.0 || ~8.2.0 || ~8.3.0
lcobucci/jwt Version ^5.1
psr/http-message Version ^1.1 || ^2.0
psr/http-server-middleware Version ^1.0.2
psr/log Version ^1.0|^2.0|^3.0
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 cube43/slim-jwt-auth contains the following files

Loading the files please wait ...