Lightopenid自动批准(初步批准后)

时间:2013-01-22 19:32:16

标签: php authentication oauth openid

我使用LightOpenId基本上将OpenIDOAuth1.0结合使用。

批准工作正常,但是,我的客户每次都需要批准。我希望OpenID认识到,客户已经批准(基本上使用复选框“记住此批准”)并且不再显示批准面具。

如何做到这一点?

谢谢, 基督教

1 个答案:

答案 0 :(得分:0)

我已经在我的应用程序上暂时忽略了这个问题,并且几乎错过了你的解决方案,因为它在评论中。

可以在处理程序的第一部分中应用“修复”而不实际修改LightOpenId代码:

  $mysiteurl = 'https://my.site.url/'; // note trailing '/' included

  $openid = new LightOpenID($mysiteurl); // <- the trailing '/' onwards is stripped internally
  if (!$openid->mode) {
      $openid->required = array(
        'namePerson/first',
        'namePerson/last'
         // etc...
      );
      // redirects to google openid provider
      $openid->identity = 'https://www.google.com/accounts/o8/id';
      $openid->realm = $mysiteurl; // <- ADD THIS LINE - resets realm with the trailing '/'
      header('Location: ' . $openid->authUrl());
      return;

  } elseif ($openid->mode == 'cancel') {
    header('Location: '. $mysiteurl.'cancelled.php');
    return;

  } elseif (!$openid->validate()) {
    header('Location: '. $mysiteurl.'failed.php');
    return;
  }

  header('Location: '. $mysiteurl.'success.php');
  return;