Skip to main content

Security Policy Reference

Reference of the security policy and of each of its rules. A security policy is deployed as an Envoy Gateway SecurityPolicy.

Policy Target​

FieldValuesMeaning
targetRef.kindHTTPRoute, Gateway, GRPCRouteAn API instance, or a whole gateway
targetRef.nameNameThe API instance or the gateway
targetRef.sectionNameName, optionalOne access point of a gateway

JWT authentication​

Why. Authenticate applications without a session: each request carries a signed token that the gateway verifies locally, with the public keys of the issuer.

ParameterDefaultMeaning
sourceproviderauth-gateway: tokens issued by an auth gateway of the platform. provider: another issuer
authGateway.name, hostname, portport 443The auth gateway. Its address gives the issuer and the JWKS URL
providerName—A short name for an external issuer
issuer—Expected iss claim. Must match exactly
jwksUri—Where the signing keys are published
checkAudienceOffRefuse a token not issued for this API
apiAudience—The audience ID of the API. First value a token is checked against
audiences—Other accepted aud values

Consequences.

  • A request without a valid token receives 401; nobody is redirected.
  • Validity covers signature, issuer and expiry. Without checkAudience, a token issued for another API of the same issuer is accepted.
Turn the audience check on

An issuer shared by several APIs makes every token valid everywhere unless the audience is checked. Leave it off only while migrating clients.

Procedure: JWT authentication.

OIDC authentication​

Why. Sign people in from a browser: the gateway runs the authorization code flow with your identity provider and keeps a session cookie.

ParameterDefaultMeaning
issuerRequiredAddress of the identity provider
clientSecretNameRequiredStored Client Credentials: client ID and secret
clientIDFrom the stored credentialsOverrides the client ID
redirectURLRequiredCallback registered at the provider. HTTPS
logoutPath—Path that ends the session, such as /logout
cookieDomainHost of the API.example.com shares the session across subdomains
scopes—Scopes requested, such as openid, profile, email
jwksUri, jwksBackendName, jwksBackendPortport 443Signing keys, and a relay service when the URL is not directly reachable
authorizationEndpoint, tokenEndpointDiscoveredOverrides of the discovery document

Consequences.

  • An unauthenticated request is answered with a redirect, not 401: unsuitable for API clients that do not follow browser flows.
  • The redirect URL must match the provider registration character for character.

Procedure: OIDC authentication.

API key authentication​

Why. The simplest credential for a few known callers and for tools that cannot run OAuth.

ParameterDefaultMeaning
credentialSecretNameRequiredStored API Keys list
headerName—Header carrying the key, such as x-api-key
queryParamName—Query parameter carrying the key
cookieName—Cookie carrying the key
forwardClientIDHeader—Header in which the identity of the caller is passed to the backend
sanitizeOffRemove the key from the request before forwarding
Prefer the header, and sanitize

A key in a query parameter ends up in access logs and browser history. Carry it in a header and turn sanitize on so that the backend never sees it.

Consequences. A key does not expire and identifies an application, not a user: rotate by adding the new key, moving callers, then removing the old one.

Procedure: API key authentication.

HTTP Basic authentication​

Why. A user name and password checked by the gateway: supported by every HTTP client and every browser, with no identity provider to run. Suitable for internal tools and legacy callers.

ParameterDefaultMeaning
usersSecretNameRequiredStored Basic Auth Users: user names and hashed passwords
forwardUsernameHeader—Header in which the verified user name is passed to the backend

Consequences. Credentials travel with every request: use it on HTTPS access points only. A browser shows its native prompt.

Procedure: HTTP Basic authentication.

CORS Fields​

Why. Let pages served from another origin call the API from a browser.

ParameterDefaultMeaning
allowOrigins*Origins allowed, such as https://app.example.com
allowMethodsGET, POST, PUT, DELETE, OPTIONSMethods allowed
allowHeadersContent-Type, AuthorizationRequest headers allowed
exposeHeaders—Response headers the page may read
maxAge3600sHow long a browser caches the preflight answer
allowCredentialsOffAllow cookies and Authorization on cross-origin requests
Wildcard origin and credentials

Browsers refuse allowCredentials together with the origin *. List the origins explicitly when credentials are allowed.

Procedure: CORS.

IP allowlist and denylist​

Why. Restrict an API to known networks (your offices, a partner) or block addresses that misbehave. It is a coarse filter, best combined with authentication.

ParameterDefaultMeaning
defaultActionDenyWhat happens when no rule matches
rules[].actionAllowAllow or Deny
rules[].cidrs—Addresses or ranges in CIDR notation: 10.0.0.0/8, 203.0.113.42/32

Rules are evaluated in order; the first match wins. defaultAction: Deny with Allow rules is an allowlist; defaultAction: Allow with Deny rules is a denylist.

Which address is evaluated

The address is the one the gateway sees. Behind a proxy or a CDN, that is the address of the proxy unless the original address is preserved up to the gateway.

Procedure: IP allowlist and denylist.

External authorization​

Why. Decide with your own service: contract status, time of day, fraud score.

ParameterDefaultMeaning
protocolHTTPHTTP or GRPC
service.kindServiceService: a service of the platform. Backend: an upstream
service.nameRequiredThe service or the upstream
service.port80Port of a service. An upstream carries its own
failOpenOffLet requests through when the authorization service is unavailable

Consequences. Every request waits for the authorization service: its latency is added to every call, and its availability becomes that of the API.

failOpen removes the protection during an outage

With failOpen on, an unavailable authorization service means no check at all. Keep it off unless availability matters more than access control for that API.

Procedure: External authorization.