2012-08-14 133 views
3

我目前正在试验实施一个openid为大学的一个小网站。我对此很新,并跟进了相关文章。我已经下载了lightopenId并将该文件夹上传到我的网络服务器。我的学校有谷歌托管他们的电子邮件服务,所以典型的电子邮件地址是:像这样[email protected]。我们可以登录mail.google.com或专为我们的登录mail.google.com/a/oakland.edu/谷歌设计的自定义网页。lightopenID for Google Google托管电子邮件

而不是让用户重定向到一般$openid->identity = 'https://www.google.com/accounts/o8/id';我可以让用户定向到自定义大学谷歌托管页面进行身份验证吗?

给我的错误:

No OpenID Server found at http://mail.google.com/a/oakland.edu/accounts/o8/id

openid.php:

<? 
    <?php 
    require 'openid.php'; 
    try { 
     # Change 'localhost' to your domain name. 
     $openid = new LightOpenID('http://webprolearner.ueuo.com'); 
     if(!$openid->mode) { 
      if(isset($_GET['login'])) { 
       $openid->identity = 'mail.google.com/a/oakland.edu/accounts/o8/id'; 
       header('Location: ' . $openid->authUrl()); 
      } 
    ?> 
    <form action="?login" method="post"> 
     <button>Login with Google</button> 
    </form> 
    <?php 
     } elseif($openid->mode == 'cancel') { 
      echo 'User has canceled authentication!'; 
     } else { 
      echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.'; 
     } 
    } catch(ErrorException $e) { 
     echo $e->getMessage(); 
    } 

回答

2

据我所知,你的情况正确的身份是:

https://www.google.com/accounts/o8/site-xrds?hd=oakland.edu 

此网址返回一个有效的XRDS(所以LightOpenID将找到一个服务器)。

请注意,如果服务器配置不正确,则调用validate()时可能会出现类似错误。

+0

完美!这个效果很好! – techAddict82 2012-08-14 17:38:54

+0

哦,但是,我确实得到了:在http://oakland.edu/openid?id=103676657823296937874找不到OpenID Server。我现在能做什么? – techAddict82 2012-08-14 17:51:45

+2

询问能够做到的人,在oakland.edu/openid返回xrds文档,或者重定向到它。例如,通过包含以下代码:'<?php header('X-XRDS-Location: https://www.google.com/accounts/o8/site-xrds?hd=oakland.edu'); ?>'。不幸的是,除非你想破解图书馆检查“有效”网址(并打破openid规范),否则没有其他办法。 – Mewp 2012-08-14 19:42:07

相关问题