如何在 ALB HTTPS 端点上使用 Cognito 提供的“access_token”?

How to use a Cognito supplied `access_token` on an ALB HTTPS endpoint?

我希望我的脚本在使用 Cognito 的 AWS ALB 上发出 HTTPS 请求。

Cognito 用户池有一个使用 Client Credential OAuth Flow 的 App Client。

我已经建立了一个概念验证,似乎允许我执行以下操作:

curl -X POST \
  https://mydomain.auth.eu-west-1.amazoncognito.com/oauth2/token  \
  -H 'authorization: Basic <mybase64encodedstring>' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'grant_type=client_credentials&scope=myscope'

我收到以下回复...

{"access_token":"<a base64 encoded JWT token>","expires_in":3600,"token_type":"Bearer"}

我现在想在负载均衡器后面的应用程序上发出 HTTPS 请求。

ALB 似乎没有与使用 Client Credentials OAuth 流程的应用程序客户端集成。

我是否可以通过 ALB 发出请求,如果令牌无效则请求被拒绝,如果令牌有效则请求传递到后端应用程序?

Can I make my request via the ALB and expect the request to denied if the token is invalid

ALB 只是一个负载均衡器。它不执行负载验证。

I would now like to make a HTTPS request on the application that is behind the load balancer.

您可以使用的是 API Gateway with an authorizer

API 网关可以有一个由 ALB 公开的 HTTP 后端。在此配置中,API 网关可以验证并执行有效的 JWT 访问令牌。参见 https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html