Skip to content

Identity Guard

Identity Guard is Apiway’s layered security model. It goes beyond simple authentication to verify who is calling, what they’re allowed to access, and whether their subscription entitles them to the requested operation.

Before any request is processed, the gateway verifies the caller’s identity:

  • JWT validation — Signature, expiry, issuer, audience
  • Subscription check — Does this credential belong to an active subscription?
  • Tenant verification — Is the calling organisation registered and in good standing?

Invalid or expired credentials are rejected immediately. No backend resources are consumed.

Not every authenticated user should see everything. Identity filtering controls access based on context:

  • Scopes — The JWT carries only the scopes the subscription entitles. Each operation requires specific scopes.
  • Roles — Roles are bundles of scopes. A payments-reader role grants read operations; payments-admin grants write operations too.
  • Subscription tier — Different SLA tiers can entitle different operations. A Free tier might exclude bulk export endpoints.

The finest-grained control — per-operation entitlement enforcement:

  • The gateway reads the SecurityCheckPolicyElement on each operation
  • Compares the JWT’s scopes against the operation’s required scopes
  • Returns 403 if the caller lacks the required entitlement
  • No database lookup at request time — everything is in the JWT

All three layers execute in the gateway’s SecurityStage — a single pipeline step that runs before any backend call:

CheckFailure Response
Invalid/expired token401 Unauthorized
Missing required scope403 Forbidden
Subscription inactive401 Unauthorized

Enforcement is sub-millisecond. The gateway reads the JWT, checks scopes locally, and proceeds or rejects. No network calls, no database queries.

Apiway integrates with external IdPs for user authentication:

ProviderIntegration
Azure AD B2CNative integration via admin-service
ClerkSupported via gateway’s open-id-jwt-auth-inbound policy
Any OIDC providerStandard OpenID Connect discovery + JWKS validation

You can configure different IdPs per environment — e.g., Clerk for the developer portal, Azure AD for internal users.

Credentials are managed per subscription:

  • Provisioned automatically when a subscription is approved
  • Rotation — Generate new credentials without downtime; revoke old ones after migration
  • Expiry tracking — Apiway monitors credential age and notifies consumers when rotation is recommended
  • Gateway injection — For consumed external APIs, the gateway injects the provider’s credentials automatically

Identity Guard isn’t just security — it protects revenue. Every request that bypasses authentication is an unmetered request:

  • No authentication → no RU tracking → no billing
  • Identity Guard ensures every request is tied to a subscription
  • Unmetered consumption is impossible — the gateway rejects before the backend is reached