Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
e05a06be
Commit
e05a06be
authored
1 year ago
by
Tim van Dijen
Browse files
Options
Downloads
Patches
Plain Diff
Move core:StatisticsWithAttribute to statistics-module
parent
2b8cef63
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/core/docs/authproc_statisticswithattribute.md
+0
-27
0 additions, 27 deletions
modules/core/docs/authproc_statisticswithattribute.md
modules/core/src/Auth/Process/StatisticsWithAttribute.php
+0
-120
0 additions, 120 deletions
modules/core/src/Auth/Process/StatisticsWithAttribute.php
with
0 additions
and
147 deletions
modules/core/docs/authproc_statisticswithattribute.md
deleted
100644 → 0
+
0
−
27
View file @
2b8cef63
`core:StatisticsWithAttribute`
==============================
This filter logs a statistics entry that can be parsed by the statistics module.
Parameters
----------
`attributename`
: The name of an attribute that should be included in the statistics entry.
`type`
: The type of the statistics entry.
`skipPassive`
: A boolean indicating whether passive requests should be skipped. Defaults to
`false`
, in which case the type tag is prefixed with 'passive-'.
Example
-------
Log the realm of the user:
45 => [
'class' => 'core:StatisticsWithAttribute',
'attributename' => 'realm',
'type' => 'saml20-idp-SSO',
],
This diff is collapsed.
Click to expand it.
modules/core/src/Auth/Process/StatisticsWithAttribute.php
deleted
100644 → 0
+
0
−
120
View file @
2b8cef63
<?php
declare
(
strict_types
=
1
);
namespace
SimpleSAML\Module\core\Auth\Process
;
use
SimpleSAML\
{
Auth
,
Logger
};
use
SimpleSAML\Assert\Assert
;
use
function
array_key_exists
;
use
function
boolval
;
use
function
is_null
;
/**
* Log a line in the STAT log with one attribute.
*
* @package SimpleSAMLphp
*/
class
StatisticsWithAttribute
extends
Auth\ProcessingFilter
{
/**
* The attribute to log
* @var string|null
*/
private
?string
$attribute
=
null
;
/**
* @var string
*/
private
string
$typeTag
=
'saml20-idp-SSO'
;
/**
* @var bool
*/
private
bool
$skipPassive
=
false
;
/**
* Initialize this filter.
*
* @param array &$config Configuration information about this filter.
* @param mixed $reserved For future use.
*/
public
function
__construct
(
array
&
$config
,
$reserved
)
{
parent
::
__construct
(
$config
,
$reserved
);
if
(
array_key_exists
(
'attributename'
,
$config
))
{
Assert
::
stringNotEmpty
(
$config
[
'attributename'
],
'Invalid attribute name given to core:StatisticsWithAttribute filter.'
,
);
$this
->
attribute
=
$config
[
'attributename'
];
}
if
(
array_key_exists
(
'type'
,
$config
))
{
Assert
::
stringNotEmpty
(
$config
[
'type'
],
'Invalid typeTag given to core:StatisticsWithAttribute filter.'
);
$this
->
typeTag
=
$config
[
'type'
];
}
if
(
array_key_exists
(
'skipPassive'
,
$config
))
{
$this
->
skipPassive
=
boolval
(
$config
[
'skipPassive'
]);
}
}
/**
* Log line.
*
* @param array &$state The current state.
*/
public
function
process
(
array
&
$state
):
void
{
Assert
::
keyExists
(
$state
,
'Attributes'
);
$logAttribute
=
'NA'
;
$isPassive
=
''
;
if
(
array_key_exists
(
'isPassive'
,
$state
)
&&
$state
[
'isPassive'
]
===
true
)
{
if
(
$this
->
skipPassive
===
true
)
{
// We have a passive request. Skip logging statistics
return
;
}
$isPassive
=
'passive-'
;
}
if
(
!
is_null
(
$this
->
attribute
)
&&
array_key_exists
(
$this
->
attribute
,
$state
[
'Attributes'
]))
{
$logAttribute
=
$state
[
'Attributes'
][
$this
->
attribute
][
0
];
}
$source
=
$this
->
setIdentifier
(
'Source'
,
$state
);
$dest
=
$this
->
setIdentifier
(
'Destination'
,
$state
);
if
(
!
array_key_exists
(
'PreviousSSOTimestamp'
,
$state
))
{
// The user hasn't authenticated with this SP earlier in this session
Logger
::
stats
(
$isPassive
.
$this
->
typeTag
.
'-first '
.
$dest
.
' '
.
$source
.
' '
.
$logAttribute
);
}
Logger
::
stats
(
$isPassive
.
$this
->
typeTag
.
' '
.
$dest
.
' '
.
$source
.
' '
.
$logAttribute
);
}
/**
* @param string &$direction Either 'Source' or 'Destination'.
* @param array $state The current state.
*
* @return string
*/
private
function
setIdentifier
(
string
$direction
,
array
$state
):
string
{
if
(
array_key_exists
(
$direction
,
$state
))
{
if
(
isset
(
$state
[
$direction
][
'core:statistics-id'
]))
{
return
$state
[
$direction
][
'core:statistics-id'
];
}
else
{
return
$state
[
$direction
][
'entityid'
];
}
}
return
'NA'
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment