Overview
Terang AI supports Single Sign-On (SSO) via signed JWT tokens. Your organization signs a JWT with your private key, and Terang AI verifies it using your public key. This allows your members to access Terang AI directly from your platform without creating a separate account.JWT Specification
Header
Use the RS256 algorithm:Payload
| Field | Type | Required | Description |
|---|---|---|---|
iss | string | Yes | Your domain (e.g. iai.or.id) |
aud | string | Yes | Must be terang.ai |
sub | string | Yes | Subject type, e.g. member |
email | string | Yes | Member’s email address |
membershipId | string | Yes | Unique member ID in your system |
iat | number | Yes | Issued at (Unix timestamp) |
exp | number | Yes | Expiration (Unix timestamp, max 5 minutes) |
jti | string | Yes | Unique token ID to prevent replay attacks |
Public Key Exchange
Terang AI needs your public key to verify JWT signatures. You have two options:Option 1: JWKS Endpoint (Recommended)
Expose your public key at a standard JWKS endpoint. This supports key rotation automatically.Option 2: Share Public Key Directly
If you cannot host a JWKS endpoint, you can share the PEM-formatted public key directly with the Terang AI team.If your key changes, you must notify the Terang AI team to update it manually. We strongly recommend Option 1 for production use.
SSO Flow
Once the JWT is ready, redirect the user to:- Verify the JWT signature using your public key
- Validate
iss,aud,exp, andjticlaims - Find or create the user account based on
emailandmembershipId - Redirect the user to the dashboard
Implementation Examples
PHP
Node.js
Testing
You can decode and inspect your JWT at jwt.io before sending it to Terang AI. Checklist:- JWT header uses
RS256algorithm - All required payload fields are present
-
audis set toterang.ai -
expis within 5 minutes ofiat -
jtiis unique per request - Public key is shared with Terang AI (via JWKS or PEM)