

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

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

Konfigurasikan otorisasi untuk mengontrol akses ke Amazon API Gateway WebSocket API Anda.

Untuk informasi selengkapnya tentang mengonfigurasi akses ke WebSocket APIs, lihat [Mengontrol akses ke WebSocket APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-control-access.html) dalam *Panduan Pengembang API Gateway*.

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

Untuk mendeklarasikan entitas ini dalam template AWS Serverless Application Model (AWS SAM) Anda, gunakan sintaks berikut.

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

## Sifat-sifat
<a name="sam-property-websocketapi-websocketapiauth-properties"></a>

 `AuthArn`   <a name="sam-websocketapiauth-autharn"></a>
ARN dari fungsi Lambda untuk digunakan untuk otorisasi. Diperlukan kapan `AuthType``CUSTOM`.  
*Tipe*: String  
*Wajib*: Bersyarat  
*CloudFormation kompatibilitas*: Properti ini unik AWS SAM dan tidak memiliki CloudFormation padanan.

 `AuthType`   <a name="sam-websocketapiauth-authtype"></a>
Jenis otorisasi. Nilai yang valid adalah `NONE`, `AWS_IAM`, atau `CUSTOM`.  
+ `NONE`- Tidak ada otorisasi
+ `AWS_IAM`- Otorisasi IAM
+ `CUSTOM`- Pengotorisasi Lambda
*Tipe*: String  
*Wajib*: Ya  
*CloudFormation kompatibilitas*: Properti ini unik AWS SAM dan tidak memiliki CloudFormation padanan.

 `IdentitySource`   <a name="sam-websocketapiauth-identitysource"></a>
Sumber identitas yang meminta otorisasi. Misalnya, `route.request.header.Authorization`.  
*Tipe*: Daftar  
*Wajib*: Tidak  
*CloudFormation kompatibilitas*: Properti ini diteruskan langsung ke `[IdentitySource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-identitysource)` properti `AWS::ApiGatewayV2::Authorizer` sumber daya.

 `InvokeRole`   <a name="sam-websocketapiauth-invokerole"></a>
ARN dari peran IAM yang diasumsikan API Gateway saat menjalankan fungsi otorisasi. Jika tidak ditentukan, AWS SAM secara otomatis membuat izin berbasis sumber daya yang memungkinkan API Gateway menjalankan fungsi otorisasi.  
*Tipe*: String  
*Wajib*: Tidak  
*CloudFormation kompatibilitas*: Properti ini diteruskan langsung ke `[AuthorizerCredentialsArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-authorizercredentialsarn)` properti `AWS::ApiGatewayV2::Authorizer` sumber daya.

 `Name`   <a name="sam-websocketapiauth-name"></a>
Nama pemberi otorisasi.  
*Tipe*: String  
*Wajib*: Tidak  
*CloudFormation kompatibilitas*: Properti ini diteruskan langsung ke `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-name)` properti `AWS::ApiGatewayV2::Authorizer` sumber daya.

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

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

Contoh berikut mengonfigurasi otorisasi Lambda untuk API. WebSocket 

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

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

Contoh berikut mengonfigurasi otorisasi IAM untuk API. WebSocket 

```
Auth:
  AuthType: AWS_IAM
```