How to Customize your Authentication Flow?

The Custom Auth flow lets you validate incoming requests, check tokens, and return user details and you can customize it to match your own authentication logic.

1. Enable Custom Auth in Settings

  • Go to the right-hand sidebar → Settings → Configuration.

  • Under Custom Auth, toggle Enable Custom Authentication.

  • Save your changes.

2. Open the Custom Auth Flow

  • Navigate to the fastnCustomAuth flow.

  • This flow always begins with an On API Request trigger.

3. Initialize Flow Variables

  • Add variables such as baseURL and APIKey.

  • These can be predefined defaults for your flow, but you can alter them if needed.

4. Apply Token Validation (Switch Step)

  • At this stage, the flow checks the Authorization header against the predefined Fastn secret (fastn_mcp_client_api_key).

  • Condition 1: If headers.authorization equals

    Bearer {{secrets.fastn_mcp_client_api_key}}

    → Pass.

  • Condition 2: If headers.authorization equals

    {{secrets.fastn_mcp_client_api_key}}

    → Pass.

When one of the conditions matches:

  • The flow returns a user object that contains:

    • tenantId

    • role

    • expiresIn

  • All inside a success response.

When no conditions match:

  • The flow continues to the Logger step for tracking request headers.

5. Handle Logs and External Checks

  • Logger Step → capture the request headers.

  • GET Request (HTTP API) → check if the user exists externally.

  • Final Switch Step

  • If user exists → return user details.

  • If not → return error and unauthorized.

6. Save and Customize

  • Save the flow once configured.

  • You can customize the logic to match your own authentication provider, add extra validation rules, or enrich the returned user object.

With this setup, you decide exactly how requests are authenticated and what user details are returned.

Last updated

Was this helpful?