x-amazon-apigateway-authtype 財產 - Amazon API Gateway

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

x-amazon-apigateway-authtype 財產

對於 REST API,此延伸可用於定義 Lambda 授權方的自訂類型。在這種情況下,值為任意格式。例如,一個 API 可能有多個 Lambda 授權方使用不同的內部結構描述。您可以使用此延伸來識別 Lambda 授權方的內部結構描述。

更常見的情況是,在 HTTP API 和 REST API 中,也可用於定義共享相同安全性結構描述的多個作業之間的 IAM 授權。在這種情況下,術語 awsSigv4 是保留字詞,以及任何前綴為 aws 的任何術語。

此延伸適用於 OpenAPI 2OpenAPI 3 中的 apiKey 類型安全性結構描述。

x-amazon-apigateway-authtype 例子

下列 OpenAPI 3 範例定義了 REST API 或 HTTP API 中多個資源之間的 IAM 授權︰

{ "openapi" : "3.0.1", "info" : { "title" : "openapi3", "version" : "1.0" }, "paths" : { "/operation1" : { "get" : { "responses" : { "default" : { "description" : "Default response" } }, "security" : [ { "sigv4Reference" : [ ] } ] } }, "/operation2" : { "get" : { "responses" : { "default" : { "description" : "Default response" } }, "security" : [ { "sigv4Reference" : [ ] } ] } } }, "components" : { "securitySchemes" : { "sigv4Reference" : { "type" : "apiKey", "name" : "Authorization", "in" : "header", "x-amazon-apigateway-authtype": "awsSigv4" } } } }

下列 OpenAPI 3 範例會使用 REST API 的自訂結構描述來定義 Lambda 授權方︰

{ "openapi" : "3.0.1", "info" : { "title" : "openapi3 for REST API", "version" : "1.0" }, "paths" : { "/protected-by-lambda-authorizer" : { "get" : { "responses" : { "200" : { "description" : "Default response" } }, "security" : [ { "myAuthorizer" : [ ] } ] } } }, "components" : { "securitySchemes" : { "myAuthorizer" : { "type" : "apiKey", "name" : "Authorization", "in" : "header", "x-amazon-apigateway-authorizer" : { "identitySource" : "method.request.header.Authorization", "authorizerUri" : "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:account-id:function:function-name/invocations", "authorizerResultTtlInSeconds" : 300, "type" : "request", "enableSimpleResponses" : false }, "x-amazon-apigateway-authtype": "Custom scheme with corporate claims" } } }, "x-amazon-apigateway-importexport-version" : "1.0" }

另請參閱

authorizer.authType