Authentication at a glance¶
ConceptExplains how it works and why.
Three kinds of party prove who they are around a gateway: the callers of your APIs, the gateway itself towards your backends, and the people who sign in to the console. Each has its own mechanisms; this page lists them side by side and links to the guide for each.
Which one should I use¶
| Situation | Use |
|---|---|
| A partner's server or an internal job calls your API | An API key (api-key), limited to the partner's addresses with allowed sources |
| An application should hold short-lived tokens, not a long-lived key: a mobile app, a partner's backend | Apinx access tokens (oauth2): client credentials, then refresh tokens |
| Your users sign in with your identity provider (Keycloak, Entra ID, Okta, Auth0, …) | jwt, which verifies the provider's tokens |
| Employees signed in with your provider and partner apps on one API | jwt and oauth2 bound together |
| Moving an application from keys to tokens | api-key and oauth2 bound together, then remove api-key |
| An internal tool or a legacy client that only speaks Basic | basic |
| Selling access with plans and quotas | Products and plans, over api-key or oauth2 |
| Only some networks may call at all | ip-filter, or allowed sources on the application |
| The backend wants a token of its own | upstream-auth |
| The backend should receive only what you list | forward |
| Your staff sign in to the console with the company directory | OpenID Connect sign-in, under Admin › Sign-in (on premises) |
Callers of your APIs¶
An authentication policy is bound like any other policy: on an API, an operation, a shared flow or the environment's defaults. An operation that no authentication policy reaches is public, unless its API belongs to a product.
| Credential | Policy | Issued by | Guide |
|---|---|---|---|
| API key | api-key |
Apinx, under Consumers: shown once, kept as a hash, rotated with an overlap, revoked from the next request | Consumers and API keys |
| Apinx access token | oauth2 |
Apinx's token endpoint (/oauth2/token), to an application presenting its client ID and secret; refresh tokens keep an install signed in, and each one works once |
Apinx-issued access tokens |
| JWT from your identity provider | jwt |
Any OpenID Connect or OAuth 2 provider; the keys are found from the issuer and cached, so the provider is not called per request | Authenticating callers with JWT |
| HTTP Basic | basic |
A fixed list of users in the policy, passwords kept as argon2id hashes | Policy reference |
An API key and an Apinx access token identify an application: the application is the
caller's identity for rate limits, quotas, products and plans, analytics and the backend. A JWT
identifies its subject. Products and plans need an application, so an API in a product needs
api-key or oauth2.
Several at once. Authentication policies bound together are alternatives: a request needs one
credential that one of them accepts. A credential addressed to one policy is judged by that
policy alone, so a wrong key is refused at once even when a token would also be accepted; a
request with no credential gets 401 APX-PL-0001 with a WWW-Authenticate challenge for every
way in.
policies:
- type: api-key # the app version still in the stores
- type: oauth2 # the new version, with tokens
Under a flow hook. Authentication a flow hook brings
is enforced on every API, so it is never one of an API's alternatives. The hook's
authentication policies are alternatives among themselves; the ones an API or an operation binds
are alternatives among themselves; a request needs one credential for each side. With a hooked
jwt and an API's own api-key, a request carries the token and the key: the key alone, or the
token alone, is answered 401 with the challenge of the side that is missing.
Narrowing who may call. Each of these adds to authentication rather than replacing it:
required_scopesandrequired_claimsonjwt,required_scopesonoauth2: 403APX-PL-0003names what is missing.allow_applicationsonapi-keyandoauth2: only the applications listed.- Allowed sources on an application or one of its keys: calls from elsewhere get 403
APX-PL-0023. ip-filter: allow and deny lists of addresses and ranges, for any caller.- On premises, an HTTPS listener can require a client certificate signed by your authority
(
tls.client_auth: requirewithclient_ca_file); see the gateway configuration.
What the backend receives. The credential is removed before forwarding (strip: true), and
the gateway adds who called: X-Apinx-Application and X-Apinx-Application-Id for an
application, X-Apinx-Subject for a token's subject or a Basic user, and X-Apinx-Auth with the
policy that accepted the call. The same headers sent by a client are dropped first, so a backend
can trust them.
Your backends¶
| The backend wants | Use | Guide |
|---|---|---|
| A token from its own identity provider | upstream-auth: the gateway obtains it with OAuth 2 client credentials or a service account's password (the password grant, or the backend's own login endpoint), caches it until shortly before it expires, renews it with a refresh token when one is given, and sends it on every request |
Authenticating to a backend |
| To know which user is calling | upstream-auth headers with ${claim.<name>} from the caller's validated token |
Authenticating to a backend |
| A client certificate | The upstream's tls.client_cert_file and client_key_file, on premises |
Gateway configuration |
| Only the headers and query parameters it needs | forward, an allow-list of what the client's request may carry |
Zero-trust forwarding |
The backend's credentials are stored encrypted with your master key, never reach a caller, and
are absent from exports, the audit and traces. When the token endpoint cannot be reached and no
valid token is cached, the request fails closed with 502 APX-PL-0026.
People who sign in to the console¶
On premises¶
- Accounts and roles. Administrators manage everything; editors change configuration but not users, security, sign-in or flow hooks; viewers read. Admin › Users adds, edits, disables and resets; a disabled user's sessions end at once.
- Passwords are kept as argon2id hashes. Five failed sign-ins lock the account for fifteen
minutes (
APX-CP-0015); ten failures from one client address within fifteen minutes, across any accounts, answer429 APX-CP-0028until the window ends. - Sessions end after an hour without activity (
console.session_idle_timeout) and after twelve hours whatever happens (console.session_ttl). Changing your password ends your other sessions. - Single sign-on. Admin › Sign-in connects your OpenID Connect provider (Authorization
Code with PKCE): roles mapped from a claim (
groupsby default), a default role for users no mapping matches, allowed e-mail domains, accounts created at first sign-in, and Test connection before saving. Local passwords can stay on for everyone or be kept for one break-glass administrator. - Scripts and CI sign in at
POST /api/v1/auth/loginfor a bearer token, or withapinxctl login(Admin API).
Apinx Cloud¶
Each person has an account with an e-mail address and a password; the address is confirmed before the first sign-in. After the right password, the console asks for a 6-digit code sent by e-mail, which works once for ten minutes; Remember this browser skips the code on that browser for 30 days, and Preferences forgets every remembered browser. Failed sign-ins are throttled per client address as on premises. Sign-in is the platform's, so there is no Sign-in tab; inside each organization the roles work as on premises, and the organization's owner adds and removes its environments.
A session stays in the browser and on the network that signed in. Another browser ends it. A new network, and a few risky actions (people, keys and secrets, data leaving Apinx, deletions), ask for the emailed code again. Preferences › Your sessions lists every session with a way to sign out the others. See Console sessions in Apinx Cloud.
Security lists every control in one place.