API Key认证组件

更新时间:
复制为 MD 格式

API Key认证组件实现了基于API Key进行认证鉴权的功能。支持从HTTP请求的URL参数、请求头或Cookie中提取API Key,并将提取到的Key与预配置的凭证列表进行比对,验证其是否有权限访问。

功能类型

认证鉴权

字段说明

ComponentConfig

参数

类型

是否必填

默认值

描述

Config

ApiKeyConfig

-

API Key认证配置。

ApiKeyConfig

参数

类型

是否必填

默认值

描述

ApiKeySources

ApiKeySourcesConfig

-

从请求中提取API Key的方式,仅支持单一提取源。

ApiKeyCredentials

ApiKeyCredential[]

-

受信任API Key凭证列表。

ApiKeySourcesConfig

参数

类型

是否必填

默认值

描述

Headers

String[]

-

HTTP请求头中提取API Key。

Params

String[]

-

URL参数中提取API Key。

Cookies

String[]

-

Cookie中提取API Key。

ApiKeyCredential

参数

类型

是否必填

默认值

描述

Provider

ApiKeyCredentialProvider

System

凭证类型。

Credential

String

条件必填

-

凭证值,即API Key字符串。
ProviderCustom时必填,长度限制 8-512 字符。

ApiKeyCredentialProvider

描述

System

系统自动生成的凭证。

Custom

用户上传的凭证。

错误码信息

HTTP状态码

出错信息

原因说明

401

Client authentication failed.

API Key验证失败,包含Key错误或未提供API Key的情况。