Download the PHP package connectholland/secure-jwt-bundle without Composer

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

Secure JWT Bundle

Symfony bundle that makes JWT more secure

Install

Installation is not fluent and error free yet, but it is easy to work around:

Will give error in post installation:

Configure scheb twofactor Google:

In the scheb_two_factor.yaml file:

Run

Again to finish the installation.

BTW1: Installation and configuration of the scheb twofactor bundle before installation of this bundle will also prevent this error.
BTW2: of course a PR that fixes these issues is welcome :)

Cookie storage

Tokens in local storage are insecure, so if you use tokens from a web interface you should store them somewhere else. A secure cookie is a good location. Configure cookie storage as follows:

Let the lexik/jwt-authentication-bundle look at cookies:

In the lexik_jwt_authentication.yaml config file:

Make sure the token is set as a secure cookie

In the security.yaml config file:

Invalidate tokens

By default tokens are valid until they expire. This makes is impossible to really log out. You can configure token invalidatation to allow logouts:

Create database table

In the doctrine.yaml file:

And run migrations:

Configure API endpoint logout

In the api_platform.yaml file:

Of course do not remove other required paths that might already be in the paths configuration.

There will be a logout endpoint in your API. This endpoint requires a message formatted like:

The value of logout is not important and not used. This field is required because API platform requires at least one field in the message. (A better solution for this is welcome).

Do not allow invalidated tokens

In the security.yaml file:

Two Factor Authentication in JWT

Configure Google Authenticator

In the scheb_two_factor.yaml file:

Use the two_factor_jwt security listener and provider

In the security.yaml file:

Implement the right interfaces

Your User object should implement ConnectHolland\SecureJWTBundle\Entity\TwoFactorUserInterface.

Using 2FA

This will give the following response:

If 2FA is not yet setup you will receive:

In the next call add the two factor challenge:

If correct you'll receive:

The response headers will include a secure cookie containing the JWT token to allow future authenticated calls.

2FA Remember this device

The remember device functionality allows users to skip the 2fa for a configurable amount of days. The default configuration is set to false, which means it doesn't set a REMEMBER_DEVICE cookie after logging in. The default amount of days is set to 30.

To configure:

In the config/packages folder of the root project create a new file called: connect_holland_secure_jwt.yaml

In this file the configuration can be set:

As mentioned before, after logging in a REMEMBER_DEVICE cookie will be set. It will contain a unix expiry time and the email of the user.

Besides placing the cookie it will be persisted in the: secure_jwt_remember_device_token table. This entity can be found in src/Entity/RememberDeviceToken.php

Recover codes

You can retrieve recovery codes for 2FA which allow you to reset 2FA. If a valid recovery code is entered as challenge, 2FA will be reset and you'll get a QR code response.


All versions of secure-jwt-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4
lexik/jwt-authentication-bundle Version ^2.16
ext-json Version *
doctrine/orm Version ^2.7
symfony/messenger Version ^5.4
api-platform/api-pack Version ^1.2
api-platform/core Version ^2.5
scheb/two-factor-bundle Version ^4.16
endroid/qr-code-bundle Version ^3.4
friendsofsymfony/rest-bundle Version ^3.0
laminas/laminas-zendframework-bridge Version ^1.4
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 connectholland/secure-jwt-bundle contains the following files

Loading the files please wait ....