2

だから私はOpenIDを理解しようとしていて、理論などを理解していると感じています...今ではそれを実装するようになっています。Googleプロバイダーのアドレスにcurlリクエストを送信する非常に基本的な設定があります。

https://www.google.com/accounts/o8/id

返されたXRDSxmlファイルを解析します

<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)">
  <XRD>
    <Service priority="0">
      <Type>http://specs.openid.net/auth/2.0/server</Type>
      <Type>http://openid.net/srv/ax/1.0</Type>
      <Type>http://specs.openid.net/extensions/ui/1.0/mode/popup</Type>
      <Type>http://specs.openid.net/extensions/ui/1.0/icon</Type>
      <Type>http://specs.openid.net/extensions/pape/1.0</Type>
      <URI>https://www.google.com/accounts/o8/ud</URI>
    </Service>
  </XRD>
</xrds:XRDS>

XRDSドキュメントからGoogleの実際のプロバイダーを取得した後、この関数を使用してリダイレクトします...

public function RedirectToEndpoint() {
    $params = array();
    $params['openid.mode'] = 'checkid_setup';
    $params['openid.ns'] = 'http://specs.openid.net/auth/2.0';
    $params['openid.claimed_id'] = 'http://specs.openid.net/auth/2.0/identifier_select';
    $params['openid.identity'] = 'http://specs.openid.net/auth/2.0/identifier_select';
    $params['openid.return_to'] = $this->URLs['return_to'];
    $params['openid.realm'] = $this->URLs['realm'];

    $join = stripos($this->URLs['openid_server'], '?') ? '&' : '?';
    $redirect_to = $this->URLs['openid_server'] . $join . $this->array2url($params);
    if (headers_sent()){ // Use JavaScript to redirect if content has been previously sent (not recommended, but safe)
        echo '<script language="JavaScript" type="text/javascript">window.location=\'';
        echo $redirect_to;
        echo '\';</script>';
    }else{  // Default Header Redirect
        header('Location: ' . $redirect_to);
    }
}

array2urlは、連想配列$paramsを変換してクエリ文字列に追加する単純な関数です。

生成されたURLはそのようなものです...

https://www.google.com/accounts/o8/ud?openid.mode=checkid_setup&openid.ns=http://specs.openid.net/auth/2.0&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&openid.return_to=http://learn.local/openid/return.php&openid.realm=http://learn.local/openid/index.html&

ただし、要求されたページが無効になってしまいます。そして素敵な400悪いリクエスト..何かアイデアはありますか?

4

1 に答える 1

3

全体として、私はこれ以上愚かであると感じることができませんでした!それは私の領域を正しく設定することに帰着しました。私には、いわば利用可能な「範囲」から外れた私の差出人住所につながる領域がありました。400エラーに遭遇する将来の人々にとって、それはそうかもしれません。

$openid->SetReturnAddress(('http://learn.local/openid/return.php')); //.return_to
$openid->SetDomain(('http://learn.local/openid/index.html')); //Realm

不適切に構成されたレルム..facepalm

今です...

$openid->SetDomain(('http://learn.local')); //Realm
于 2012-06-06T19:51:56.547 に答える