Configure Fusion 5 for JWT

You can configure Fusion Server to use JSON Web Tokens (JWTs) for user authentication and authorization.

How the JWT realm works

A JWT is comprised of three distinct parts: the header, payload, and signing key. Each of these parts are separately encoded using Base64url encoding.

  • The header identifies the algorithm used to generate the token.

    Fusion uses only the HS256 signature algorithm.
  • The payload consists of data that will be passed with the token.

  • The signing key validates the integrity of the token by using a "secret" to ensure the header and payload being submitted in the token match the header and payload stored in the signing key.

Within Fusion, the JWT realm uses an authorization header in the request to authenticate the user and the data inside the JWT token for the authorization. This authorization header uses the following format:

Bearer <jwt-token>

Upon receiving the authorization header, Fusion authenticates the token and emits a response accordingly.

Configure JWT for Fusion

Create a JWT token

Using the tool you use to validate users, create a JWT token. The token should have following properties:

  • iss: Issuer value. If the issuer value does not match the value configured in Fusion, the user will be denied access.

  • iat: A JSON numeric date value. This value is calculated by counting the number of seconds between 1970-01-01T00:00:00Z UTC and the specified UTC date/time, ignoring leap seconds.

  • sub: Subject. The name/id of the user. The user is logged in by this name.

  • groups: The groups from the group-role mappings that this user belongs to. The groups key should match the one you specify while creating the JWT realm.

Example data inside token:

:iss “fusion-enterprise-app”
:iat 1562633069
:sub “username”
:groups [“group-1” “group-2”]

Create the Fusion JWT realm

To create a Fusion realm, in the Fusion UI:

  1. Click System > Access Control.

  2. Click the Security Realms tab, then Add Security Realm.

  3. Enter a realm name. Under type, select jwt.

  4. Create the security realm with the following values:

    Value Description

    Realm type


    JWT Issuer

    A unique value that is used in the JWT authorization header. This value should match the value of the iss in the token, for example fusion-enterprise-app.


    Check the roles that this realm provides after successfully authenticating a user by default.

    Groups Key

    The JWT token value that contains the list of groups the user is in. Default value: GRPS.

    Group mappings

    A list of pairs which associate groups to roles. For example: {<name of group>, <role assigned to group>}.

    1. Click Add new mapping. Two rows appear.

    2. In the first row, add a group. The JWT token contains the groups for a particular user.

    3. In the second row, add the role or roles (separated by spaces) for that group.

      map JWT groups to Fusion roles

    Signing Key

    A string of secret characters that will be used to encrypt the JWT token. The key must be a shared secret key. Leave empty if no signing key is used.

  5. Click Save.

Validate the new realm

When you send a request to Fusion, you should receive a response. The request to Fusion looks like this:

curl -H 'authorization: Bearer <token-header>.<token-payload>.<token-signing-key>'
Bearer is case sensitive.

Start Fusion with Custom JWT Realms

You can start Fusion with your desired realm settings already enabled. Realm values are in JSON format and can be either a single realm configuration or an array. Realm settings are stored inside the application’s configuration files and include the native realm as a default. If the native realm is missing in a non-empty configuration, it is still created but in a disabled state.

After defining the realms, add them to application.yml or any other configuration file that uses the security.initial-realm-configs Spring Boot property. Settings that create only the native realm will be used on a first launch, for recovery, or when all other realms have been disabled.

Sample JSON for creating a JWT OKTA realm:


 initial-realm-configs: '[
    "realmType": "jwt",
    "name": "jwt_okta",
    "enabled": true,
    "roleNames": [
    "config": {
      "autoCreateUsers": true,
      "jwtIssuer": "",
      "jwkSetUri": "",
      "groups": {
        "groupKey": "fusion-groups",
        "roleMapping": [

Resources is an excellent resource for learning about JWT, creating tokens, debugging tokens, and more.

Example of generating a JWT using PyJWT

Typically, you will generate your JWT token from the application you are integrating with Fusion APIs.

This example, however, uses Python to create a JWT token with the PyJWT Python egg.

  1. Install the PyJWT egg:

    pip install pyjwt
  2. Inside a Python console, run the following command using your realm configurations:

    import jwt
    from datetime import datetime
    key = '<signing key>'
    jwt_issuer = '<JWT issuer>'
    username = '<username>'
    groups = ['<groups assigned to user>']
    payload = {'iss': jwt_issuer, 'iat': datetime.utcnow(), 'sub': username, 'groups': groups}
    print jwt.encode(payload, key, algorithm='HS256')

    A Bearer token will be printed for use in API requests:

  3. You can now use this as a bearer token in an authorization header to authenticate to Fusion.

    Test your Fusion API web service call with cURL. For example, if your role is an administrator, call:

    curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmdXNpb24iLCJpYXQiOjE1MzY3ODI1MTc4NjQsInN1YiI6InRlc3QtZnVzaW9uIiwiZ3JvdXBzIjpbImdyb3VwLW9uZSIsImdyb3VwLXR3byJdfQ._ACGk4q3Y5g8QgvLFUUQIcMN2ynACypcpei2JmYFlzc" http://localhost:8764/api/roles