【问题标题】:Google Cloud Endpoints custom authentication with App Engine Flexible (Node.js)使用 App Engine Flexible (Node.js) 的 Google Cloud Endpoints 自定义身份验证
【发布时间】:2017-10-09 15:37:51
【问题描述】:

Google Cloud Endpoints 文档为可扩展服务代理配置文件中的自定义安全定义提供了此规范:

securityDefinitions:
    your_custom_auth_id:
        authorizationUrl: ""
        flow: "implicit"
        type: "oauth2"
        # The value below should be unique
        x-google-issuer: "issuer of the token"
        x-google-jwks_uri: "url to the public key"
        # Optional. Replace YOUR-CLIENT-ID with your client ID
        x-google-audiences: "YOUR-CLIENT-ID"

关于如何实现这一点的文档对于 App Engine 灵活来说非常少。有没有人有一个如何设置的例子,或者他们可以证明这是可能的?特别是authorizationUrl的接口是什么?我们可以放置我们的授权服务的 URL(它提供由可扩展服务代理验证的 JWT 令牌),以便如果令牌在 authenticationURL 中无效,端点将重定向到它?

【问题讨论】:

    标签: google-app-engine google-cloud-platform google-cloud-endpoints


    【解决方案1】:

    你是对的。 'authorizationUrl' 是一个 OpenAPI Swagger specific annotation,它指向客户端用来检索实际 JWT(JSON Web 令牌)的 URL endpoint of your log in form

    一旦客户端在登录后从您的 App Engine 应用程序中检索到 JWT,他们就可以使用它来授权他们对您的 Cloud Endpoint API 的请求。


    您的 Node.js App Engine 应用程序将使用任何 JWT signing library 来生成 JWT(auth0 offers their own 在许多语言中)。

    要生成令牌,您将提供标准的“JWT”和哈希标头,添加您的特定用户对象 JSON 有效负载(因为此令牌对于该特定用户应该是唯一的),以及您的密钥/公钥。

    JWT 库还应在生成它时自动提供所需的 JWT claims,只需确保您在 'openapi.yaml' 中提供库使用的颁发者和您的秘密/公钥作为“x-google-issuer”和“ x-google-jwks_uri'。


    您可以关注JWT.io guide,详细了解如何生成和使用 JWT。也可以按照具体的App Engine Flexible guidecode your application来处理JWT。

    【讨论】:

    • 如果我们没有像 auth0 这样的提供者怎么办?我在我的 Spring Boot 应用程序中为我的 Android 应用程序实现了带有 auth 2 的 JWT。对于身份验证,我的 Android 应用程序将使用他们的电话号码和密码。我没有找到描述如何做的例子。
    猜你喜欢
    • 1970-01-01
    • 2016-02-03
    • 1970-01-01
    • 2011-12-25
    • 2013-06-02
    • 2021-11-20
    • 1970-01-01
    • 1970-01-01
    • 2016-04-01
    相关资源
    最近更新 更多