AWS API Gateway的身份验证策略

时间:2019-08-06 15:32:01

标签: amazon-web-services aws-lambda aws-api-gateway amazon-cognito spotify

我正在尝试根据他们的Spotify帐户对用户进行身份验证。但是我在AWS服务中还很陌生,我不确定应该使用哪一种,无论是Cognito,自定义auth lambda函数还是任何其他服务。

1 个答案:

答案 0 :(得分:0)

据我了解,Spotify为外部应用程序开发人员提供了符合RFC 6749 [1]的OAuth 2.0端点。由于您要基于OAuth 2.0协议用户进行身份验证,因此请注意,OAuth主要不是身份验证协议[2]。 这就是为什么Spotify在其文档中将其称为授权指南 [3]。

AWS Cognito不支持OAuth 2.0,因为它旨在解决身份验证问题。 [4]
相反,它支持OpenID Connect(OIDC)。有些文章解释了OIDC和OAuth之间的区别,例如[5]。

尽管如此,如果您想在API网关中使用OAuth令牌,另一个SO线程[4]提到您可以通过使用自定义授权器 [6] [7]来实现。您可以使用令牌访问Spotify后端,但不确定是否可以直接对其进行验证。由于上述AuthZ与AuthN原因,我对此表示怀疑。

参考文献

[1] https://tools.ietf.org/html/rfc6749#section-4.1
[2] https://oauth.net/articles/authentication/
[3] https://developer.spotify.com/documentation/general/guides/authorization-guide/
[4] https://stackoverflow.com/a/33686216/10473469
[5] https://medium.com/@abstarreveld/oauth-and-openid-explained-with-real-life-examples-bf40daa8049f
[6] https://aws.amazon.com/de/blogs/compute/introducing-custom-authorizers-in-amazon-api-gateway/
[7] https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html

相关问题