3. Security and Validation

expressionExtractor

Version

Deprecated: Set the expression directly on the apiKey plugin.
Extracts an API key by evaluating an expression on the incoming request. The result (a string) is treated as the API key. The expression is evaluated in the configured language (default: SPEL) during the request flow.

Typical usage inside <apiKey> If the expression evaluates to null or an empty string, no key is extracted.

apiKey:
extractors:
- expressionExtractor:
language: SPEL
expression: request.headers['X-Api-Key']
apiKey:
   extractors:
     - expressionExtractor:
         language: SPEL
         expression: request.headers['X-Api-Key']

Syntax

expressionExtractor:
'$ref': <string>
expression: <string>
language: groovy
xmlConfig: {}
expressionExtractor:
  '$ref': <string>
  expression: <string>
  language: groovy
  xmlConfig: {}

Attributes

NameRequiredDefaultDescriptionExamples
$reffalse-Reference a component defined under components.-
expressionfalse-The expression evaluated against the message. It must resolve to a String containing the API key. Empty or null results mean “no key found”.

Examples (SPEL):

expression="request.headers['X-Api-Key']"
  expression="request.query['api_key']"
-
languagefalse---

Child Structure

ElementCardinalityDescription
xmlConfig0..1

Can be used in