如何处理用于UI的Lambda/API网关的Cognito认证重定向?

问题描述:

当我去我的Cognito身份验证页面如何处理用于UI的Lambda/API网关的Cognito认证重定向?

https://example.auth.us-east-1.amazoncognito.com/login?response_type=token&client_id=xxxxxxxxxxxxxxxxxxxxxxxx&redirect_uri=https://example.com/

我可以成功登录。接着,我会重定向到https://example.com/#id_token= {令牌去,这里} &的access_token = {另一个令牌,这里} & expires_in = 3600 & token_type =持票人

或类似的东西。

我有一个为根(/)端点设置的自定义Cognito授权程序。但Cognito授权人只能查看该JWT的标题。

我试着设置了一个重定向,除了将片段的id_token的值移动到Authorization标头中,但标头没有传递到目标Location

一种选择是实现一个REQUEST类型的Lambda授权程序,它允许您访问查询字符串。您将需要执行几行来完成JWT签名验证,但现有的库应该可以帮助实现这一点。 Cognito用户池使用标准的OpenID Connect规范。