Api网关授权失败,因为Cognito使用 # 而不是 ? 传递id_token参数。

0

【以下的问题经过翻译处理】 我使用Cognito授权程序进行http API集成,使用隐式授权方式,id_token被作为URL传递:https://abc.eu-central-1.amazonaws.com/abc#id_token=xyz>

我的API网关的身份来源配置为:$request.querystring.id_token。API网关无法解析id_token,最终返回{"message":"Unauthorized"}。

如果我手动更改请求,使用?代替#来放置id_token,一切正常,因为哈希部分不会被发送到服务器:https://abc.eu-central-1.amazonaws.com/abc?id_token=xyz>

有什么想法可以解决这个问题而不更改授权类型吗?我不能相信我在解决这样的问题上花了一天的时间。

1 Antwort
0

【以下的回答经过翻译处理】 使用URL的哈希片段与OpenID Connect Core 1.0标准中的3.2.2.5. 成功身份验证响应有关。

在使用隐式流时,所有响应参数都添加到重定向URI的片段组件中。 根据3.2.2.7.重定向URI片段处理建议: 由于响应参数以重定向URI片段值的形式返回,因此客户端需要使用户代理解析片段编码值,并将它们传递给客户端的处理逻辑以供使用。 您是否从Cognito直接重定向到API Gateway? 但是,根据Amazon Cognito - 授权端点,“隐式授权的安全性较低,因为它会向用户公开令牌和潜在的识别信息”,使用授权代码授权更安全。代码以查询字符串参数的形式返回,而不是以片段的形式返回。

profile picture
EXPERTE
beantwortet vor 5 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen