/
auth.php
84 lines (65 loc) · 1.79 KB
/
auth.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/**
* DokuWiki Plugin authsaml (Auth Component).
*
* @author Sixto Martin <sixto.martin.garcia@gmail.com>
* @author Andreas Aakre Solberg, UNINETT, http://www.uninett.no
* @author François Kooman
* @author Thijs Kinkhorst, Universiteit van Tilburg
* @author Jorge Hervás <jordihv@gmail.com>, Lukas Slansky <lukas.slansky@upce.cz>
* @license GPL2 http://www.gnu.org/licenses/gpl.html
* @link https://github.com/pitbulk/dokuwiki-saml
*/
// must be run within Dokuwiki
if (! defined('DOKU_INC'))
die();
class auth_plugin_authsaml extends DokuWiki_Auth_Plugin
{
/**
* simplesamlphp auth instance
*
* @var object
*/
protected $saml;
/**
* Constructor.
*/
public function __construct()
{
global $conf;
parent::__construct();
// $this->cando['external'] = true;
$this->cando['modGroups'] = true;
$this->cando['external'] = true;
$this->cando['logoff'] = true;
$this->success = true;
require_once('saml.php');
$this->loadConfig();
$this->saml = new saml_handler($this->conf);
}
/**
* Get user data
*
* @return string|null
*/
public function getUserData($user, $requireGroups = true)
{
return $this->saml->getUserData($user);
}
public function checkPass($user, $pass) {
return $this->saml->checkPass($user);
}
/**
* {@inheritdoc}
* @see DokuWiki_Auth_Plugin::trustExternal()
*/
public function trustExternal($user, $pass, $sticky = false)
{
$this->saml->get_ssp_instance();
if ($this->saml->ssp->isAuthenticated()) {
$username = $this->saml->getUsername();
return $this->saml->login($username);
}
return false;
}
}