Plugin Directory

Changeset 366470


Ignore:
Timestamp:
03/29/2011 06:39:46 PM (15 years ago)
Author:
AdamBackstrom
Message:

cas/validate should be CAS 1.0 (plain text), cas/serviceValidate should be CAS 2.0 (xml).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wpcas-server/trunk/wpcas-server.php

    r344653 r366470  
    6666            case '/cas/logout/':
    6767            case '/cas/logout' : self::logout(); break;
     68            case '/cas/validate/':
     69            case '/cas/validate' : self::validate(); break;
    6870            case '/cas/proxyValidate/':
    6971            case '/cas/proxyValidate' :
    70             case '/cas/validate/':
    71             case '/cas/validate' : self::validate(); break;
     72            case '/cas/serviceValidate/':
     73            case '/cas/serviceValidate' : self::serviceValidate(); break;
    7274            default : self::fail(); break;
    7375        }//end switch
     
    122124    /**
    123125     * validate a given ticket
     126     * @return string user id
    124127     */
    125     public function validate()
     128    public function _validate()
    126129    {
    127130        self::session_start();
    128 
    129131
    130132        $path = self::get_path();
     
    133135        $decrypted_ticket = str_rot13($ticket);
    134136
     137        if( isset( $_GET['ticket'] ) && $user_id = wp_validate_auth_cookie( $decrypted_ticket, 'auth' ) ) {
     138            return $user_id;
     139        }
     140    }//end _validate
     141
     142    /**
     143     * CAS 2.0 serviceValidate.
     144     */
     145    public function serviceValidate() {
    135146        $response = '<cas:serviceResponse xmlns:cas="'.get_bloginfo('url').'/cas">'."\n";
    136         if( isset( $_GET['ticket'] ) && $user_id = wp_validate_auth_cookie( $decrypted_ticket, 'auth' ))
    137         {
     147
     148        if( $user_id = self::_validate() ) {
    138149            $auth_value = apply_filters('wpcas_server_auth_value', $user_id);
    139150
     
    148159        $response .= '</cas:serviceResponse>';
    149160 
    150         die($response);
     161        die( $response );
     162    }//end serviceValidate
     163
     164    /**
     165     * CAS 1.0 validate.
     166     */
     167    public function validate() {
     168        if( $user_id = self::_validate() ) {
     169            $auth_value = apply_filters('wpcas_server_auth_value', $user_id);
     170            $response = "yes\n{$auth_value}\n";
     171        } else {
     172            $response = "no\n\n";
     173        }
     174
     175        die( $response );
    151176    }//end validate
    152177}//end class wpCAS_server
Note: See TracChangeset for help on using the changeset viewer.