Download the PHP package marcohern/jwtauthorize without Composer

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

Jwtauthorize

Packagist PHP from Packagist Laravel versions GitHub Workflow Status (main) Total Downloads

Jwtauthorize authorizes Laravel requests with allow/deny route policies carried in a JWT claim. It is built on php-open-source-saver/jwt-auth.

Installation

You can install the package via Composer:

You may publish the configuration file:

Option Env Default Description
guard JWTA_GUARD default guard The jwt-auth guard the middleware reads the token from.
claim JWTA_CLAIM scope The JWT claim holding the policies.
roles.disk JWTA_ROLES_DISK local Filesystem disk holding role files.
roles.path JWTA_ROLES_PATH jwta/roles Folder, inside the disk, holding role files.
ui.enabled JWTA_UI false Register the role management pages.
ui.prefix JWTA_UI_PREFIX jwta URL prefix of the pages, e.g. /jwta/roles.
ui.middleware ['web', 'auth'] Middleware in front of the pages.

Usage

Policies

A policy is a string of the form <action> <methods> <pathex>:

Policies nest. A string key holds a policy, and its value is the list of its more specific children:

The request is decided like this:

Protecting routes

Add the jwta middleware after the jwt-auth guard:

Jwtauthorize::middleware() returns the same middleware class if you prefer a class reference.

Issuing tokens

Put the policies in the configured claim when you issue the token:

Roles

Roles are named, reusable lists of policies stored as JSON files. You can manage them with Artisan:

Use PolicyManager::claim() to put one or more roles' policies in a token:

The policies are copied into the token when it is issued, so later role changes apply only to tokens issued after the change.

Managing roles in the browser

The package ships pages to list, view, create, edit, reorder and delete roles. They are off by default. To turn them on, set JWTA_UI=true; the pages are then served at /jwta/roles.

The pages are server-rendered forms, so they need a session login. They run behind ui.middleware, which defaults to ['web', 'auth']. A bearer token alone won't work in a browser. Every page also requires the jwtauthorize.manage gate. Unless you define that gate, it only allows the local environment. Define it to choose who can manage roles:

In the editor, each row is one policy. Use ⇥ / ⇤ to nest a policy under the one above it, and ↑ / ↓ to reorder. ⇅ sorts one level by specificity, longest path regex first: on a row it sorts that policy's direct children, and Sort top level sorts the top-level policies. Children always move with their parent. On the role page, ↑ / ↓ reorder the top-level policies. Among matching siblings deny wins, so the order is only for readability.

Testing roles

To check what a role allows, open Test policies (/jwta/test) and choose a role, a method and a path. You can also start from a role's Test button. A full URL works too: the page tests its path, without the query string, the same way the middleware does. The page shows:

The same check is available from the terminal. It exits with 0 when the request is allowed and 1 when it is denied, so you can use it in scripts:

The tester and the middleware share the same PolicyEvaluator, so they always agree. Among matching siblings the first deny decides. Otherwise the first matching allow does, so when several allows match, the order decides which one is reported, but never whether the request is allowed.

To restyle the pages, publish the views:

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Thank you for considering contributing to Jwtauthorize! Please review our contributing guide to get started.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

Jwtauthorize is open-sourced software licensed under the MIT license.


All versions of jwtauthorize with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
laravel/framework Version ^12.0||^13.0
php-open-source-saver/jwt-auth Version ^2.9
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 marcohern/jwtauthorize contains the following files

Loading the files please wait ...