Changeset 12961

Show
Ignore:
Timestamp:
06/01/08 03:23:11 (5 years ago)
Author:
ha1t
Message:

認証にプラグインを利用

Location:
websites/planet.php.gr.jp/trunk
Files:
2 added
8 modified

Legend:

Unmodified
Added
Removed
  • websites/planet.php.gr.jp/trunk/.ethna

    r12928 r12961  
    11[project] 
     2ethna_version = 2.3.5 
    23controller_file = "app/Delphinus_Controller.php" 
    34controller_class = "Delphinus_Controller" 
  • websites/planet.php.gr.jp/trunk/app/Ethna_AuthActionClass.php

    r12955 r12961  
    1717 *  @package    Anubis 
    1818 * 
    19  * $config = array( 
    20  *     'base_url' => 'http://example.com/index.php', 
    21  *     'author'   => 'typekey_username', 
    22  *     'typekey_token' => 'typekey_token', 
    23  * );     
    2419 */ 
    2520class Ethna_AuthActionClass extends Ethna_ActionClass 
    2621{ 
    2722 
    28     /** 
    29      * Typekey Object 
    30      * @var     object 
    31      * @access  protected 
    32      */ 
    33     var $TypeKey; 
    34  
    35     var $typekey_token; 
    36     var $signin_url; 
    37     var $signout_url; 
    38      
    39     //{{{ authenticate() 
    4023    /** 
    4124     * authentication 
     
    4427    function authenticate() 
    4528    { 
    46         if ($this->session->isStart()) { 
    47             //session_start(); 
    48             return null; 
     29        if (!$this->session->isStart()) { 
     30            $config = $this->config->get('auth'); 
     31            if (!isset($config['type'])) { 
     32                $error_message = 'システム設定が正しく行われていません。認証設定を見直してください。'; 
     33                $error_message = mb_convert_encoding($error_message, 'UTF-8', 'EUC-JP'); 
     34                $this->ae->add('config_error', $error_message); 
     35                return 'error'; 
     36            } else if ($config['type'] == 'none') { 
     37 
     38                // none 
     39 
     40            } else { 
     41                $this->redirect('/login'); 
     42            } 
    4943        } 
    50          
    51         $typekey_url = "http://".$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 
    52         $base_url = $this->config->get('base_url'); 
    53         $author = $this->config->get('author'); 
    54          
    55         if ( !is_array($author) ) { 
    56             $author = array($author); 
    57         } 
    58          
    59         //set typekey token from config 
    60         $this->typekey_token = $this->config->get('typekey_token'); 
    61         
    62         $this->TypeKey = new Auth_TypeKey(); 
    63         $this->TypeKey->site_token($this->typekey_token); 
    64         $this->TypeKey->version('1.1'); 
    65          
    66         $this->signin_url = $this->TypeKey->urlSignIn($typekey_url); 
    67         $this->signout_url = $this->TypeKey->urlSignOut($base_url); 
    68          
    69         $this->af->setApp('signout_url', $this->signout_url); 
    7044 
    71         if ( is_null($this->session->get('name')) || 
    72              !in_array($this->session->get('name'), $author) ) { 
    73          
    74             if( $this->authTypeKey($_GET) === TRUE ){ 
    75             //if( TRUE ){ 
    76              
    77                 //typekey user not defined allow list 
    78                 //if ( !in_array($_GET['name'], $author) ) { 
    79                      
    80                 //    $this->session->destroy(); 
    81                 //    Aero_Util::move($this->signout_url, "3"); 
    82                 //    //header('Location: ' . $this->signout_url); 
    83                 //    exit(); 
    84                  
    85                 //} 
    86                  
    87                 //success 
    88                 $this->session->start(); 
    89                 $this->session->set('name', $_GET['name']); 
    90                  
    91                 return null; 
    92              
    93             } else { 
     45        return parent::authenticate(); 
     46    } 
    9447 
    95                 //$this->session->destroy(); 
    96                 print("fail auth typekey"); 
    97                 Aero_Util::move($this->signout_url, "5"); 
    98                 exit(); 
    99              
    100             } 
    101        } 
    102  
    103        return null; 
    104         
     48    /** 
     49     * redirect 
     50     * 
     51     * @access public 
     52     */ 
     53    function redirect($action = "") 
     54    { 
     55        $url = $this->config->get('base_url') . $action; 
     56        $html = <<<EOD 
     57<html> 
     58<head> 
     59<meta http-equiv="Content-type" content="text/html; charset=EUC-JP"> 
     60<meta http-equiv="refresh" CONTENT="0;URL={$url}"> 
     61<meta name="robots" content="INDEX,NOFOLLOW"> 
     62<title>Redirecting to {$url}</title> 
     63</head> 
     64<body> 
     65<p>if not start redirect, click <a href="{$url}">this link</a></p> 
     66</body> 
     67</html> 
     68EOD; 
     69        print($html); 
     70        exit(); 
    10571    } 
    106     //}}} 
    107  
    108     //{{{ authTypeKey() 
    109     /** 
    110      * authTypeKey 
    111      * 
    112      * $query = array( 
    113      *  'ts' => '', 
    114      *  'email' => '', 
    115      *  'name' => '', 
    116      *  'nick' => '', 
    117      *  'sig' => '', 
    118      * ) 
    119      * 
    120      * @access protected 
    121      */ 
    122     function authTypeKey($query){ 
    123      
    124         $result = isset($query['ts']) 
    125             && isset($query['email']) 
    126             && isset($query['name']) 
    127             && isset($query['nick']) 
    128             && isset($query['sig']); 
    129          
    130         if($result){ 
    131          
    132             $result = $this->TypeKey->verifyTypeKey($query); 
    133  
    134             if (PEAR::isError($result)) { 
    135                  
    136                 if($result->getMessage() == 'Timestamp from TypeKey is too old'){ 
    137                     header('Location: ' . $this->signout_url); 
    138                     exit(); 
    139                      
    140                 } 
    141  
    142                 if($result->getMessage() == 'Invalid signature'){ 
    143                     Ethna::raiseNotice('TypeKey Invalid signature'); 
    144                     return true; 
    145                 } 
    146                  
    147                 Ethna::raiseError($result->getMessage()); 
    148                 var_dump($result->getMessage()); 
    149                 return false; 
    150                  
    151             } else { 
    152                  
    153                 return true; 
    154              
    155             } 
    156              
    157         } else { 
    158              
    159             //header('Location: ' . $this->signin_url); 
    160             Aero_Util::move($this->signin_url, "0"); 
    161             exit(); 
    162          
    163         } 
    164     } 
    165     //}}} 
    16672 
    16773} 
  • websites/planet.php.gr.jp/trunk/etc/delphinus-ini.php.default

    r12921 r12961  
    1717 
    1818    //using typekey account by Administration    
    19     'author' => array('typekey_username'), 
    20     'typekey_token' => '', 
     19    'auth' => array( 
     20        'type' => 'typekey', // typekey or hatena 
     21 
     22        //for typekey setting 
     23        'author' => array('your accountname'), 
     24        'typekey_url' => 'http://example.com/to/delphinus', 
     25        'typekey_token' => 'your typekey token', 
     26 
     27        //'any' or 'id' or array('id1', 'id2', 'id3') 
     28        'hatena_id' => array('your hatena id'), 
     29        'hatena_api_key' => '', 
     30        'hatena_api_secret' => '', 
     31    ), 
    2132 
    2233    //delphinus system setting 
  • websites/planet.php.gr.jp/trunk/www/css/ethna.css

    r12921 r12961  
    11body { 
    2         background: url("http://ethna.jp/image/pagebg.gif"); 
    3         font-family: Arial,Verdana,Helvetica,'MS UI Gothic',sans-serif; 
    4         margin-left: 40px; 
    5         margin-right: 40px; 
     2    background: url("http://ethna.jp/image/pagebg.gif"); 
     3    font-family: Arial,Verdana,Helvetica,'MS UI Gothic',sans-serif; 
     4    margin-left: 40px; 
     5    margin-right: 40px; 
    66} 
    77 
    88div#header { 
    9         margin-top: 40px; 
    10         margin-bottom: 1em; 
    11         padding: 0px 20px; 
    12         height: 40px; 
    13         background: url("http://ethna.jp/image/navbg.gif") repeat-x; 
     9    margin-top: 40px; 
     10    margin-bottom: 1em; 
     11    padding: 0px 20px; 
     12    height: 40px; 
     13    background: url("http://ethna.jp/image/navbg.gif") repeat-x; 
    1414} 
    1515 
    1616div#header h1 { 
    17         font-weight: bold; 
    18         background: url("http://ethna.jp/image/navlogo.gif") right no-repeat; 
     17    font-weight: bold; 
     18    background: url("http://ethna.jp/image/navlogo.gif") right no-repeat; 
    1919} 
    2020 
    2121div#footer { 
    22         margin-bottom: 1em; 
    23         padding: 5px 20px; 
    24         background-color: #cee6e6; 
    25         text-align: right; 
     22    margin-bottom: 1em; 
     23    padding: 5px 20px; 
     24    background-color: #cee6e6; 
     25    text-align: right; 
    2626} 
    2727 
    2828div#footer a { 
    29         color: #f35a21; 
     29    color: #f35a21; 
    3030} 
    3131 
    3232div#main { 
    33         margin-bottom: 1em; 
    34         padding: 10px 20px; 
    35         border: 1px solid #cee6e6; 
    36         background-color: #ffffff; 
     33    margin-bottom: 1em; 
     34    padding: 10px 20px; 
     35    border: 1px solid #cee6e6; 
     36    background-color: #ffffff; 
    3737} 
    3838 
    3939div#main h2 { 
    40         color: #00cccc; 
    41         border: 1px solid #cee6e6; 
    42         border-width: 0 0 1px 0; 
     40    color: #00cccc; 
     41    border: 1px solid #cee6e6; 
     42    border-width: 0 0 1px 0; 
    4343} 
    4444 
     
    5050    color: #f29578; 
    5151} 
     52 
     53span.ethna-error { 
     54    color: #ff0000; 
     55} 
  • websites/planet.php.gr.jp/trunk/www/info.php

    r12921 r12961  
    11<?php 
    2 /** 
    3  * Delphinus Debug Info 
    4  * 
    5  * @package Delphinus 
    6  * @author halt <halt.hde@gmail.com> 
    7  */ 
    8 include_once('/home/halt/codes/delphinus/app/Delphinus_Controller.php'); 
     2include_once( dirname( dirname(__FILE__) ). '/app/Delphinus_Controller.php'); 
    93 
    10 define('ETHNA_DEBUG', true); 
    11  
    12 Delphinus_Controller::main( 
    13     'Delphinus_Controller', 
    14     array('__ethna_info__') 
     4Delphinus_Controller::main('Delphinus_Controller', array( 
     5    '__ethna_info__', 
     6    ) 
    157); 
    168?> 
  • websites/planet.php.gr.jp/trunk/www/unittest.php

    r12921 r12961  
    11<?php 
    22error_reporting(E_ALL); 
    3 include_once '/home/halt/codes/delphinus/app/Delphinus_Controller.php'; 
     3require_once '/home/ha1t/codes/delphinus/app/Delphinus_Controller.php'; 
    44 
    55Delphinus_Controller::main('Delphinus_Controller', array( 
  • websites/planet.php.gr.jp/trunk/www/xmlrpc.php

    r12921 r12961  
    11<?php 
    2 include_once('/home/halt/codes/delphinus/app/Delphinus_Controller.php'); 
     2require_once '/home/ha1t/codes/delphinus/app/Delphinus_Controller.php'; 
    33 
    44Delphinus_Controller::main_XMLRPC('Delphinus_Controller');