【问题标题】:AppEngine authentication through Node.js通过 Node.js 进行 AppEngine 身份验证
【发布时间】:2019-07-19 09:08:27
【问题描述】:

我正在尝试编写一个 VSCode 扩展程序,用户可以使用谷歌帐户登录 Google AppEngine,我需要获取他们的SACSID cookie 来发出 appengine 请求。

所以我在

打开一个浏览器窗口

https://accounts.google.com/ServiceLogin?service=ah&passive=true&continue=https://appengine.google.com/_ah/conflogin%3Fcontinue%3Dhttp://localhost:3000/

(由google.appengine.api.users.create_login_url生成)

用户登录并被重定向到我的本地网络服务器

localhost:3000/_ah/conflogin/?state={state}

现在我尝试将请求转发给我的 AppEngine 应用(因为它知道如何解码 state 参数),所以我向

发出请求

https://my-app.appspot.com/_ah/conflogin/?state={state}

基本上只是将 localhost 替换为实际的应用程序。

但它不起作用,大概是因为域不同。我认为这是出于安全考虑。

我有什么办法可以完成这项工作吗?

【问题讨论】:

    标签: google-app-engine google-authentication


    【解决方案1】:

    不理想,但我发现的唯一解决方案是在我的 GAE 实例上设置一个端点来执行重定向。然后我可以将其设置为继续 url,当我开始身份验证过程时

    https://accounts.google.com/ServiceLogin?service=ah&passive=true&continue=https://appengine.google.com/_ah/conflogin%3Fcontinue%3Dhttps://my-app.appspot.com/redirect?to=http://localhost:3000

    【讨论】:

      【解决方案2】:

      我认为您应该将注意力集中在您正在使用的协议上,因为众所周知 cookie 名称是基于 http 协议(HTTP : ACSID,HTTPS:SACSID),而这对我来说是迄今为止的安全视角.

      遇到您现在面临的错误将有助于更好地理解问题。此外,您如何执行对 API 的调用以及您正在使用的代码也会有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-09-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-09-18
        相关资源
        最近更新 更多