Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
81.82% |
9 / 11 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
Shibboleth | |
81.82% |
9 / 11 |
|
50.00% |
1 / 2 |
3.05 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
getPermissions | |
60.00% |
3 / 5 |
|
0.00% |
0 / 1 |
2.26 |
1 | <?php |
2 | |
3 | /** |
4 | * Shibboleth permission provider for VuFind. |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2007. |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2, |
12 | * as published by the Free Software Foundation. |
13 | * |
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 General Public License for more details. |
18 | * |
19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 | * |
23 | * @category VuFind |
24 | * @package Authorization |
25 | * @author Demian Katz <demian.katz@villanova.edu> |
26 | * @author Jochen Lienhard <lienhard@ub.uni-freiburg.de> |
27 | * @author Bernd Oberknapp <bo@ub.uni-freiburg.de> |
28 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
29 | * @link https://vufind.org Main Page |
30 | */ |
31 | |
32 | namespace VuFind\Role\PermissionProvider; |
33 | |
34 | use Laminas\Http\PhpEnvironment\Request; |
35 | use VuFind\Auth\Shibboleth as ShibbolethAuth; |
36 | |
37 | /** |
38 | * Shibboleth permission provider for VuFind. |
39 | * |
40 | * @category VuFind |
41 | * @package Authorization |
42 | * @author Demian Katz <demian.katz@villanova.edu> |
43 | * @author Jochen Lienhard <lienhard@ub.uni-freiburg.de> |
44 | * @author Bernd Oberknapp <bo@ub.uni-freiburg.de> |
45 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
46 | * @link https://vufind.org Main Page |
47 | */ |
48 | class Shibboleth extends ServerParam |
49 | { |
50 | /** |
51 | * Request object |
52 | * |
53 | * @var Request |
54 | */ |
55 | protected $request; |
56 | |
57 | /** |
58 | * Server param with the identity provider entityID |
59 | * |
60 | * @var string |
61 | */ |
62 | protected $idpServerParam; |
63 | |
64 | /** |
65 | * Constructor |
66 | * |
67 | * @param Request $request Request object |
68 | * @param \Laminas\Config\Config $config VuFind configuration |
69 | */ |
70 | public function __construct(Request $request, $config) |
71 | { |
72 | parent::__construct($request); |
73 | |
74 | $this->idpServerParam = $config->Shibboleth->idpserverparam |
75 | ?? ShibbolethAuth::DEFAULT_IDPSERVERPARAM; |
76 | |
77 | $this->aliases = ['idpentityid' => $this->idpServerParam]; |
78 | $this->serverParamDelimiter = ';'; |
79 | $this->serverParamEscape = '\\'; |
80 | } |
81 | |
82 | /** |
83 | * Return an array of roles which may be granted the permission based on |
84 | * the options. |
85 | * |
86 | * @param mixed $options Options provided from configuration. |
87 | * |
88 | * @return array |
89 | */ |
90 | public function getPermissions($options) |
91 | { |
92 | $this->debug('getPermissions: idpServerParam = ' . $this->idpServerParam); |
93 | if ($this->request->getServer()->get($this->idpServerParam) === null) { |
94 | $this->logWarning('getPermissions: Shibboleth server params missing'); |
95 | |
96 | return []; |
97 | } |
98 | |
99 | return parent::getPermissions($options); |
100 | } |
101 | } |