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 TicketFactory |
27
|
|
|
{ |
28
|
|
|
private $serviceTicketExpireTime; |
29
|
|
|
private $proxyGrantingTicketExpireTime; |
30
|
|
|
private $proxyTicketExpireTime; |
31
|
|
|
|
32
|
|
|
public function __construct(\SimpleSAML\Configuration $config) |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
$this->serviceTicketExpireTime = $config->getValue('service_ticket_expire_time', 5); |
35
|
|
|
$this->proxyGrantingTicketExpireTime = $config->getValue('proxy_granting_ticket_expire_time', 3600); |
36
|
|
|
$this->proxyTicketExpireTime = $config->getValue('proxy_ticket_expire_time', 5); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param $sessionId string |
41
|
|
|
* @param $expiresAt int |
42
|
|
|
* @return array |
43
|
|
|
*/ |
44
|
|
|
public function createSessionTicket($sessionId, $expiresAt) |
45
|
|
|
{ |
46
|
|
|
return [ |
47
|
|
|
'id' => $sessionId, |
48
|
|
|
'validBefore' => $expiresAt, |
49
|
|
|
'renewId' => SimpleSAML\Utils\Random::generateID() |
|
|
|
|
50
|
|
|
]; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param $content array |
55
|
|
|
* @return array |
56
|
|
|
*/ |
57
|
|
|
public function createServiceTicket(array $content) |
58
|
|
|
{ |
59
|
|
|
$id = str_replace('_', 'ST-', SimpleSAML\Utils\Random::generateID()); |
60
|
|
|
$expiresAt = time() + $this->serviceTicketExpireTime; |
61
|
|
|
|
62
|
|
|
return array_merge(['id' => $id, 'validBefore' => $expiresAt], $content); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param $content array |
67
|
|
|
* @return array |
68
|
|
|
*/ |
69
|
|
|
public function createProxyGrantingTicket(array $content) |
70
|
|
|
{ |
71
|
|
|
$id = str_replace('_', 'PGT-', SimpleSAML\Utils\Random::generateID()); |
72
|
|
|
$iou = str_replace('_', 'PGTIOU-', SimpleSAML\Utils\Random::generateID()); |
73
|
|
|
|
74
|
|
|
$expireAt = time() + $this->proxyGrantingTicketExpireTime; |
75
|
|
|
|
76
|
|
|
return array_merge(['id' => $id, 'iou' => $iou, 'validBefore' => $expireAt], $content); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param $content array |
81
|
|
|
* @return array |
82
|
|
|
*/ |
83
|
|
|
public function createProxyTicket(array $content) |
84
|
|
|
{ |
85
|
|
|
$id = str_replace('_', 'PT-', SimpleSAML\Utils\Random::generateID()); |
86
|
|
|
$expiresAt = time() + $this->proxyTicketExpireTime; |
87
|
|
|
|
88
|
|
|
return array_merge(['id' => $id, 'validBefore' => $expiresAt], $content); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @param $ticket array |
93
|
|
|
* @return int|false |
94
|
|
|
*/ |
95
|
|
|
public function isSessionTicket(array $ticket) |
96
|
|
|
{ |
97
|
|
|
return preg_match('/^[a-zA-Z0-9]+$/D', $ticket['id']); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param $ticket array |
102
|
|
|
* @return int|false |
103
|
|
|
*/ |
104
|
|
|
public function isServiceTicket(array $ticket) |
105
|
|
|
{ |
106
|
|
|
return preg_match('/^ST-?[a-zA-Z0-9]+$/D', $ticket['id']); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param $ticket array |
111
|
|
|
* @return int|false |
112
|
|
|
*/ |
113
|
|
|
public function isProxyGrantingTicket(array $ticket) |
114
|
|
|
{ |
115
|
|
|
return preg_match('/^PGT-?[a-zA-Z0-9]+$/D', $ticket['id']); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param $ticket array |
120
|
|
|
* @return int|false |
121
|
|
|
*/ |
122
|
|
|
public function isProxyTicket(array $ticket) |
123
|
|
|
{ |
124
|
|
|
return preg_match('/^PT-?[a-zA-Z0-9]+$/D', $ticket['id']); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @param $ticket array |
129
|
|
|
* @return bool |
130
|
|
|
*/ |
131
|
|
|
public function isExpired(array $ticket) |
132
|
|
|
{ |
133
|
|
|
return !array_key_exists('validBefore', $ticket) || $ticket['validBefore'] < time(); |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
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