Download the PHP package flytachi/jwt without Composer

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

Flytachi JWT

Latest Version on Packagist PHP Version Require License: MIT

A strictly-typed PHP library for issuing and verifying JSON Web Tokens, with JWKS support and no dependencies beyond ext-openssl and ext-json.

Tokens it issues are accepted by other implementations, and tokens from other implementations are accepted by it — the test suite verifies the examples printed in RFC 7515 itself, so interoperability is a checked property rather than an intention.

Installation

Requires PHP 8.1+, ext-openssl and ext-json.

Quick start

Everything that can go wrong throws one type, JWTException: a malformed string, an unsupported algorithm, a key that does not match, a signature that does not verify, an expiry that has passed. One catch covers the lot.

Algorithms

alg Family Key material Signature
HS256 HS384 HS512 HMAC shared secret string hash width
RS256 RS384 RS512 RSA OpenSSL key pair key width
ES256 ECDSA, P-256 OpenSSL key pair 64 bytes
ES384 ECDSA, P-384 OpenSSL key pair 96 bytes
ES512 ECDSA, P-521 OpenSSL key pair 132 bytes

ECDSA signatures travel as the raw pair R || S, each component padded to the width of the curve (RFC 7515 §3.4) — not as the ASN.1 DER structure OpenSSL produces. The library converts in both directions, so a token that leaves here is readable anywhere.

Asymmetric keys

The algorithm travels with the key, and a token whose header names a different one is refused. That is what closes the algorithm-confusion attack, where an RS256 token is re-signed with the public key as an HMAC secret.

Which key verifies a token

kid is optional under RFC 7515 §4.1.4, and one rule covers every algorithm:

In the header Passed to decode() Result
kid present a key under that id that key is used
kid present no such id refused
no kid exactly one key that key is used
no kid several keys refused

A named key is used or none is — there is no falling back to another, so a token cannot influence what verifies it. Several keys with no kid are refused rather than resolved by array order.

JWKS

JWK::parseKey() handles RSA, EC and oct keys and builds the PEM itself, with no ASN.1 library involved. Each key remembers its own kid, so a key taken out of the set still knows which one it is.

Keys carrying a kid land under it; keys without one are appended under a numeric index, since kid is optional in a JWK too (RFC 7517 §4.5). A key the library cannot parse is skipped rather than fatal — a provider mid-rotation may publish a type not everyone handles, and refusing the whole set would stop verification for every token.

Cache the fetched set: parseKeySet() does no I/O and no caching of its own.

What is verified, and what is not

Verified: the signature; that the key's algorithm matches the token's alg; and the time claims exp, nbf and iat, each widened by the $leeway seconds you pass.

Not verified: iss, aud, sub, scopes, revocation. Those depend on your application, and a library that guessed at them would be wrong quietly. Read them from the payload and check them yourself:

Documentation

Development

The suite covers all nine algorithms end to end, checks the bytes an ECDSA signature is made of rather than only the round trip, and verifies the RFC 7515 Appendix A examples — tokens this library did not produce.

License

MIT — see LICENSE.


All versions of jwt with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-openssl Version *
ext-json Version *
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 flytachi/jwt contains the following files

Loading the files please wait ...