1
1
<?php
2
+ /**
3
+ * Redis store for simpleSAMLphp
4
+ *
5
+ * This store uses the Redis document store to store data from simpleSAMLphp.
6
+ * It implements the simpleSAMLphp datastore API, for easy integration with
7
+ * other parts of simpleSAMLphp.
8
+ *
9
+ * @author Jacob Christiansen [email protected]
10
+ * @copyright 2015 Colourbox ApS
11
+ * @license http://opensource.org/licenses/MIT MIT-license
12
+ */
2
13
class sspmod_redis_Store_Redis extends SimpleSAML_Store
3
14
{
4
15
protected function __construct ()
5
16
{
6
- $ config = SimpleSAML_Configuration::getConfig ('module_redis.php ' );
7
- $ host = $ config ->getString ('host ' , 'localhost ' );
8
- $ this ->redis = new Predis \Client ($ host );
17
+ $ redisConfig = SimpleSAML_Configuration::getConfig ('module_redis.php ' );
18
+ $ globalConfig = SimpleSAML_Configuration::getConfig ();
19
+
20
+ $ this ->redis = new Predis \Client ($ redisConfig ->getString ('host ' , 'localhost ' ));
21
+ $ this ->prefix = $ redisConfig ->getString ('prefix ' , 'simpleSAMLphp ' );
9
22
$ this ->lifeTime = $ globalConfig ->getInteger ('session.duration ' , 28800 ); // Default 8 hours
10
23
}
11
24
@@ -18,7 +31,7 @@ protected function __construct()
18
31
*/
19
32
public function get ($ type , $ key )
20
33
{
21
- $ redisKey = "simpleSAMLphp .$ type. $ key " ;
34
+ $ redisKey = "{ $ this -> prefix } . $ type. $ key " ;
22
35
$ value = $ this ->redis ->get ($ redisKey );
23
36
24
37
return unserialize ($ value );
@@ -37,7 +50,7 @@ public function get($type, $key)
37
50
*/
38
51
public function set ($ type , $ key , $ value , $ expire = null )
39
52
{
40
- $ redisKey = "simpleSAMLphp .$ type. $ key " ;
53
+ $ redisKey = "{ $ this -> prefix } . $ type. $ key " ;
41
54
$ this ->redis ->set ($ redisKey , serialize ($ value ));
42
55
43
56
if (is_null ($ expire )) {
@@ -54,7 +67,7 @@ public function set($type, $key, $value, $expire = null)
54
67
*/
55
68
public function delete ($ type , $ key )
56
69
{
57
- $ redisKey = "simpleSAMLphp .$ type. $ key " ;
70
+ $ redisKey = "{ $ this -> prefix } . $ type. $ key " ;
58
71
$ this ->redis ->del ($ redisKey );
59
72
}
60
73
}
0 commit comments