

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

# CognitoAuthorizer
<a name="sam-property-api-cognitoauthorizer"></a>

定义 Amazon Cognito 用户群体授权方。

有关更多信息以及示例，请参阅 [使用您的 AWS SAM 模板控制 API 访问权限](serverless-controlling-access-to-apis.md)。

## 语法
<a name="sam-property-api-cognitoauthorizer-syntax"></a>

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

### YAML
<a name="sam-property-api-cognitoauthorizer-syntax.yaml"></a>

```
  [AuthorizationScopes](#sam-api-cognitoauthorizer-authorizationscopes): List
  [Identity](#sam-api-cognitoauthorizer-identity): CognitoAuthorizationIdentity
  [UserPoolArn](#sam-api-cognitoauthorizer-userpoolarn): String
```

## Properties
<a name="sam-property-api-cognitoauthorizer-properties"></a>

 `AuthorizationScopes`   <a name="sam-api-cognitoauthorizer-authorizationscopes"></a>
此授权方的授权范围列表。  
*类型*：列表  
*必需*：否  
*CloudFormation 兼容性*：此属性是独有的 AWS SAM ，没有 CloudFormation 等效属性。

 `Identity`   <a name="sam-api-cognitoauthorizer-identity"></a>
此属性可用于在授权方传入请求中指定 `IdentitySource`。  
*类型*：[CognitoAuthorizationIdentity](sam-property-api-cognitoauthorizationidentity.md)  
*必需*：否  
*CloudFormation 兼容性*：此属性是独有的 AWS SAM ，没有 CloudFormation 等效属性。

 `UserPoolArn`   <a name="sam-api-cognitoauthorizer-userpoolarn"></a>
可以指用户 pool/specify 一个你想向其添加这个 cognito 授权者的用户池 arn  
*类型*：字符串  
*是否必需*：是  
*CloudFormation 兼容性*：此属性是独有的 AWS SAM ，没有 CloudFormation 等效属性。

## 示例
<a name="sam-property-api-cognitoauthorizer--examples"></a>

### CognitoAuth
<a name="sam-property-api-cognitoauthorizer--examples--cognitoauth"></a>

Cognito 身份验证示例

#### YAML
<a name="sam-property-api-cognitoauthorizer--examples--cognitoauth--yaml"></a>

```
Auth:
  Authorizers:
    MyCognitoAuth:
      AuthorizationScopes:
        - scope1
        - scope2
      UserPoolArn:
        Fn::GetAtt:
          - MyCognitoUserPool
          - Arn
      Identity:
        Header: MyAuthorizationHeader
        ValidationExpression: myauthvalidationexpression
```