Quasr
  • Introduction
    • Welcome to Quasr
    • Concepts
      • Flexible Authentication
      • User-Centric Privacy
      • Modern Development
    • Terminology
    • FAQs
  • Getting Started
    • Sign up with Quasr
    • Setup your tenant
      • Factor Configuration
      • Enrolling additional factors
      • Test with the Sample Client
      • Understanding Scopes & Scores
      • Setting up an API Client (M2M)
    • Connect your app
      • Hosted Login UI
      • Custom Login UI
      • Embedded Login UI
  • Account Administration
    • Introduction
    • Account & Billing
      • Metrics
    • Tenants
    • Usage & Statistics
    • Security
  • Tenant Administration
    • Introduction
    • Dashboard
    • Tenant Settings
    • Your Security
    • Accounts
      • Tenant Admins
    • Factors
      • Factors and Scoring
      • Username (ID)
      • Identity Provider (IDP)
        • Apple
        • Facebook
        • GitHub
        • Google
        • LinkedIn
        • Slack
      • Time-based One-time Password (TOTP)
      • One-Time Password (OTP)
      • Password
      • Secret
    • Controls
      • Configuration
      • Permissions
      • Consents
      • Rules
    • Attributes
      • Capturing Claims
      • Sourcing Claims
      • Viewing Claims
      • Searching Claims / Users
      • Sharing Claims
    • Extensions
      • Synchronous
      • Asynchronous
    • Tokens
      • Session Token (OAuth 2.0)
      • Access Token (OAuth 2.0)
      • Refresh Token (OAuth 2.0)
      • ID Token (OIDC 1.0)
      • Consent Token
      • Authorization Code (OAuth 2.0)
    • Hosted Login Page
    • APIs
      • Authentication API
      • Management API (GraphQL)
  • Legal
    • Terms of Service
    • Acceptable Use Policy
    • DPA & Subprocessors
  • More Info
    • Standards
    • Security
      • Vulnerability Disclosure
      • Wall of Recognition
    • Support
    • Status
Powered by GitBook
On this page
  • Synchronous vs Asynchronous
  • Tenant Administration UI
  • API
  • GraphQL Example
  • NodeJs - Axios Example
  • Build
  • Management API for Extensions
  1. Tenant Administration

Extensions

PreviousSharing ClaimsNextSynchronous

Last updated 2 months ago

Extensions allow to extend the system's behaviour with custom logic. Quasr allows you to run your own custom code to respond to platform events (such as account creation, OTP, data capture, ...) or add custom claims to ID and/or access tokens. Both use case differ in their integration pattern, responding to platform events is async, while adding custom claims to tokens is synchronous.

Quasr currently only supports the following programming languages/frameworks for extensions:

  • Node.js 22 in JavaScript on AWS Lambda

Synchronous vs Asynchronous

Synchronous
Asynchronous

Run as part of request; time-sensitive

Run outside of requests; not time-sensitive

Current use cases: - add custom claims to ID token - add custom claims to access token - modify granted scopes in access token

Current use cases: - respond to API calls - respond to resource creation - respond to resource updates - respond to resource deletion - respond to input capture (username / OTP) - respond to claims capture (federation) - respond to communication (send OTP) - respond to authentication events - respond to authorization events

Configured as part of resource: - client configuration

Configured as part of extension: - rule configuration

Tenant Administration UI

A code extension can be created and configured through the Tenant Admin UI > Extensions > Code Extensions.

It is currently not possible to update extensions (besides their label and status). The Tenant Admin UI may give the impression but it does not update the extension. If you want to change the code and/or rule of an extension you hence have to create a new one with the desired code and/or rule.

API

The code must be provided in Base64 encoded format.

GraphQL Example

// GraphQL Query (Sample)
mutation createExtension ($input: CreateExtensionInput!) {
    createExtension (input: $input) {
        id
    }
}

// GraphQL Variables (Sample)
{
  "input": {
    "label": "My Code Extension",
    "code": "ZXhwb3J0IGFzeW5jIGZ1bmN0aW9uIGhhbmRsZXIoKSB7IHJldHVybiB7IG1hZ2ljOiAndGVzdCcgfX0="
  }
}

// Response (Sample)
{
    "data": {
        "createExtension": {
            "id": "8bde5565-7027-4232-8db8-3f3ca1acaeac"
        }
    }
}

NodeJs - Axios Example

var axios = require('axios');
var data = JSON.stringify({
  query: `mutation createExtension ($input: CreateExtensionInput!) {
    createExtension (input: $input) {
        id
    }
}`,
  variables: {
    "input": {
      "label": "My Code Extension",
      "code": "ZXhwb3J0IGFzeW5jIGZ1bmN0aW9uIGhhbmRsZXIoKSB7IHJldHVybiB7IG1hZ2ljOiAndGVzdCcgfX0="
    }
  }
});

var config = {
  method: 'post',
  url: 'https://{tenant_id}.api.quasr.io/graphql',
  headers: { 
    'Authorization': 'Bearer ACCESS_TOKEN_WITH_ADMIN_SCOPE', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

Build

You can query the status by using getExtension and looking for the build status. Once the build has started it will say STARTED and once finished it will be either SUCCEEDED or FAILED. In case your extension build succeeded your extension status will change to ENABLED, else it will become DISABLED.

Currently little information is provided when a build fails but as we share the build details customers can run this locally to debug.

You are limited to 5 enabled code extensions per tenant. When your extension is initially deployed it will be valid for 1 day, in which time you must successfully run the extension or it will expire. Afterwards it will expire after an inactivity window of 30 days.

Below the package.json we use during build hence no imports are allowed.

{} // no imports

Management API for Extensions

Code Extensions can also be created and configured through the , see and .

You provide code for a Nodejs 22 AWS Lambda function in JavaScript. The main function must be called handler (for more information please study AWS Lambda documentation ).

see

see

Admin API
Postman Collection
GraphQL Voyager
here
Postman Collection
GraphQL Voyager
Extension in the Quasr Tenant Admin UI
Extension example to add custom claims to tokens in the Quasr Tenant Admin UI