OAuth2Authorizer - Amazon Serverless Application Model
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

OAuth2Authorizer

OAuth 2.0 授权方的定义,也称为 JSON Web 令牌(JWT)授权方。

有关更多信息,请参阅《API Gateway 开发人员指南》中的使用 JWT 授权方控制对 HTTP API 的访问

语法

要在您的 Amazon Serverless Application Model (Amazon SAM) 模板中声明此实体,请使用以下语法。

属性

AuthorizationScopes

此授权方的授权范围列表。

类型:列表

必需:否

Amazon CloudFormation 兼容性:此属性为 Amazon SAM 独有,没有 Amazon CloudFormation 等效属性。

IdentitySource

此授权方的身份源表达式。

类型:字符串

必需:否

Amazon CloudFormation 兼容性:此属性为 Amazon SAM 独有,没有 Amazon CloudFormation 等效属性。

JwtConfiguration

此授权方的 JWT 配置。

这会传递到 OpenAPI 定义的 securitySchemes 部分中 x-amazon-apigateway-authorizerjwtConfiguration 部分。

注意

issuer性和audience不区分大小写,可以像在 OpenAPI 中那样使用小写字母,也可以使用大写字母Issuer和。Audience AWS::ApiGatewayV2::Authorizer

类型:映射

必需:否

Amazon CloudFormation 兼容性:此属性为 Amazon SAM 独有,没有 Amazon CloudFormation 等效属性。

示例

OAuth 2.0 授权方

OAuth 2.0 授权方示例

YAML

Auth: Authorizers: OAuth2Authorizer: AuthorizationScopes: - scope1 JwtConfiguration: issuer: "https://www.example.com/v1/connect/oauth2" audience: - MyApi IdentitySource: "$request.querystring.param" DefaultAuthorizer: OAuth2Authorizer