Single Sign-On (SSO) allows users to log into different applications securely and quickly. Pylon uses the JSON Web Token (JWT) protocol for simple sign on.

Authentication Flows

Pylon Initiated Flow

In the Pylon Initiated Flow, your users will be redirected from the portal login page directly to you for authentication.

Platform Initiated Flow

If users are coming directly from your platform, you can automatically authenticate them as you redirect them to Pylon's KB or Portal. You must redirect the users to https://graph.usepylon.com/callback/jwt?orgSlug=<ORG_SLUG>&jwt=<TOKEN> , following the configuration below. ORG_SLUG is defined in your workspace settings.

JWT Configuration

Token Required Attributes

Token Optional Attributes

Pylon supports the following Signing Algorithms for JWT:

HMAC Symmetric Key Encryption

RSA Asymmetric Key Encryption with JWKS

Note that the Metadata Endpoint must match the Remote Login URL, discussed below.

Setup

To enable this for your customers, Pylon will need some information:

image.png

More details on adjusting visibility of articles after setting up customer authentication are available here.

Example Auth0 Post-login action for JWT SSO

This example follows the Platform Initiated flow, as defined above. Note that users requesting specific pages will not be redirected to them

const jwt = require('jsonwebtoken')

exports.onExecutePostLogin = async (event, api) => {
    // Select an auth0 client id to use for the redirect, optional.
    if (event.client.client_id == "<CLIENT_ID>"){
        const email = event.user.email
        
        const pylonPayload = {
            iat: Math.floor(Date.now() / 1000),
            email,
            iss: "<ISSUER>",
            aud: 'https://portal.usepylon.com'
        };

        const options = {
            algorithm: 'HS256',
            expiresIn: '10h'
        };

        const token = jwt.sign(pylonPayload,"<SECRET>", options);
        const url = `http://graph.usepylon.com/callback/jwt?orgSlug=<ORGSLUG>&access_token=${token}`
        console.log(url)
        api.redirect.sendUserTo(url, {
            query: { access_token: token }
        });
    }
};