Kri*_*zsa 6 amazon-web-services oauth-2.0 amazon-cognito kubernetes kubernetes-ingress
我在 AWS EKS 上的 kubernetes pod 中提供面向外部的 REST GET API 服务。我为此服务配置了一个 ALB Ingress,它强制执行 Cognito 用户池身份验证。Cognito 配置为Authorization code grant启用openidOAuth 范围。
如果我从浏览器调用 REST API,我会被重定向到 Cognito 登录页面。在此处的表单上成功进行身份验证后,我可以正常访问我的 REST GET API。这可行,但这不是我想要实现的目标。
相反,Bearer在成功通过身份验证后,我需要使用令牌。因此,首先我使用 Postman 调用https://cognito-idp.ap-southeast-1.amazonaws.com并发出以下请求:
"AuthParameters" : {
"USERNAME" : "<email>",
"PASSWORD" : "<mypass>",
"SECRET_HASH" : "<correctly calculated hash>"
},
"AuthFlow" : "USER_PASSWORD_AUTH",
"ClientId" : "<cognito user pool id>"
}
Run Code Online (Sandbox Code Playgroud)
我得到了一个成功的回复,例如:
"AuthenticationResult": {
"AccessToken": "...",
"ExpiresIn": 3600,
"IdToken": "...",
"RefreshToken": "...",
"TokenType": "Bearer"
},
"ChallengeParameters": {}
}
Run Code Online (Sandbox Code Playgroud)
在最后一步中,我尝试调用 REST API 服务,传递Authorization带有值的 HTTP 标头Bearer <AccessToken>,但我仍然收到带有登录页面的 HTML 响应。
如何配置 Cognito 以接受此调用的承载令牌作为经过身份验证的身份?
| 归档时间: |
|
| 查看次数: |
6954 次 |
| 最近记录: |