ApiKeyAuthConfig
Defined in: packages/gateway/src/policies/auth/api-key-auth.ts:15
Configuration for the apiKeyAuth policy.
Extends
Section titled “Extends”Properties
Section titled “Properties”forwardKeyIdentity?
Section titled “forwardKeyIdentity?”
optionalforwardKeyIdentity?: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
Section titled “headerName”headerName:
string
Header name to set on the request.
identityFn
Section titled “identityFn”identityFn: (
key) =>string|Promise<string>
Derive an identity string from the validated key. Can be async.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”string | Promise<string>
Example
Section titled “Example”apiKeyAuth({ validate: (key) => keys.has(key), forwardKeyIdentity: { headerName: "x-api-client", identityFn: (key) => keyToClientMap.get(key) ?? "unknown", },});headerName?
Section titled “headerName?”
optionalheaderName?: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”
queryParam?
Section titled “queryParam?”
optionalqueryParam?:string
Defined in: packages/gateway/src/policies/auth/api-key-auth.ts:19
Query parameter name as fallback. Default: undefined (disabled)
optionalskip?: (c) =>boolean|Promise<boolean>
Defined in: packages/gateway/src/policies/types.ts:90
Skip this policy when condition returns true
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean | Promise<boolean>
Inherited from
Section titled “Inherited from”validate
Section titled “validate”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
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean | Promise<boolean>