Skip to main content

Security Overview

Security best practices for ChainIT authentication integrations.

Security is Everyone's Responsibility

A single compromised credential can lead to data breaches. Follow these best practices to protect your application and users.


Security by App Type

App TypeKey Security FeaturesThreat Model
M2MClient secret protection, scope validation, token expirationServer-to-server
IDPPKCE required, callback URL validation, allowed origins, state parameterBrowser/mobile app
Hosted UIServer-to-server secrets, session security, token handlingManaged UI

Key Security Principles

PrincipleDescriptionEnforcement
Least PrivilegeOnly request scopes you needServer validates scopes
Secure StorageStore secrets in env vars, not codeClient-side responsibility
HTTPS OnlyAlways use HTTPS for API callsTLS 1.2+ required
Token HygieneRefresh before expiration, revoke when doneClient responsibility
Validate TokensVerify signature, expiration, issuer, audienceServer-side validation

Token Security

Never Expose Secrets in Client Code

clientSecret is for server-side only. Browser bundles, mobile apps, and frontend code should never contain secrets.

PracticeDescriptionImpact
Never expose secrets in client codeclientSecret is for server-side onlyPrevents token theft
Use HttpOnly cookies when possiblePrevents XSS access to tokensMitigates XSS attacks
Don't put tokens in URLsTokens in URLs leak via logs/refererPrevents token leakage
Validate on every requestCheck signature, expiration, scopesEnsures token validity

PKCE (IDP Apps)

PKCE (RFC 7636) is required for all IDP flows:

// Always use S256 method
const codeChallenge = base64url(sha256(codeVerifier));
PKCE Protection

PKCE prevents authorization code interception attacks. Even if the authorization code is stolen, the attacker cannot exchange it without the code_verifier.


Callback URL Validation

The server validates that the redirect_uri matches configured URLs exactly.

ValidationDescription
Exact MatchRedirect URL must match configured URL exactly
ProtocolHTTPS required for production
PortNon-standard ports must be specified

Server-to-Server Security (M2M & Hosted UI)

  • Client secrets are encrypted at rest (AES-256)
  • Rotate secrets periodically from the Developer Portal — open the application's Credentials section and use the Rotate secret action
  • Use environment variables, never hardcode secrets
Secret Rotation

Regularly rotate client secrets from the portal. Update your applications with the new secret immediately after rotation, and revoke any leaked credentials.


Origin Whitelisting

ChainIT enforces origin whitelisting (CORS) for all browser-based integrations. Only origins you explicitly register in URL White Listing (CORS) can make API calls or host your OAuth flow.

App TypeEnforcementReference
IDPBrowser CORS on token/userinfo endpointsOrigin whitelisting guide
Hosted UIServer-side X-Origin header validation on SDK callsOrigin whitelisting guide

Always register every environment (production, staging, local) and never use a bare * wildcard.

Origin whitelisting is required

Configure at least one allowed origin when creating an IDP or Hosted UI application. See the full origin whitelisting guide for configuration rules and troubleshooting.


Mobile QR Face Handoff

When the desktop has no camera, Hosted UI can hand the face scan to a phone via a QR code. The QR returns to the same application page with a single-use code in the URL (?h=<code> by default, or your configured handoffParam), which the SDK detects automatically.

ControlDescription
Single-use codeThe handoff code is burned server-side on completion; a reused or stale code is rejected.
Origin-validated resolveResolving the code (/users/v1/hosted-auth/liveness/qr-session/resolve) validates X-Origin against your URL whitelist, so the handoff only works on allowlisted pages.
Ephemeral credentialsThe resolved request token stays in iframe memory only and is cleared on completion; the SDK strips the handoff param from the URL afterward.
The handoff query parameter is reserved

On pages wrapped by HostedAuthProvider, the handoff query parameter (h by default, or your configured handoffParam) is reserved for the mobile face handoff. Do not reuse it for your own routing, analytics, or feature flags — any value present on load makes the SDK render the handoff surface instead of your app. See the

mobile QR face handoff

section.


Further reading