

# x amazon-apigateway-authtype プロパティ
<a name="api-gateway-swagger-extensions-authtype"></a>

REST API の場合、この拡張モジュールを使用して Lambda オーソライザーのカスタムタイプを定義できます。この場合、値は自由形式です。たとえば、API は、異なる内部スキームを使用する複数の Lambda オーソライザーを持つ場合があります。この拡張を使用して、Lambda オーソライザーの内部スキームを識別できます。

より一般的には、HTTP API と REST API では、同じセキュリティスキームを共有する複数のオペレーションにわたって IAM 認可を定義する方法としても使用できます。この場合、`awsSigv4`の接頭辞が付く用語と同様、`aws`は予約語になります。

この拡張機能は、[ OpenAPI 2 ](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#security-scheme-object)および [OpenAPI 3](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.1.md#security-scheme-object)の `apiKey` タイプのセキュリティスキームに適用されます。

## x-amazon-apigateway-authtype の例
<a name="api-gateway-swagger-extensions-authtype-example"></a>

次の OpenAPI 3 の例では、REST API または HTTP API の複数のリソースにわたって IAM 認可を定義します。

```
{
  "openapi" : "3.0.1",
  "info" : {
    "title" : "openapi3",
    "version" : "1.0"
  },
  "paths" : {
    "/operation1" : {
      "get" : {
        "responses" : {
          "default" : {
            "description" : "Default response"
          }
        },
        "security" : [ {
          "sigv4Reference" : [ ]
        } ]
      }
    },
    "/operation2" : {
      "get" : {
        "responses" : {
          "default" : {
            "description" : "Default response"
          }
        },
        "security" : [ {
          "sigv4Reference" : [ ]
        } ]
      }
    }
  },
  "components" : {
    "securitySchemes" : {
      "sigv4Reference" : {
        "type" : "apiKey",
        "name" : "Authorization",
        "in" : "header",
        "x-amazon-apigateway-authtype": "awsSigv4"
      }
    }
  }
}
```

次の OpenAPI 3 の例は、REST API のカスタムスキームを使用して Lambda オーソライザーを定義します。

```
{
  "openapi" : "3.0.1",
  "info" : {
    "title" : "openapi3 for REST API",
    "version" : "1.0"
  },
  "paths" : {
    "/protected-by-lambda-authorizer" : {
      "get" : {
        "responses" : {
          "200" : {
            "description" : "Default response"
          }
        },
        "security" : [ {
          "myAuthorizer" : [ ]
        } ]
      }
    }
  },
  "components" : {
    "securitySchemes" : {
      "myAuthorizer" : {
        "type" : "apiKey",
        "name" : "Authorization",
        "in" : "header",
        "x-amazon-apigateway-authorizer" : {
          "identitySource" : "method.request.header.Authorization",
          "authorizerUri" : "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:account-id:function:function-name/invocations",
          "authorizerResultTtlInSeconds" : 300,
          "type" : "request",
          "enableSimpleResponses" : false
        },
        "x-amazon-apigateway-authtype": "Custom scheme with corporate claims"
      }
    }
  },
  "x-amazon-apigateway-importexport-version" : "1.0"
}
```

## 以下の資料も参照してください。
<a name="api-gateway-swagger-extensions-authtype-see-also"></a>

[authorizer.authType](https://docs.aws.amazon.com/apigateway/latest/api/API_Authorizer.html#apigw-Type-Authorizer-authType)