Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit 07b6aa2

Browse files
committed
Added MULTI_IDP mode
1 parent bec59ef commit 07b6aa2

File tree

7 files changed

+36
-9
lines changed

7 files changed

+36
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
All notable changes to this project will be documented in this file.
33

44
## [Unreleased]
5+
#### Added
6+
- Added MULTI_IDP mode
57

68
## [v4.1.0]
79
#### Removed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Once you have installed SimpleSAMLphp, installing this module is very simple. Fi
1717
2. For this database run script to create tables. Script is available in config-templates/tables.sql.
1818
3. Copy config-templates/module_proxystatistics.php to your config folder and fill it.
1919
4. Configure, according to mode
20-
* for PROXY mode, configure IdPAttribute filter from Perun module to get sourceIdPName from IdP metadata:
20+
21+
* PROXY - collects data about number of logins from each identity provider and accessed services; for PROXY mode, configure IdPAttribute filter from Perun module to get sourceIdPName from IdP metadata:
2122
```
2223
50 => [
2324
'class' => 'perun:IdPAttribute',
@@ -27,20 +28,27 @@ Once you have installed SimpleSAMLphp, installing this module is very simple. Fi
2728
],
2829
// where 50 is priority (for example, must not be used for other modules)
2930
```
30-
* for IDP mode, configure entity ID and name in `module_proxystatistics.php`
31+
* IDP - collects data about accessed services through given identity provider; for IDP mode, configure entity ID and name in `module_proxystatistics.php`
3132
```
3233
'IDP' => [
3334
'id' => '',
3435
'name' => '',
3536
],
3637
```
37-
* for SP mode, configure entity ID and name in `module_proxystatistics.php`
38+
* SP - collects data about identity providers used for access to given service; for SP mode, configure entity ID and name in `module_proxystatistics.php`
3839
```
3940
'SP' => [
4041
'id' => '',
4142
'name' => '',
4243
],
4344
```
45+
* MULTI_IDP - similar to IDP mode, stores more identity providers in one database; for MULTI_IDP mode, configure entity ID and name in each `module_proxystatistics.php` we want to get statistics from
46+
```
47+
'IDP' => [
48+
'id' => '',
49+
'name' => '',
50+
],
51+
```
4452
5. Configure proxystatistics filter
4553
```
4654
50 => [

config-templates/module_proxystatistics.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@
1111
$config = [
1212

1313
/*
14-
* Choose one of the following modes: PROXY, IDP, SP
14+
* Choose one of the following modes: PROXY, IDP, SP, MULTI_IDP
15+
* PROXY - collects data about number of logins from each identity provider and accessed services
16+
* IDP - collects data about accessed services through given identity provider
17+
* SP - collects data about identity providers used for access to given service
18+
* MULTI_IDP - similar to IDP mode, stores more identity providers in one database
1519
*/
1620
'mode' => 'PROXY',
1721

1822
/*
1923
* EntityId and name of IdP
20-
* REQUIRED FOR IDP MODE
24+
* REQUIRED FOR IDP AND MULTI_IDP MODE
2125
*/
2226
//'IDP' => [
2327
// 'id' => '',

dictionaries/stats.definition.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@
143143
"en": "identity provider",
144144
"cs": "poskytovatele identity"
145145
},
146+
"through_mode_MULTI_IDP": {
147+
"en": "identity provider",
148+
"cs": "poskytovatele identity"
149+
},
146150
"summary_logins_info": {
147151
"en": "The chart shows overall number of logins from identity providers for each day.",
148152
"cs": "Graf zobrazuje počet přihlášení za každý den."

lib/Config.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class Config
1616

1717
public const MODE_SP = 'SP';
1818

19+
public const MODE_MULTI_IDP = 'MULTI_IDP';
20+
1921
public const SIDES = [self::MODE_IDP, self::MODE_SP];
2022

2123
public const MODE_PROXY = 'PROXY';
@@ -43,7 +45,7 @@ private function __construct()
4345
$this->config = Configuration::getConfig(self::CONFIG_FILE_NAME);
4446
$this->store = $this->config->getConfigItem(self::STORE, null);
4547
$this->tables = $this->config->getArray('tables', []);
46-
$this->mode = $this->config->getValueValidate(self::MODE, ['PROXY', 'IDP', 'SP'], 'PROXY');
48+
$this->mode = $this->config->getValueValidate(self::MODE, ['PROXY', 'IDP', 'SP', 'MULTI_IDP'], 'PROXY');
4749
}
4850

4951
private function __clone()

lib/DatabaseCommand.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ private function getEntities($request)
218218
Config::MODE_IDP => [],
219219
Config::MODE_SP => [],
220220
];
221-
if ($this->mode !== Config::MODE_IDP) {
221+
if ($this->mode !== Config::MODE_IDP && $this->mode !== Config::MODE_MULTI_IDP) {
222222
$entities[Config::MODE_IDP]['id'] = $request['saml:sp:IdP'];
223223
$entities[Config::MODE_IDP]['name'] = $request['Attributes']['sourceIdPName'][0];
224224
}
@@ -227,13 +227,20 @@ private function getEntities($request)
227227
$entities[Config::MODE_SP]['name'] = $request['Destination']['name']['en'] ?? '';
228228
}
229229

230-
if ($this->mode !== Config::MODE_PROXY) {
230+
if ($this->mode !== Config::MODE_PROXY && $this->mode !== Config::MODE_MULTI_IDP) {
231231
$entities[$this->mode] = $this->config->getSideInfo($this->mode);
232232
if (empty($entities[$this->mode]['id']) || empty($entities[$this->mode]['name'])) {
233233
Logger::error('Invalid configuration (id, name) for ' . $this->mode);
234234
}
235235
}
236236

237+
if ($this->mode === Config::MODE_MULTI_IDP) {
238+
$entities[Config::MODE_IDP] = $this->config->getSideInfo(Config::MODE_IDP);
239+
if (empty($entities[$this->mode]['id']) || empty($entities[$this->mode]['name'])) {
240+
Logger::error('Invalid configuration (id, name) for ' . $this->mode);
241+
}
242+
}
243+
237244
return $entities;
238245
}
239246

lib/Templates.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public static function showSummary()
195195
$mode = Config::getInstance()->getMode();
196196
$t->data['mode'] = $mode;
197197
$t->data['summaryGraphs'] = [];
198-
if ($mode === Config::MODE_PROXY) {
198+
if ($mode === Config::MODE_PROXY || $mode === Config::MODE_MULTI_IDP) {
199199
foreach (Config::SIDES as $side) {
200200
$t->data['summaryGraphs'][$side] = [];
201201
$t->data['summaryGraphs'][$side]['Providers'] = 'col-md-6 graph';

0 commit comments

Comments
 (0)