您可以使用以下機制進行身份驗證和授權:
-
資源策略允許您創建基於資源的策略,以允許或拒絕從指定的源 IP 地址或 VPC 終端節點訪問您的 API 和方法。有關更多信息,請參閱 使用 Amazon API Gateway 資源策略控制對 API 的訪問。
-
標准 AWS IAM 角色和策略 提供靈活、穩健的訪問控制,可應用於整個 API 或單個方法。IAM 角色和策略可用於控制誰可以創建和管理您的 API 以及誰可以調用它們。有關更多信息,請參閱使用 IAM 許可控制對 API 的訪問。
-
IAM 標簽可與 IAM 策略結合使用來控制訪問權限。有關更多信息,請參閱 使用標簽控制對 API Gateway 資源的訪問。
-
接口 VPC 終端節點的終端節點策略允許您將 IAM 資源策略附加到接口 VPC 終端節點,用於改進私有 API 的安全性。有關更多信息,請參閱 在 API Gateway 中為私有 API 使用 VPC 終端節點策略。
-
Lambda 授權方是 Lambda 函數,它們使用持有者令牌身份驗證以及由標頭、路徑、查詢字符串、階段變量或上下文變量請求參數描述的信息來控制對 REST API 方法的訪問。Lambda 授權方用於控制誰可以調用 REST API 方法。有關更多信息,請參閱 使用 API Gateway Lambda 授權方。
-
Amazon Cognito 用戶池可讓您為 REST API 創建可自定義的身份驗證和授權解決方案。Amazon Cognito 用戶池用於控制誰可以調用 REST API 方法。有關更多信息,請參閱 使用 Amazon Cognito 用戶池 作為授權方控制對 REST API 的訪問權限。
以下機制可用於執行與訪問控制相關的其他任務:
-
跨源資源共享 (CORS) 可讓您控制您的 REST API 響應跨域資源請求的方式。有關更多信息,請參閱為 API Gateway REST API 資源啟用 CORS。
-
客戶端 SSL 證書可用於驗證發送到后端系統的 HTTP 請求是否來自 API Gateway。有關更多信息,請參閱生成和配置 SSL 證書用於后端身份驗證。
-
AWS WAF 可用於保護您的 API Gateway API 免遭常見 Web 漏洞的攻擊。有關更多信息,請參閱 使用 AWS WAF 來保護 Amazon API Gateway API 免遭常見 Web 漏洞的攻擊。
以下機制可用於跟蹤和限制您已向授權客戶端授予的訪問權限:
-
使用計划可讓您向客戶提供 API 密鑰 — 然后跟蹤和限制每個 API 密鑰的 API 階段和方法的使用。有關更多信息,請參閱 創建和使用帶 API 密鑰的使用計划。
The following mechanisms can be used for authentication and authorization:
-
Resource policies let you create resource-based policies to allow or deny access to your APIs and methods from specified source IP addresses or VPC endpoints. For more information, see Control Access to an API with Amazon API Gateway Resource Policies.
-
Standard AWS IAM roles and policies offer flexible and robust access controls that can be applied to an entire API or individual methods. IAM roles and policies can be used for controlling who can create and manage your APIs as well as who can invoke them. For more information, see Control Access to an API with IAM Permissions.
-
IAM tags can be used together with IAM policies to control access. For more information, see Using Tags to Control Access to API Gateway Resources.
-
Endpoint Policies for Interface VPC Endpoints allow you to attach IAM resource policies to interface VPC endpoints to improve the security of your private APIs. For more information, see Use VPC Endpoint Policies for Private APIs in API Gateway.
-
Lambda authorizers are Lambda functions that control access to REST API methods using bearer token authentication as well as information described by headers, paths, query strings, stage variables, or context variables request parameters. Lambda authorizers are used to control who can invoke REST API methods. For more information, see Use API Gateway Lambda Authorizers.
-
Amazon Cognito user pools let you create customizable authentication and authorization solutions for your REST APIs. Amazon Cognito user pools are used to control who can invoke REST API methods. For more information, see Control Access to a REST API Using Amazon Cognito User Pools as Authorizer.