

Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.

# WebSocketApiAuth
<a name="sam-property-websocketapi-websocketapiauth"></a>

Configurez l'autorisation pour contrôler l'accès à votre API Amazon WebSocket API Gateway.

Pour plus d'informations sur la configuration de l'accès à WebSocket APIs, consultez la section [Contrôle de l'accès à WebSocket APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-control-access.html) dans le *Guide du développeur d'API Gateway*.

## Syntaxe
<a name="sam-property-websocketapi-websocketapiauth-syntax"></a>

Pour déclarer cette entité dans votre modèle AWS Serverless Application Model (AWS SAM), utilisez la syntaxe suivante.

### YAML
<a name="sam-property-websocketapi-websocketapiauth-syntax.yaml"></a>

```
[AuthArn](#sam-websocketapiauth-autharn): {{String}}
[AuthType](#sam-websocketapiauth-authtype): {{String}}
[IdentitySource](#sam-websocketapiauth-identitysource): {{List}}
[InvokeRole](#sam-websocketapiauth-invokerole): {{String}}
[Name](#sam-websocketapiauth-name): {{String}}
```

## Propriétés
<a name="sam-property-websocketapi-websocketapiauth-properties"></a>

 `AuthArn`   <a name="sam-websocketapiauth-autharn"></a>
L'ARN de la fonction Lambda à utiliser pour l'autorisation. Obligatoire quand `AuthType` c'est le cas`CUSTOM`.  
*Type* : chaîne  
*Obligatoire* : Conditionnelle  
*CloudFormation compatibilité* : cette propriété est unique AWS SAM et n'a pas d' CloudFormation équivalent.

 `AuthType`   <a name="sam-websocketapiauth-authtype"></a>
Type d'autorisation. Les valeurs valides sont `NONE`, `AWS_IAM` ou `CUSTOM`.  
+ `NONE`- Aucune autorisation
+ `AWS_IAM`- Autorisation IAM
+ `CUSTOM`- Autorisateur Lambda
*Type* : chaîne  
*Obligatoire* : oui  
*CloudFormation compatibilité* : cette propriété est unique AWS SAM et n'a pas d' CloudFormation équivalent.

 `IdentitySource`   <a name="sam-websocketapiauth-identitysource"></a>
Source d'identité pour laquelle l'autorisation est demandée. Par exemple, `route.request.header.Authorization`.  
*Type* : liste  
*Obligatoire* : non  
*CloudFormation compatibilité* : cette propriété est transmise directement à la `[IdentitySource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-identitysource)` propriété d'une `AWS::ApiGatewayV2::Authorizer` ressource.

 `InvokeRole`   <a name="sam-websocketapiauth-invokerole"></a>
L'ARN du rôle IAM assumé par API Gateway lors de l'appel de la fonction d'autorisation. Si ce n'est pas spécifié, crée AWS SAM automatiquement une autorisation basée sur les ressources qui permet à API Gateway d'invoquer la fonction d'autorisation.  
*Type* : chaîne  
*Obligatoire* : non  
*CloudFormation compatibilité* : cette propriété est transmise directement à la `[AuthorizerCredentialsArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-authorizercredentialsarn)` propriété d'une `AWS::ApiGatewayV2::Authorizer` ressource.

 `Name`   <a name="sam-websocketapiauth-name"></a>
Nom du mécanisme d'autorisation.  
*Type* : chaîne  
*Obligatoire* : non  
*CloudFormation compatibilité* : cette propriété est transmise directement à la `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-name)` propriété d'une `AWS::ApiGatewayV2::Authorizer` ressource.

## Exemples
<a name="sam-property-websocketapi-websocketapiauth-examples"></a>

### Autorisateur Lambda
<a name="sam-property-websocketapi-websocketapiauth-examples-lambda"></a>

L'exemple suivant configure un autorisateur Lambda pour une API. WebSocket 

```
Auth:
  AuthType: CUSTOM
  AuthArn: !GetAtt AuthorizerFunction.Arn
  IdentitySource:
    - route.request.header.Authorization
```

### Autorisation IAM
<a name="sam-property-websocketapi-websocketapiauth-examples-iam"></a>

L'exemple suivant configure l'autorisation IAM pour une WebSocket API.

```
Auth:
  AuthType: AWS_IAM
```