AuthPlugin
使用 API 金鑰或 OAuth2 模擬驗證和授權。
外掛程式實例定義
{
"name": "AuthPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll",
"configSection": "auth"
}
設定範例:API 金鑰
{
"auth": {
"type": "apiKey",
"apiKey": {
"parameters": [
{
"in": "header",
"name": "x-api-key"
},
{
"in": "query",
"name": "code"
}
],
"allowedKeys": [
"1234"
]
}
}
}
組態範例:OAuth2
{
"auth": {
"type": "oauth2",
"oauth2": {
"metadataUrl": "https://login.microsoftonline.com/organizations/v2.0/.well-known/openid-configuration",
"allowedApplications": [
"00000000-0000-0000-0000-000000000000"
],
"allowedAudiences": [
"00000000-0000-0000-0000-000000000000"
],
"allowedPrincipals": [
"00000000-0000-0000-0000-000000000000"
],
"allowedTenants":[
"00000000-0000-0000-0000-000000000000"
],
"issuer": "https://login.microsoftonline.com/ffffffff-eeee-dddd-cccc-bbbbbbbbbbb0/v2.0",
"scopes": [
"Posts.Read"
],
"validateLifetime": true,
"validateSigningKey": true
}
}
}
設定屬性
屬性 |
描述 |
必要 |
type |
開發 Proxy 應該使用的驗證和授權類型。 允許值︰apiKey 和 oauth2 |
Yes |
apiKey |
API 金鑰驗證和授權的設定。 |
是,當 type 為 apiKey |
oauth2 |
OAuth2 驗證和授權的設定。 |
是,當 type 為 oauth2 |
API 金鑰組態屬性
屬性 |
描述 |
必要 |
allowedKeys |
允許的 API 金鑰清單。 |
Yes |
parameters |
包含 API 金鑰的參數清單。 |
Yes |
參陣組態屬性
屬性 |
描述 |
必要 |
in |
預期會找到 參數的位置。 允許的值:header 、、 query cookie |
Yes |
name |
參數的名稱。 |
Yes |
OAuth2 組態屬性
屬性 |
描述 |
必要 |
metadataUrl |
OpenID Connect 元數據檔的 URL。 |
Yes |
allowedApplications |
允許的應用程式識別碼清單。 保留空白,以不驗證發出令牌的應用程式(appid 或 azp 宣告)。 |
No |
allowedAudiences |
允許的物件清單。 保留空白,以不驗證發出令牌的物件(aud 宣告)。 |
No |
allowedPrincipals |
允許的主體清單。 保留空白,以不驗證發出令牌的主體(oid 宣告)。 |
No |
allowedTenants |
允許的租用戶清單。 保留空白,以不驗證發出令牌的租使用者(tid 宣告)。 |
No |
issuer |
允許的令牌簽發者。 保留空白,以不驗證令牌簽發者。 |
No |
roles |
允許的角色清單。 保留空白,以不驗證令牌上的角色(roles 宣告)。 |
No |
scopes |
允許的範圍清單。 保留空白,以不驗證令牌上的範圍(scp 宣告)。 |
No |
validateLifetime |
設定為 以 false 停用驗證令牌存留期。 預設 true 。 |
No |
validateSigningKey |
設定為 以 false 停用驗證令牌簽章。 違約 true |
No |
命令列選項
無