colourbox / simplesamlphp-module-redis
A SimpleSAMLphp module for using Redis for session storage etc.
Installs: 84 634
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 5
Open Issues: 2
Type:simplesamlphp-module
pkg:composer/colourbox/simplesamlphp-module-redis
Requires
- php: ^5.4 || ^7.0
- predis/predis: ~1.0
- simplesamlphp/composer-module-installer: ^1.1
Requires (Dev)
- mayflower/php-codebrowser: ~1.1
- pdepend/pdepend: ~2.0
- phploc/phploc: ~2.0
- phpmd/phpmd: ~2.1
- phpunit/php-invoker: ~1.1
- phpunit/phpunit: ~4.4
- sebastian/phpcpd: ~2.0
- sensiolabs/security-checker: ~2.0
- simplesamlphp/simplesamlphp: ^1.14
- squizlabs/php_codesniffer: ~2.2
- theseer/phpdox: ~0.7
README
Introduction
The Redis module implements the simpleSAMLphp data store API, so Redis can be used for backend storage, i.e. session storage.
Prerequisites
This module requires the following
- simpleSAMLphp v. 1.14.11 (Works with older version, but you should update)
- Redis server, See https://redis.io/ for more information
Installation
First thing to do is to set up your Redis server(s). This is out side the scope of this documentation.
Next you must install this module either by either obtaining the tarball or by installing it via composer. The latter is recommended
composer.phar require colourbox/simplesamlphp-module-redis
This will automatically install "predis/predis" as a dependency for ther module. If you downloaded the module yourself, remember to add predis/predis as a dependency in your composer.json.
See https://github.com/simplesamlphp/composer-module-installer for more information on how to install simpleSAMLphp modules via composer.
You can now enable the module by
touch /var/simplesamlphp/modules/redis/enable
Create /var/simplesamlphp/config/module_redis.php and set appropriate options
for your Redis server. A configuration file template can be found in the
Redis is used as session store for simpleSAMLphp by setting the following options in config.php
'store.type' => 'redis:Redis'
Configuration options
parametersConnection parameters for the underlying predis client. See connection parameters for detailsoptionsClient options for the underlying predis client. See options for detailsprefixKey prefix for all keys stored in RedislifetimeDefault lifetime for non-expiring keys in RedisoldHostconfiguration for old Redis host when doing rolloverparametersConnection parameters for the underlying predis clientoptionsClient options for the underlying predis client
Example
$config = [
// Predis client parameters
'parameters' => 'tcp://localhost:6379',
// Predis client options
'options' => null,
// Key prefix
'prefix' => 'simpleSAMLphp',
// Lifitime for all non expiring keys
'lifetime' => 288000
];
Rollover to new server
The module has build in support for doing rolling update to a new Redis host. All writes are only done to the new host, but all reads will fall back to the old host if the value is not found on new host.
How-to
- Start new Redis host
- Add new host to config file (
parametersandoptions) and add the old host tooldHostoption - Wait until max session lifetime have expired
- Remove
oldHostconfig - Shut down old Redis host
Configuration example
$config = [
// Predis client parameters
'parameters' => 'tcp://newhost:6379',
// Predis client options
'options' => null,
// Old host
'oldHost' => [
// Predis client parameters
'parameters' => 'tcp://oldhost:6379',
// Predis client options
'options' => null,
],
// Key prefix
'prefix' => 'simpleSAMLphp',
// Lifitime for all non expiring keys
'lifetime' => 288000
];