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

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

HttpApiAuth

配置授权,以控制对 Amazon API Gateway HTTP API 的访问。

有关配置对 HTTP API 的访问权限的更多信息,请参阅《API Gateway 开发人员指南》中的控制和管理对 API Gateway 中 HTTP API 的访问

语法

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

属性

Authorizers

用于控制对 API Gateway API 的访问的授权方。

类型oauth2Authorizer | LambdaAuthorizer

必需:否

默认值:无

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

附加说明:Amazon SAM 会将授权方添加到 OpenAPI 定义中。

DefaultAuthorizer

指定默认授权方,以用于授权对 API Gateway API 的 API 调用。如果 EnableIamAuthorizer 设置为 true,您可以指定 AWS_IAM 作为默认授权方。否则,请指定您在 Authorizers 中定义的授权方。

类型:字符串

必需:否

默认值:无

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

EnableIamAuthorizer

指定是否要对 API 路由使用 IAM 授权。

类型:布尔值

必需:否

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

示例

OAuth 2.0 授权方

OAuth 2.0 授权方示例

YAML

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

IAM 授权方

IAM 授权方示例

YAML

Auth: EnableIamAuthorizer: true DefaultAuthorizer: AWS_IAM