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
88745b8d
Unverified
Commit
88745b8d
authored
7 years ago
by
Tim van Dijen
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
PSR-2
/ indentation
parent
0526e1b6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/core/lib/Auth/Process/StatisticsWithAttribute.php
+80
-72
80 additions, 72 deletions
modules/core/lib/Auth/Process/StatisticsWithAttribute.php
with
80 additions
and
72 deletions
modules/core/lib/Auth/Process/StatisticsWithAttribute.php
+
80
−
72
View file @
88745b8d
...
@@ -6,83 +6,91 @@
...
@@ -6,83 +6,91 @@
* @author Andreas Åkre Solberg, UNINETT AS.
* @author Andreas Åkre Solberg, UNINETT AS.
* @package SimpleSAMLphp
* @package SimpleSAMLphp
*/
*/
class
sspmod_core_Auth_Process_StatisticsWithAttribute
extends
SimpleSAML_Auth_ProcessingFilter
{
class
sspmod_core_Auth_Process_StatisticsWithAttribute
extends
SimpleSAML_Auth_ProcessingFilter
{
/**
/**
* The attribute to log
* The attribute to log
* @var string|null
*/
*/
private
$attribute
=
NULL
;
private
$attribute
=
null
;
private
$typeTag
=
'saml20-idp-SSO'
;
/**
* @var string
private
$skipPassive
=
false
;
*/
private
$typeTag
=
'saml20-idp-SSO'
;
/**
/**
* Initialize this filter.
* @var bool
*
*/
* @param array $config Configuration information about this filter.
private
$skipPassive
=
false
;
* @param mixed $reserved For future use.
*/
public
function
__construct
(
$config
,
$reserved
)
{
parent
::
__construct
(
$config
,
$reserved
);
assert
(
is_array
(
$config
));
if
(
array_key_exists
(
'attributename'
,
$config
))
{
$this
->
attribute
=
$config
[
'attributename'
];
if
(
!
is_string
(
$this
->
attribute
))
{
throw
new
Exception
(
'Invalid attribute name given to core:StatisticsWithAttribute filter.'
);
}
}
if
(
array_key_exists
(
'type'
,
$config
))
{
$this
->
typeTag
=
$config
[
'type'
];
if
(
!
is_string
(
$this
->
typeTag
))
{
throw
new
Exception
(
'Invalid typeTag given to core:StatisticsWithAttribute filter.'
);
}
}
if
(
array_key_exists
(
'skipPassive'
,
$config
))
{
$this
->
skipPassive
=
(
bool
)
$config
[
'skipPassive'
];
}
}
/**
/**
* Log line.
* Initialize this filter.
*
*
* @param array &$state The current state.
* @param array $config Configuration information about this filter.
*/
* @param mixed $reserved For future use.
public
function
process
(
&
$state
)
{
*/
assert
(
is_array
(
$state
));
public
function
__construct
(
$config
,
$reserved
)
assert
(
array_key_exists
(
'Attributes'
,
$state
));
{
parent
::
__construct
(
$config
,
$reserved
);
$logAttribute
=
'NA'
;
assert
(
is_array
(
$config
));
$isPassive
=
''
;
if
(
array_key_exists
(
'isPassive'
,
$state
)
&&
$state
[
'isPassive'
]
===
true
)
{
if
(
array_key_exists
(
'attributename'
,
$config
))
{
if
(
$this
->
skipPassive
===
true
)
{
$this
->
attribute
=
$config
[
'attributename'
];
// We have a passive request. Skip logging statistics
if
(
!
is_string
(
$this
->
attribute
))
{
return
;
throw
new
Exception
(
'Invalid attribute name given to core:StatisticsWithAttribute filter.'
);
}
}
$isPassive
=
'passive-'
;
}
}
if
(
array_key_exists
(
'type'
,
$config
))
{
$this
->
typeTag
=
$config
[
'type'
];
if
(
!
is_string
(
$this
->
typeTag
))
{
throw
new
Exception
(
'Invalid typeTag given to core:StatisticsWithAttribute filter.'
);
}
}
if
(
array_key_exists
(
$this
->
attribute
,
$state
[
'Attributes'
]))
{
if
(
array_key_exists
(
'skipPassive'
,
$config
))
{
$this
->
skipPassive
=
(
bool
)
$config
[
'skipPassive'
];
}
}
/**
* Log line.
*
* @param array &$state The current state.
*/
public
function
process
(
&
$state
)
{
assert
(
is_array
(
$state
));
assert
(
array_key_exists
(
'Attributes'
,
$state
));
$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
(
array_key_exists
(
$this
->
attribute
,
$state
[
'Attributes'
]))
{
$logAttribute
=
$state
[
'Attributes'
][
$this
->
attribute
][
0
];
$logAttribute
=
$state
[
'Attributes'
][
$this
->
attribute
][
0
];
}
}
$source
=
$this
->
setIdentifier
(
'Source'
,
$state
);
$source
=
$this
->
setIdentifier
(
'Source'
,
$state
);
$dest
=
$this
->
setIdentifier
(
'Destination'
,
$state
);
$dest
=
$this
->
setIdentifier
(
'Destination'
,
$state
);
if
(
!
array_key_exists
(
'PreviousSSOTimestamp'
,
$state
))
{
if
(
!
array_key_exists
(
'PreviousSSOTimestamp'
,
$state
))
{
// The user hasn't authenticated with this SP earlier in this session
// The user hasn't authenticated with this SP earlier in this session
SimpleSAML\Logger
::
stats
(
$isPassive
.
$this
->
typeTag
.
'-first '
.
$dest
.
' '
.
$source
.
' '
.
$logAttribute
);
SimpleSAML\Logger
::
stats
(
$isPassive
.
$this
->
typeTag
.
'-first '
.
$dest
.
' '
.
$source
.
' '
.
$logAttribute
);
}
}
SimpleSAML\Logger
::
stats
(
$isPassive
.
$this
->
typeTag
.
' '
.
$dest
.
' '
.
$source
.
' '
.
$logAttribute
);
SimpleSAML\Logger
::
stats
(
$isPassive
.
$this
->
typeTag
.
' '
.
$dest
.
' '
.
$source
.
' '
.
$logAttribute
);
}
}
/**
/**
...
@@ -90,16 +98,16 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P
...
@@ -90,16 +98,16 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P
* @param array $state The current state.
* @param array $state The current state.
*
*
* @return string
* @return string
*/
*/
private
function
setIdentitier
(
$direction
,
$state
)
private
function
setIdentitier
(
$direction
,
$state
)
{
{
if
(
array_key_exists
(
$direction
,
$state
))
{
if
(
array_key_exists
(
$direction
,
$state
))
{
if
(
isset
(
$state
[
$direction
][
'core:statistics-id'
]))
{
if
(
isset
(
$state
[
$direction
][
'core:statistics-id'
]))
{
return
$state
[
$direction
][
'core:statistics-id'
];
return
$state
[
$direction
][
'core:statistics-id'
];
}
else
{
}
else
{
return
$state
[
$direction
][
'entityid'
];
return
$state
[
$direction
][
'entityid'
];
}
}
}
}
return
'NA'
;
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