3 * StatusNet, the distributed open-source microblogging tool
5 * Plugin to enable Single Sign On via CAS (Central Authentication Service)
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Craig Andrews <candrews@integralblue.com>
25 * @copyright 2009 Craig Andrews http://candrews.integralblue.com
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
34 // We bundle the phpCAS library...
35 set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/extlib/CAS');
37 require_once INSTALLDIR.'/plugins/Authentication/AuthenticationPlugin.php';
38 class CasAuthenticationPlugin extends AuthenticationPlugin
44 function checkPassword($username, $password)
46 global $casTempPassword;
47 return ($casTempPassword == $password);
50 function onAutoload($cls)
55 require_once(INSTALLDIR.'/plugins/CasAuthentication/extlib/CAS.php');
57 case 'CasloginAction':
58 require_once(INSTALLDIR.'/plugins/CasAuthentication/' . strtolower(mb_substr($cls, 0, -6)) . '.php');
61 return parent::onAutoload($cls);
65 function onStartInitializeRouter($m)
67 $m->connect('main/cas', array('action' => 'caslogin'));
71 function onEndLoginGroupNav(&$action)
73 $action_name = $action->trimmed('action');
75 $action->menuItem(common_local_url('caslogin'),
77 _m('Login or register with CAS'),
78 $action_name === 'caslogin');
83 function onEndShowPageNotice($action)
85 $name = $action->trimmed('action');
90 $instr = '(Have an account with CAS? ' .
91 'Try our [CAS login]'.
92 '(%%action.caslogin%%)!)';
98 $output = common_markup_to_html($instr);
99 $action->raw($output);
103 function onLoginAction($action, &$login)
115 function onInitializePlugin(){
116 parent::onInitializePlugin();
117 if(!isset($this->server)){
118 throw new Exception("must specify a server");
120 if(!isset($this->port)){
121 throw new Exception("must specify a port");
123 if(!isset($this->path)){
124 throw new Exception("must specify a path");
126 //These values need to be accessible to a action object
127 //I can't think of any other way than global variables
128 //to allow the action instance to be able to see values :-(
130 $casSettings = array();
131 $casSettings['server']=$this->server;
132 $casSettings['port']=$this->port;
133 $casSettings['path']=$this->path;