ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 12682


Ignore:
Timestamp:
Aug 18, 2009, 2:01:21 AM (13 years ago)
Author:
ebihara
Message:

#4243:added support for being OpenID 2.0 Provider

Location:
OpenPNE3/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/apps/pc_frontend/config/filters.yml

    r12283 r12682  
    66enable_app:
    77  class: opCheckEnabledApplicationFilter
     8
     9xrds_header:
     10  class: opAppendXRDSHeaderFilter
    811
    912security:  ~
  • OpenPNE3/trunk/apps/pc_frontend/modules/OpenID/actions/actions.class.php

    r12681 r12682  
    77 * For the full copyright and license information, please view the LICENSE
    88 * file and the NOTICE file that were distributed with this source code.
    9  */
    10 
    11 /**
    12  * Copyright (C) 2005-2009 OpenPNE Project
    13  *
    14  * Licensed under the Apache License, Version 2.0 (the "License");
    15  * you may not use this file except in compliance with the License.
    16  * You may obtain a copy of the License at
    17  *
    18  *  http://www.apache.org/licenses/LICENSE-2.0
    19  *
    20  * Unless required by applicable law or agreed to in writing, software
    21  * distributed under the License is distributed on an "AS IS" BASIS,
    22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    23  * See the License for the specific language governing permissions and
    24  * limitations under the License.
    259 */
    2610
     
    4832    $server = new Auth_OpenID_Server(new Auth_OpenID_FileStore(sfConfig::get('sf_cache_dir')), $url);
    4933
    50 //    header('X-XRDS-Location: '.$this->getController()->genUrl('OpenID/idpXrds'));
     34    $this->getResponse()->setHttpHeader('X-XRDS-Location', $this->getController()->genUrl('OpenID/signonXrds', true));
    5135
    5236    $openIDRequest = $server->decodeRequest();
    5337    if (!$openIDRequest)
    5438    {
    55       $_SESSION['request'] = serialize($openIDRequest);
     39      $_SESSION['request'] = null;
    5640      return sfView::SUCCESS;
    5741    }
     
    6852        else
    6953        {
     54          $this->getRequest()->setMethod(sfWebRequest::GET);
     55          $_SERVER['QUERY_STRING'] = str_replace('http://example.com/?', '', $openIDRequest->encodeToURL('http://example.com/'));
     56          $this->forwardUnless($this->getUser()->isAuthenticated() && $this->getUser()->getMember(), 'member', 'login');
     57
    7058          $this->info = $openIDRequest;
    7159          return 'Trust';
     
    117105
    118106    $reqUrl = $this->getController()->genUrl('OpenID/member?id='.$this->getUser()->getMemberId(), true);
    119     $this->forward404Unless($reqUrl === $info->identity, 'request:'.$reqUrl.'/identity:'.$info->identity);
    120 
    121     if ($trusted)
     107    if (!$info->idSelect())
    122108    {
    123       unset($_SESSION['request']);
    124       $server = new Auth_OpenID_Server(new Auth_OpenID_FileStore(sfConfig::get('sf_cache_dir')), $info->identity);
    125       $response = $info->answer(true, null, $reqUrl);
    126 
    127       $sregRequest = Auth_OpenID_SRegRequest::fromOpenIDRequest($info);
    128       if ($sregRequest)
    129       {
    130         $userData = array(
    131           'nickname' => $this->getUser()->getMember()->name,
    132         );
    133         $sregResp = Auth_OpenID_SRegResponse::extractResponse($sregRequest, $userData);
    134         $response->addExtension($sregResp);
    135       }
    136 
    137       $response = $server->encodeResponse($response);
    138       $this->writeResponse($response);
     109      $this->forward404Unless($reqUrl === $info->identity, 'request:'.$reqUrl.'/identity:'.$info->identity);
    139110    }
    140111
    141     $this->forward404();
     112    unset($_SESSION['request']);
     113    $server = new Auth_OpenID_Server(new Auth_OpenID_FileStore(sfConfig::get('sf_cache_dir')), $info->identity);
     114    $response = $info->answer(true, null, $reqUrl);
     115
     116    $sregRequest = Auth_OpenID_SRegRequest::fromOpenIDRequest($info);
     117    if ($sregRequest)
     118    {
     119      $userData = array(
     120        'nickname' => $this->getUser()->getMember()->name,
     121      );
     122      $sregResp = Auth_OpenID_SRegResponse::extractResponse($sregRequest, $userData);
     123      $response->addExtension($sregResp);
     124    }
     125
     126    $response = $server->encodeResponse($response);
     127
     128    $this->writeResponse($response);
    142129  }
    143130
     
    150137    header('Content-type: application/xrds+xml');
    151138    $type = Auth_OpenID_TYPE_2_0_IDP;
    152     $uri = $this->getController()->genUrl('OpenID/index');
     139    $uri = $this->getController()->genUrl('OpenID/index', true);
    153140    echo <<<EOF
    154141<?xml version="1.0" encoding="UTF-8"?>
    155142<xrds:XRDS
    156143    xmlns:xrds="xri://\$xrds"
     144    xmlns="xri://\$xrd*(\$v*2.0)">
     145  <XRD>
     146    <Service priority="0">
     147      <Type>$type</Type>
     148      <URI>$uri</URI>
     149    </Service>
     150  </XRD>
     151</xrds:XRDS>
     152EOF;
     153    return sfView::NONE;
     154  }
     155
     156  public function executeSignonXrds(sfWebRequest $request)
     157  {
     158    header('Content-type: application/xrds+xml');
     159    $type = Auth_OpenID_TYPE_2_0;
     160    $uri = $this->getController()->genUrl('OpenID/index', true);
     161    echo <<<EOF
     162<?xml version="1.0" encoding="UTF-8"?>
     163<xrds:XRDS
     164    xmlns:xrds="xri://\$xrds"
     165    xmlns:openid="http://openid.net/xmlns/1.0"
    157166    xmlns="xri://\$xrd*(\$v*2.0)">
    158167  <XRD>
  • OpenPNE3/trunk/apps/pc_frontend/modules/OpenID/templates/memberSuccess.php

    r9796 r12682  
    33    <title>OpenID Server Endpoint</title>
    44    <link rel="openid.server" href="<?php echo url_for('OpenID/index', true) ?>" />
     5    <link rel="openid2.provider" href="<?php echo url_for('OpenID/index', true) ?>" />
    56  </head>
    67  <body>
Note: See TracChangeset for help on using the changeset viewer.