Skip to content

Commit 2fdd644

Browse files
author
Frank Tamás
committed
Initial commit
0 parents  commit 2fdd644

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

composer.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "niif/simplesamlphp-module-ftickslogger",
3+
"description": "F-TICKS logger for simplesamlphp",
4+
"type": "simplesamlphp-module",
5+
"require": {
6+
"simplesamlphp/composer-module-installer": "~1.0"
7+
}
8+
}

default-disable

Whitespace-only changes.

lib/Auth/Process/ftickslogger.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* F-TICKS logger Authentication Processing filter
4+
*
5+
* @author Tamas Frank <sitya@niif.hu>
6+
* @package simpleSAMLphp
7+
* @version $Id$
8+
*/
9+
class sspmod_ftickslogger_Auth_Process_ftickslogger extends SimpleSAML_Auth_ProcessingFilter
10+
{
11+
12+
/**
13+
* The attribute to log
14+
*/
15+
private $attribute = NULL;
16+
private $secretsalt = NULL;
17+
18+
private $typeTag = 'FTICKS/eduid.hu/1.0/';
19+
20+
/**
21+
* Initialize this filter.
22+
*
23+
* @param array $config Configuration information about this filter.
24+
* @param mixed $reserved For future use.
25+
*/
26+
public function __construct($config, $reserved) {
27+
parent::__construct($config, $reserved);
28+
29+
assert('is_array($config)');
30+
31+
if (array_key_exists('attributename', $config)) {
32+
$this->attribute = $config['attributename'];
33+
if (!is_string($this->attribute)) {
34+
throw new Exception('Invalid attribute name given to fticklogger filter.');
35+
}
36+
}
37+
38+
if (array_key_exists('secretsalt', $config)) {
39+
$this->secretsalt = $config['secretsalt'];
40+
if (!is_string($this->secretsalt)) {
41+
throw new Exception('Invalid secretsalt given to fticklogger filter.');
42+
}
43+
}
44+
45+
}
46+
47+
48+
/**
49+
* Log line.
50+
*
51+
* @param array &$state The current state.
52+
*/
53+
public function process(&$state) {
54+
assert('is_array($state)');
55+
assert('array_key_exists("Attributes", $state)');
56+
57+
$TS = time();
58+
$AP = 'NA';
59+
$RP = 'NA';
60+
$PN = 'NA';
61+
$AM = 'urn:oasis:names:tc:SAML:2.0:ac:classes:Password';
62+
63+
if (array_key_exists($this->attribute, $state['Attributes'])) {
64+
$PN = hash('sha256', $state['Attributes'][$this->attribute][0] . $this->secretsalt);
65+
}
66+
if (array_key_exists('Source', $state)) {
67+
$AP = $state['Source']['entityid'];
68+
}
69+
70+
if (array_key_exists('Destination', $state)) {
71+
$RP = $state['Destination']['entityid'];
72+
}
73+
74+
SimpleSAML_Logger::stats($this->typeTag . '#TS=' . $TS . '#AP=' . $AP . '#RP=' . $RP . '#PN=' . $PN . '#AM=' . $AM . '#');
75+
}
76+
77+
}

0 commit comments

Comments
 (0)