|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* simpleSAMLphp-casserver is a CAS 1.0 and 2.0 compliant CAS server in the form of a simpleSAMLphp module |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright (C) 2013 Bjorn R. Jensen |
|
7
|
|
|
* |
|
8
|
|
|
* This library is free software; you can redistribute it and/or |
|
9
|
|
|
* modify it under the terms of the GNU Lesser General Public |
|
10
|
|
|
* License as published by the Free Software Foundation; either |
|
11
|
|
|
* version 2.1 of the License, or (at your option) any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* This library is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16
|
|
|
* Lesser General Public License for more details. |
|
17
|
|
|
* |
|
18
|
|
|
* You should have received a copy of the GNU Lesser General Public |
|
19
|
|
|
* License along with this library; if not, write to the Free Software |
|
20
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
21
|
|
|
* |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
namespace SimpleSAML\Module\casserver\Cas\Ticket; |
|
25
|
|
|
|
|
26
|
|
|
class FileSystemTicketStore extends TicketStore |
|
|
|
|
|
|
27
|
|
|
{ |
|
28
|
|
|
private $pathToTicketDirectory; |
|
29
|
|
|
|
|
30
|
|
|
public function __construct(\SimpleSAML\Configuration $config) |
|
|
|
|
|
|
31
|
|
|
{ |
|
32
|
|
|
$storeConfig = $config->getValue('ticketstore', ['directory' => 'ticketcache']); |
|
33
|
|
|
|
|
34
|
|
|
if (!is_string($storeConfig['directory'])) { |
|
35
|
|
|
throw new Exception('Invalid directory option in config.'); |
|
|
|
|
|
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
$path = $config->resolvePath($storeConfig['directory']); |
|
39
|
|
|
|
|
40
|
|
|
if (!is_dir($path)) { |
|
41
|
|
|
throw new Exception('Directory for CAS Server ticket storage ['.$path.'] does not exists.'); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
if (!is_writable($path)) { |
|
45
|
|
|
throw new Exception('Directory for CAS Server ticket storage ['.$path.'] is not writable.'); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
$this->pathToTicketDirectory = preg_replace('/\/$/', '', $path); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @param $ticketId string |
|
53
|
|
|
* @return array|null |
|
54
|
|
|
*/ |
|
55
|
|
|
public function getTicket($ticketId) |
|
56
|
|
|
{ |
|
57
|
|
|
$filename = $this->pathToTicketDirectory.'/'.$ticketId; |
|
58
|
|
|
|
|
59
|
|
|
if (file_exists($filename)) { |
|
60
|
|
|
$content = file_get_contents($filename); |
|
61
|
|
|
|
|
62
|
|
|
return unserialize($content); |
|
63
|
|
|
} else { |
|
64
|
|
|
return null; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function addTicket(array $ticket) |
|
69
|
|
|
{ |
|
70
|
|
|
$filename = $this->pathToTicketDirectory.'/'.$ticket['id']; |
|
71
|
|
|
file_put_contents($filename, serialize($ticket)); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param $ticketId string |
|
76
|
|
|
*/ |
|
77
|
|
|
public function deleteTicket($ticketId) |
|
78
|
|
|
{ |
|
79
|
|
|
$filename = $this->pathToTicketDirectory.'/'.$ticketId; |
|
80
|
|
|
|
|
81
|
|
|
if (file_exists($filename)) { |
|
82
|
|
|
unlink($filename); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths