Pylon supports two authentication methods for portal and knowledge base login for your customers - passwordless and JWT Single Sign On (SSO). These settings can be configured in the Workspace tab in your Pylon settings page.

Pylon requires that the users logging in must already be registered as contacts within Pylon, otherwise the login will fail.

Pylon has a setting to automatically create contacts using the user's email domain to match them to the appropriate account.

📄 Do contacts have to be created in Pylon to login to the portal?

Passwordless login

Our default authentication method allows users to input their email, and perform a no-password login using a one-time passcode sent to their email.

From there, they’ll be redirected to their customer portal only if they have access to the portal.

image.png

JWT SSO

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

Token Required Attributes

Token Optional Attributes

Pylon supports the following Signing Algorithms for JWT:

No other algorithms are supported (eg RSA SHA-256 or ECDSA P-256 SHA-256)

Configuration

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 hardcodes the redirect URL, which will always redirect users to the portal. However, to accommodate scenarios where users access specific pages (e.g., a private knowledge base article), you should utilize the redirect URL provided by Pylon. A recommended approach is:

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);
        // URL is hardcoded here, but you'll want to use the redirect url provided by Pylon.
        const url = `http://graph.usepylon.com/callback/jwt?orgSlug=<ORGSLUG>&access_token=${token}`
        console.log(url)
        api.redirect.sendUserTo(url, {
            query: { access_token: token }
        });
    }
};