在 S3 提供的 AWS 无服务器网站中,在何处存储 API 网关凭据?
Where to store API gateway credentials in AWS serverless website served from S3?
在示例 AWS 无服务器架构中,S3 托管静态网站,通过 javascript 调用 API 网关端点,后者又调用 Lambda 函数。
如何在不生成凭据的情况下针对 AWS API 网关进行身份验证 public,方法是将它们存储在 public可访问的 javascript 来源中S3?
(不询问后端凭据,这些凭据很容易存储(并加密)在 Lambda 函数可访问的环境变量中)
使用 AWS Cognito 之类的东西是最好的主意(无需担心管理您自己的身份验证服务器)。
在 AWS Cognito 中,您可以简单地为未经身份验证的用户提供调用 API 的访问权限。有关更多信息,请参阅文档 (here and here)。
您的用户通常会使用 Cognito or some other auth backend, exchanging their credentials for a JWT token or equivalent that is used to authenticate to API Gateway. Here's an example 所涉及的步骤进行身份验证。
也可以通过 Cognito 支持 unauthenticated users。
如果在某些情况下您需要 API 无需身份验证即可进行网关调用,请参阅 。
您需要使用第三方身份提供商从客户端获取令牌,您可以将其传递给 API 网关。我个人使用 Auth0,最多两个身份提供者可以免费使用。
它很容易与您的 Single Page Application (Angular/React/Vue) to one or many Identity Providers 集成,有很好的代码示例。
集成起来也很简单server-side validation of the auth tokens in API Gateway using a Custom Authenticator. Role Based Access can also be controlled using the Authorization Extension。网站的 public 部分可以对 API 不使用自定义身份验证器的端点进行 API 调用。
这是来自无服务器框架网站的一个很好的指南,显示 Strategies for implementing user authentication in serverless applications, with a working example on GitHub。
在示例 AWS 无服务器架构中,S3 托管静态网站,通过 javascript 调用 API 网关端点,后者又调用 Lambda 函数。
如何在不生成凭据的情况下针对 AWS API 网关进行身份验证 public,方法是将它们存储在 public可访问的 javascript 来源中S3?
(不询问后端凭据,这些凭据很容易存储(并加密)在 Lambda 函数可访问的环境变量中)
使用 AWS Cognito 之类的东西是最好的主意(无需担心管理您自己的身份验证服务器)。
在 AWS Cognito 中,您可以简单地为未经身份验证的用户提供调用 API 的访问权限。有关更多信息,请参阅文档 (here and here)。
您的用户通常会使用 Cognito or some other auth backend, exchanging their credentials for a JWT token or equivalent that is used to authenticate to API Gateway. Here's an example 所涉及的步骤进行身份验证。
也可以通过 Cognito 支持 unauthenticated users。
如果在某些情况下您需要 API 无需身份验证即可进行网关调用,请参阅
您需要使用第三方身份提供商从客户端获取令牌,您可以将其传递给 API 网关。我个人使用 Auth0,最多两个身份提供者可以免费使用。
它很容易与您的 Single Page Application (Angular/React/Vue) to one or many Identity Providers 集成,有很好的代码示例。
集成起来也很简单server-side validation of the auth tokens in API Gateway using a Custom Authenticator. Role Based Access can also be controlled using the Authorization Extension。网站的 public 部分可以对 API 不使用自定义身份验证器的端点进行 API 调用。
这是来自无服务器框架网站的一个很好的指南,显示 Strategies for implementing user authentication in serverless applications, with a working example on GitHub。