代码之家  ›  专栏  ›  技术社区  ›  moraes

使用Google Apps+应用程序引擎进行单一登录

  •  14
  • moraes  · 技术社区  · 15 年前

    是否可以使用内置的OpenID应用程序引擎实现SSO?我一直在尝试集成一个市场应用程序,让用户从谷歌应用程序(管理面板或通用导航)登录。我惨遭失败,现在我发现了:

    “这方面的一个例外是执行混合OpenID/OAuth_”白名单的应用程序目前不适用于此方法。”(来自 here )

    我假设我必须使用一个库来实现OpenID,而不是使用内置的库来实现在我的应用程序中使用Google应用程序的SSO?或者,如果可以使用内置的OpenID,是否有一个示例可以演示如何做到这一点?

    5 回复  |  直到 14 年前
        1
  •  6
  •   moraes    15 年前

    后来,谷歌发布了一篇关于如何在python中实现这一点的文章:

    http://code.google.com/googleapps/marketplace/tutorial_python_gae.html

    总结如下:

    • 您必须在市场清单XML中白名单您的“openid领域”(应用程序域)。
    • 用于谷歌通用导航的入口点必须包含当前的谷歌应用程序域。
    • 应用程序中的入口点将通过Google应用程序域的用户重定向为 federated_identity .

    例如:

    from google.appengine.api import users
    
    # [...]
    
    login_url = users.create_login_url(dest_url='http://my-app.appspot.com/',
                                       _auth_domain=None,
                                       federated_identity=google_apps_domain_name)
    self.redirect(login_url)
    
        2
  •  2
  •   Paul Lernmark    14 年前

    这在Java中为我工作:

    Set<String> attributesRequest = new HashSet<String>();
    String loginRealm = "http://myapp.appspot.com"; //Important that it is exactly the same as in application-manifest.xml, watch out for trailing slashes.
    String destinationURL = req.getRequestURI() + "?" + req.getQueryString();
    String federatedIdentity = null;
    String authDomain = req.getParameter("hd"); //hd is the default parameter name. Contains the google apps domain name of the user logging on. example.com for example.
    String loginUrl = userService.createLoginURL(destinationURL, federatedIdentity, authDomain, attributesRequest);     
    

    确保包括

    <Edition id="free">
        <Name>Cloud App Studio</Name>
        <Extension ref="navLink" />
        <Extension ref="realm" />
    </Edition>
    

    在application-manifest.xml中。也就是说,如果免费的话。重要的是包括对领域的引用。

        3
  •  1
  •   aldrinleal    15 年前

    嗯,我还没有得到这个功能的全部独家新闻,但我确实在GAE应用程序中使用了Janrain Engage(StackOverflow使用)。我认为OpenID4Java也可以做到这一点。

        4
  •  1
  •   iamgopal    15 年前

    您没有指定要使用的语言。如果是Java,则有OpenID+OAuthTM的谷歌库。

    http://code.google.com/p/step2/

        5
  •  1
  •   Martin Thoma    15 年前

    你已经知道了吗 this link ?

    UserService userService = UserServiceFactory.getUserService();
    
    if (userService.isUserLoggedIn()) {
      User user = userService.getCurrentUser();
      /* ...Do something with user.getFederatedIdentity(), which is the OpenID URL. */
    }