

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

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

Amazon API Gateway WebSocket API へのアクセスを制御するための認可を設定します。

WebSocket APIs「API *Gateway デベロッパーガイド*」の[WebSocket APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-control-access.html)」を参照してください。

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

 AWS Serverless Application Model (AWS SAM) テンプレートでこのエンティティを宣言するには、次の構文を使用します。

### 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}}
```

## プロパティ
<a name="sam-property-websocketapi-websocketapiauth-properties"></a>

 `AuthArn`   <a name="sam-websocketapiauth-autharn"></a>
認可に使用する Lambda 関数の ARN。`AuthType` が の場合は必須です`CUSTOM`。  
*タイプ*: 文字列  
*必須*: 条件に応じて異なります  
*CloudFormation 互換性*: このプロパティは に固有 AWS SAM であり、 CloudFormation 同等のものはありません。

 `AuthType`   <a name="sam-websocketapiauth-authtype"></a>
認可のタイプ。有効な値は `NONE`、`AWS_IAM`、または `CUSTOM` です。  
+ `NONE` - 認可なし
+ `AWS_IAM` - IAM 認可
+ `CUSTOM` - Lambda オーソライザー
*タイプ*: 文字列  
*必須*: はい  
*CloudFormation 互換性*: このプロパティは に固有 AWS SAM であり、 CloudFormation 同等のものはありません。

 `IdentitySource`   <a name="sam-websocketapiauth-identitysource"></a>
承認がリクエストされた ID ソースを含みます。例えば、`route.request.header.Authorization`。  
*タイプ*: リスト  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは、 `AWS::ApiGatewayV2::Authorizer`リソースの `[IdentitySource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-identitysource)`プロパティに直接渡されます。

 `InvokeRole`   <a name="sam-websocketapiauth-invokerole"></a>
オーソライザー関数を呼び出すときに API Gateway が引き受ける IAM ロールの ARN。指定しない場合、API Gateway がオーソライザー関数を呼び出すことを許可するリソースベースのアクセス許可 AWS SAM が自動的に作成されます。  
*タイプ*: 文字列  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは、 `AWS::ApiGatewayV2::Authorizer`リソースの `[AuthorizerCredentialsArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-authorizercredentialsarn)`プロパティに直接渡されます。

 `Name`   <a name="sam-websocketapiauth-name"></a>
認証の名前。  
*タイプ*: 文字列  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは、 `AWS::ApiGatewayV2::Authorizer`リソースの `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-name)`プロパティに直接渡されます。

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

### Lambda オーソライザー
<a name="sam-property-websocketapi-websocketapiauth-examples-lambda"></a>

次の例では、WebSocket API の Lambda オーソライザーを設定します。

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

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

次の例では、WebSocket API の IAM 認可を設定します。

```
Auth:
  AuthType: AWS_IAM
```