Skip to content

ApiKeyAuthConfig

Defined in: packages/gateway/src/policies/auth/api-key-auth.ts:15

Configuration for the apiKeyAuth policy.

optional forwardKeyIdentity?: object

Defined in: packages/gateway/src/policies/auth/api-key-auth.ts:37

After successful validation, derive an identity string from the key and set it as a request header for upstream consumption.

headerName: string

Header name to set on the request.

identityFn: (key) => string | Promise<string>

Derive an identity string from the validated key. Can be async.

string

string | Promise<string>

apiKeyAuth({
validate: (key) => keys.has(key),
forwardKeyIdentity: {
headerName: "x-api-client",
identityFn: (key) => keyToClientMap.get(key) ?? "unknown",
},
});

optional headerName?: string

Defined in: packages/gateway/src/policies/auth/api-key-auth.ts:17

Header name to read the API key from. Default: “X-API-Key”


optional queryParam?: string

Defined in: packages/gateway/src/policies/auth/api-key-auth.ts:19

Query parameter name as fallback. Default: undefined (disabled)


optional skip?: (c) => boolean | Promise<boolean>

Defined in: packages/gateway/src/policies/types.ts:90

Skip this policy when condition returns true

unknown

boolean | Promise<boolean>

PolicyConfig.skip


validate: (key) => boolean | Promise<boolean>

Defined in: packages/gateway/src/policies/auth/api-key-auth.ts:21

Validator function - return true if the key is valid

string

boolean | Promise<boolean>