GetGatewayAuthDetail - 获取网关鉴权详情

获取网关鉴权详情。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。

  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。

  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:

    • 对于必选的资源类型,用前面加 * 表示。

    • 对于不支持资源级授权的操作,用全部资源表示。

  • 条件关键字:是指云产品自身定义的条件关键字。

  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。

操作

访问级别

资源类型

条件关键字

关联操作

mse:GetGatewayAuthDetail

get

*Gateway

acs:mse:{#regionId}:{#accountId}:instance/{#GatewayUniqueId}

请求参数

名称

类型

必填

描述

示例值

Id

integer

鉴权 ID

1100

GatewayId

integer

网关 ID(和网关唯一 ID 二选一)

2274

GatewayUniqueId

string

网关唯一 ID(和网关 ID 二选一,网关唯一 ID 不为空时优先使用网关唯一 ID 查询)

gw-6f0dbd108a0249d2b675b3ef50b*****

AcceptLanguage

string

返回结果显示的语言。取值:

  • zh(默认值):中文

  • en:英文

zh

返回参数

名称

类型

描述

示例值

object

Schema of Response

RequestId

string

请求 ID

9C96CDF8-9E6C-XXXX-XXXX-8F87A10117E6

HttpStatusCode

integer

HTTP 状态码。

200

Message

string

信息。

OK

Code

integer

用于和 Success 同步,当 Success 为 true 时,Code 为 200

200

Success

boolean

请求是否成功

true

Data

object

鉴权详情

Id

integer

鉴权 ID

1100

Name

string

鉴权名称

test

GatewayUniqueId

string

鉴权所属网关的唯一 ID

gw-6f0dbd108a0249d2b675b3ef50b*****

GatewayId

integer

鉴权所属网关的 ID

2274

Type

string

鉴权类型:

  • JWT

  • OIDC

  • IDaaS

  • ExternalAuthZ(自建的鉴权服务)

JWT

Issuer

string

鉴权类型为 JWT/OIDC 时使用:

  • JWT:表示 JWT claims 的 iss(issuer),即签发人。

  • OIDC:表示 OIDC claims 的 iss(issuer),即签发人

https://example.com/auth

Jwks

string

JWT 公钥,JSON 格式

{\n \"keys\":[\n {\n \"kty\": \"RSA\",\n \"e\": \"AQAB\",\n \"use\": \"sig\",\n \"kid\": \"1rGufmH1YN8rqM9ZOLgo7eEST3AnL89Y-m-XGFioLoA\",\n \"alg\": \"RS256\",\n \"n\": \"rM2GIc0YTMqwNCwXnjKbW5QndkCEZgyLu3uQUnyZF7HvMTekiTvQg_39mg3dV1eaYYkYfZBogyroJBqAQXhk6VVCxlBjFVp2xstJPVWngMOOlcafwN_BKdN-EQ06O_Uu__e7gNKI3DunkNk0cNaFETE7d4meRYyTlgEzYgsrW05_ufR0BKoddL3E5JsCpUxRjH9ICbodBx0U74W6Dcci-R2EA1DBrEcboE6n90uoJs6UJNriAK_71nAsYonihU5aQFFnyPTkJHfRwHK6JlME6rn-b-rpLSpdyc6U1nOFZP2DEpz8U5FrYoLYSZIU-MQGxDhCnGc_rxl2IyP9B2qcCQ\"\n }\n ]\n}\n

IsWhite

boolean

授权黑白名单模式:

  • true:白名单模式(名单中的 hosts + paths 不需要校验即可访问,其余都需要校验)

  • false:黑名单模式(名单中的 hosts + paths 需要校验,其余可直接访问)

true

GmtCreate

string

鉴权创建的 GMT 时间

2024-02-19T02:41:03.000+0000

GmtModified

string

鉴权修改的 GMT 时间

2024-02-19T02:41:03.000+0000

TokenPosition

string

JWT Token 类型:

  • HEADER:通过 Header 传输

HEADER

TokenName

string

JWT Token 保存的位置

Authorization

TokenNamePrefix

string

JWT Token 的前缀

Bearer

TokenPass

boolean

是否透传 Token

true

Status

boolean

鉴权是否开启

false

RedirectUrl

string

授权成功后的重定向地址(OIDC/IDaaS 使用,需要与 OIDC/IDaaS 中配置的重定向地址保持一致。)

https://yourdomain/path

ClientId

string

服务注册的应用 ID(OIDC/IDaaS 使用)。

example-app

ClientSecret

string

服务注册的应用 Secret(OIDC/IDaaS 使用)。

xxxxx

CookieDomain

string

Cookie 的域名,认证通过后会将 Cookie 发送到指定的域名,保持登录状态(OIDC/IDaaS 使用)。

hello.com

ScopesList

string

OIDC 作用域(OIDC 使用)。

["openid","email"]

LoginUrl

string

IDaaS 实例用户登录页地址(IDaaS 使用)。

https://daxxxxcn.aliyunidaas.com/

Sub

string

鉴权类型为 JWT 时使用;JWT claims 的 sub(subject),即主体。

https://example.com/auth

ExternalAuthZ

object

自定义鉴权信息

ServiceId

integer

鉴权服务 ID

15300

PrefixPath

string

鉴权 API 的 Path

/auth

TokenKey

string

Token 位置,表示 Token 位于请求报文中哪个 Header 中,常见的有 Authorization 和 Cookie

Authorization

AllowRequestHeaders

array

允许的请求头部

string

允许的请求头名称。

x-req

AllowUpstreamHeaders

array

允许的响应头部

string

允许的响应头名称。

x-resp

Timeout

integer

鉴权服务的超时时间,单位:秒

10

IsRestrict

boolean

自定义鉴权模式:

  • true:严格模式,当鉴权服务不可用时(鉴权服务建立连接失败或者返回 5xx 请求),网关拒绝客户端请求

  • false:宽松模式,当鉴权服务不可用时(鉴权服务建立连接失败或者返回 5xx 请求),网关放过客户端请求

true

Service

object

鉴权服务信息

Name

string

鉴权服务名称

httpbin-auth-service

SourceType

string

鉴权服务来源类型

K8s

GroupName

string

鉴权服务所属的分组

test

Namespace

string

鉴权服务命名空间

default

WithRequestBody

boolean

是否允许携带 Body

true

BodyMaxBytes

integer

Body 的最大字节数

4000000

WithRematchRoute

boolean

ResourceList

array

鉴权的授权规则列表,多个规则条件之间是“或”关系,规则条件内的多个匹配项之间是“与”关系。

object

鉴权的授权规则。

Id

integer

授权规则 ID

1303

AuthId

integer

规则所归属鉴权的 ID

2274

DomainId

integer

规则内域名的 ID

1765

DomainName

string

规则内的域名

example.com

Path

string

规则的匹配路径

/test

IsWhite

boolean

授权黑白名单模式:

  • true:白名单模式(名单中的 hosts + paths 不需要校验即可访问,其余都需要校验)

  • false:黑名单模式(名单中的 hosts + paths 需要校验,其余可直接访问)

true

GatewayId

integer

规则所属网关的 ID

2274

GatewayUniqueId

string

规则所属网关的唯一 ID

gw-6f0dbd108a0249d2b675b3ef50b*****

GmtCreate

string

授权规则的创建 GMT 时间

2024-02-19T03:32:38.000+0000

GmtModified

string

授权规则的修改 GMT 时间

2024-02-19T03:32:38.000+0000

MatchType

string

请求 Path 的匹配类型:

  • EQUAL:精确匹配

  • PRE:前缀匹配

  • ERGULAR:正则匹配

EQUAL

IgnoreCase

boolean

路径是否开启大小写敏感

  • true:开启大小写敏感

  • false:关闭大小写敏感

true

AuthResourceHeaderList

array

规则的请求头(当前仅供自定义鉴权使用)

object

HeaderKey

string

请求头名称

x-req

HeaderMethod

string

匹配条件:

  • EQUAL:等于

  • NOT_EQUAL:不等于

  • EXIST:存在

  • NOT_EXIST:不存在

  • INCLUDE:包含

  • EXCLUDE:不包含

  • PREFIX:前缀

  • SUFFIX:后缀

  • REGREX:正则

EQUAL

HeaderValue

string

请求头的值

123

AuthResourceMode

integer

授权资源模式:

  • 0:简单模式

  • 1:复杂模式

0

AuthResourceConfig

string

复杂模式的 YAML 配置

permissions: - not_rule: or_rules: rules: - and_rules: rules: - url_path: path: ignore_case: false prefix: /version - and_rules: rules: - url_path: path: ignore_case: false prefix: /header

示例

正常返回示例

JSON格式

{
  "RequestId": "9C96CDF8-9E6C-XXXX-XXXX-8F87A10117E6",
  "HttpStatusCode": 200,
  "Message": "OK",
  "Code": 200,
  "Success": true,
  "Data": {
    "Id": 1100,
    "Name": "test",
    "GatewayUniqueId": "gw-6f0dbd108a0249d2b675b3ef50b*****",
    "GatewayId": 2274,
    "Type": "JWT",
    "Issuer": "https://example.com/auth",
    "Jwks": "{\\n  \\\"keys\\\":[\\n    {\\n      \\\"kty\\\": \\\"RSA\\\",\\n      \\\"e\\\": \\\"AQAB\\\",\\n      \\\"use\\\": \\\"sig\\\",\\n      \\\"kid\\\": \\\"1rGufmH1YN8rqM9ZOLgo7eEST3AnL89Y-m-XGFioLoA\\\",\\n      \\\"alg\\\": \\\"RS256\\\",\\n      \\\"n\\\": \\\"rM2GIc0YTMqwNCwXnjKbW5QndkCEZgyLu3uQUnyZF7HvMTekiTvQg_39mg3dV1eaYYkYfZBogyroJBqAQXhk6VVCxlBjFVp2xstJPVWngMOOlcafwN_BKdN-EQ06O_Uu__e7gNKI3DunkNk0cNaFETE7d4meRYyTlgEzYgsrW05_ufR0BKoddL3E5JsCpUxRjH9ICbodBx0U74W6Dcci-R2EA1DBrEcboE6n90uoJs6UJNriAK_71nAsYonihU5aQFFnyPTkJHfRwHK6JlME6rn-b-rpLSpdyc6U1nOFZP2DEpz8U5FrYoLYSZIU-MQGxDhCnGc_rxl2IyP9B2qcCQ\\\"\\n    }\\n  ]\\n}\\n",
    "IsWhite": true,
    "GmtCreate": "2024-02-19T02:41:03.000+0000",
    "GmtModified": "2024-02-19T02:41:03.000+0000",
    "TokenPosition": "HEADER",
    "TokenName": "Authorization",
    "TokenNamePrefix": "Bearer ",
    "TokenPass": true,
    "Status": false,
    "RedirectUrl": "https://yourdomain/path",
    "ClientId": "example-app",
    "ClientSecret": "xxxxx",
    "CookieDomain": "hello.com",
    "ScopesList": "[\"openid\",\"email\"]",
    "LoginUrl": "https://daxxxxcn.aliyunidaas.com/",
    "Sub": "https://example.com/auth",
    "ExternalAuthZ": {
      "ServiceId": 15300,
      "PrefixPath": "/auth",
      "TokenKey": "Authorization",
      "AllowRequestHeaders": [
        "x-req"
      ],
      "AllowUpstreamHeaders": [
        "x-resp"
      ],
      "Timeout": 10,
      "IsRestrict": true,
      "Service": {
        "Name": " httpbin-auth-service",
        "SourceType": "K8s",
        "GroupName": "test",
        "Namespace": "default"
      },
      "WithRequestBody": true,
      "BodyMaxBytes": 4000000,
      "WithRematchRoute": true
    },
    "ResourceList": [
      {
        "Id": 1303,
        "AuthId": 2274,
        "DomainId": 1765,
        "DomainName": "example.com",
        "Path": "/test",
        "IsWhite": true,
        "GatewayId": 2274,
        "GatewayUniqueId": "gw-6f0dbd108a0249d2b675b3ef50b*****",
        "GmtCreate": "2024-02-19T03:32:38.000+0000",
        "GmtModified": "2024-02-19T03:32:38.000+0000",
        "MatchType": "EQUAL",
        "IgnoreCase": true,
        "AuthResourceHeaderList": [
          {
            "HeaderKey": "x-req",
            "HeaderMethod": "EQUAL",
            "HeaderValue": "123"
          }
        ]
      }
    ],
    "AuthResourceMode": 0,
    "AuthResourceConfig": "permissions:\n  - not_rule:\n      or_rules:\n        rules:\n        - and_rules:\n            rules:\n            - url_path:\n                path:\n                  ignore_case: false\n                  prefix: /version\n        - and_rules:\n            rules:\n            - url_path:\n                path:\n                  ignore_case: false\n                  prefix: /header"
  }
}

错误码

HTTP status code

错误码

错误信息

描述

400 IllegalRequest Invalid request:%s 非法请求: %s
400 InvalidParameter Parameter error:%s 请求参数错误:%s
500 InternalError Console error. Try again later:%s 控制台错误.稍后重试:%s
403 NoPermission You are not authorized to perform this operation:%s 没有权限使用此接口:%s
404 NotFound Not found:%s 资源不存在:%s

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情