Reference a key

更新时间:
复制 MD 格式

Keys replace plaintext credentials in consumers and plugins, preventing credential leaks.

Prerequisites

A key is available. If not, Create a key.

Important

Key references require official plugins version 2.1.10+ and custom plugins version 2.1.11+.

Reference a key in a consumer

  1. Log on to the Cloud-native API Gateway console, select a region, and click Consumers in the left-side navigation pane.

  2. Click Create Consumer. Enter a name, set Authentication Method to API Key, set Generation Method to Reference Key, and select a key under Attach Key.

    Note

    Only API key authentication supports key references for consumer credentials.

Reference a key in a plugin

Use the $ref{secretName} syntax in plugin configurations, where secretName is the key name. Example Key-Auth configuration:

credentials: 
# Reference the key named secretName
- $ref{secretName}
keys:
- apikey
- x-api-key

The secretName key grants access to the cloud-native gateway. Both official and custom plugins support key references.

View key reference details

In the Cloud-native API Gateway console, click Key in the left-side navigation pane. In the Referenced By column, click the reference count to view associated resources.