PHPackages                             liplum/flarum-jwt-auth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. liplum/flarum-jwt-auth

ActiveFlarum-extension[Authentication &amp; Authorization](/categories/authentication)

liplum/flarum-jwt-auth
======================

Authentication based on JSON Web Token (JWT) token through HTTP request cookie.

0.3.1(1y ago)21191MITPHP

Since Dec 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/liplum/flarum-jwt-auth)[ Packagist](https://packagist.org/packages/liplum/flarum-jwt-auth)[ RSS](/packages/liplum-flarum-jwt-auth/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

Flarum JSON Web Token Auth
==========================

[](#flarum-json-web-token-auth)

A [Flarum](http://flarum.org) extension to authenticate based on JSON Web Token (JWT) token through HTTP request cookie.

Get Started
-----------

[](#get-started)

Installation:

```
composer require liplum/flarum-jwt-auth
```

Update:

```
composer update liplum/flarum-jwt-auth
```

Forum Setup
-----------

[](#forum-setup)

Setup the JWT authentication by following the steps below in the extension settings page. You can find the corresponding backend implementation example in [the next chapter](#backend-setup).

### 1. Set the cookie name

[](#1-set-the-cookie-name)

Set the name of [cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) from the user browser requests. For example, "access\_token".

### 2. Set the JWT audience

[](#2-set-the-jwt-audience)

It's optional.

The extension will check if the `aud` field in JWT payload is identical to the JWT audience provided by admin settings. If not, the JWT will be considered as invalid.

### 3. Set the JWT secret

[](#3-set-the-jwt-secret)

The secret to sign(encode) and verify(decode) a JWT token.

The JWT payload should be something like this.

```
{
  "sub": "your_user_id"
}
```

For security issue, you should set the JWT secret in the [config.php](https://docs.flarum.org/config/)instead of barely display on extension settings page for anyone who has the extension management permission.

```
