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
0
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
64609935
Commit
64609935
authored
9 years ago
by
Thijs Kinkhorst
Browse files
Options
Downloads
Patches
Plain Diff
Fix formatting.
parent
9047384a
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/AttributeAlter.php
+95
-95
95 additions, 95 deletions
modules/core/lib/Auth/Process/AttributeAlter.php
with
95 additions
and
95 deletions
modules/core/lib/Auth/Process/AttributeAlter.php
+
95
−
95
View file @
64609935
...
@@ -9,10 +9,10 @@
...
@@ -9,10 +9,10 @@
*/
*/
class
sspmod_core_Auth_Process_AttributeAlter
extends
SimpleSAML_Auth_ProcessingFilter
{
class
sspmod_core_Auth_Process_AttributeAlter
extends
SimpleSAML_Auth_ProcessingFilter
{
/**
/**
* Should the pattern found be replaced?
* Should the pattern found be replaced?
*/
*/
private
$replace
=
FALSE
;
private
$replace
=
FALSE
;
/**
/**
* Should the value found be removed?
* Should the value found be removed?
...
@@ -20,102 +20,102 @@ class sspmod_core_Auth_Process_AttributeAlter extends SimpleSAML_Auth_Processing
...
@@ -20,102 +20,102 @@ class sspmod_core_Auth_Process_AttributeAlter extends SimpleSAML_Auth_Processing
private
$remove
=
FALSE
;
private
$remove
=
FALSE
;
/**
/**
* Pattern to search for.
* Pattern to search for.
*/
*/
private
$pattern
=
''
;
private
$pattern
=
''
;
/**
/**
* String to replace the pattern found with.
* String to replace the pattern found with.
*/
*/
private
$replacement
=
FALSE
;
private
$replacement
=
FALSE
;
/**
/**
* Attribute to search in
* Attribute to search in
*/
*/
private
$subject
=
''
;
private
$subject
=
''
;
/**
/**
* Attribute to place the result in.
* Attribute to place the result in.
*/
*/
private
$target
=
''
;
private
$target
=
''
;
/**
/**
* Initialize this filter.
* Initialize this filter.
*
*
* @param array $config Configuration information about this filter.
* @param array $config Configuration information about this filter.
* @param mixed $reserved For future use.
* @param mixed $reserved For future use.
* @throws SimpleSAML_Error_Exception In case of invalid configuration.
* @throws SimpleSAML_Error_Exception In case of invalid configuration.
*/
*/
public
function
__construct
(
$config
,
$reserved
)
{
public
function
__construct
(
$config
,
$reserved
)
{
parent
::
__construct
(
$config
,
$reserved
);
parent
::
__construct
(
$config
,
$reserved
);
assert
(
'is_array($config)'
);
assert
(
'is_array($config)'
);
// parse filter configuration
// parse filter configuration
foreach
(
$config
as
$name
=>
$value
)
{
foreach
(
$config
as
$name
=>
$value
)
{
if
(
is_int
(
$name
))
{
if
(
is_int
(
$name
))
{
// check if this is an option
// check if this is an option
if
(
$value
===
'%replace'
)
{
if
(
$value
===
'%replace'
)
{
$this
->
replace
=
TRUE
;
$this
->
replace
=
TRUE
;
}
elseif
(
$value
==
'%remove'
)
{
}
elseif
(
$value
==
'%remove'
)
{
$this
->
remove
=
TRUE
;
$this
->
remove
=
TRUE
;
}
else
{
}
else
{
throw
new
SimpleSAML_Error_Exception
(
'Unknown flag : '
.
var_export
(
$value
,
TRUE
));
throw
new
SimpleSAML_Error_Exception
(
'Unknown flag : '
.
var_export
(
$value
,
TRUE
));
}
}
continue
;
continue
;
}
}
// Unknown flag
// Unknown flag
if
(
!
is_string
(
$name
))
{
if
(
!
is_string
(
$name
))
{
throw
new
SimpleSAML_Error_Exception
(
'Unknown flag : '
.
var_export
(
$name
,
TRUE
));
throw
new
SimpleSAML_Error_Exception
(
'Unknown flag : '
.
var_export
(
$name
,
TRUE
));
}
}
// Set pattern
// Set pattern
if
(
$name
===
'pattern'
)
{
if
(
$name
===
'pattern'
)
{
$this
->
pattern
=
$value
;
$this
->
pattern
=
$value
;
}
}
// Set replacement
// Set replacement
if
(
$name
===
'replacement'
)
{
if
(
$name
===
'replacement'
)
{
$this
->
replacement
=
$value
;
$this
->
replacement
=
$value
;
}
}
// Set subject
// Set subject
if
(
$name
===
'subject'
)
{
if
(
$name
===
'subject'
)
{
$this
->
subject
=
$value
;
$this
->
subject
=
$value
;
}
}
// Set target
// Set target
if
(
$name
===
'target'
)
{
if
(
$name
===
'target'
)
{
$this
->
target
=
$value
;
$this
->
target
=
$value
;
}
}
}
}
}
}
/**
/**
* Apply the filter to modify attributes.
* Apply the filter to modify attributes.
*
*
* Modify existing attributes with the configured values.
* Modify existing attributes with the configured values.
*
*
* @param array &$request The current request.
* @param array &$request The current request.
* @throws SimpleSAML_Error_Exception In case of invalid configuration.
* @throws SimpleSAML_Error_Exception In case of invalid configuration.
*/
*/
public
function
process
(
&
$request
)
{
public
function
process
(
&
$request
)
{
assert
(
'is_array($request)'
);
assert
(
'is_array($request)'
);
assert
(
'array_key_exists("Attributes", $request)'
);
assert
(
'array_key_exists("Attributes", $request)'
);
// get attributes from request
// get attributes from request
$attributes
=&
$request
[
'Attributes'
];
$attributes
=&
$request
[
'Attributes'
];
// check that all required params are set in config
// check that all required params are set in config
if
(
empty
(
$this
->
pattern
)
||
empty
(
$this
->
subject
))
{
if
(
empty
(
$this
->
pattern
)
||
empty
(
$this
->
subject
))
{
throw
new
SimpleSAML_Error_Exception
(
"Not all params set in config."
);
throw
new
SimpleSAML_Error_Exception
(
"Not all params set in config."
);
}
}
if
(
!
$this
->
replace
&&
!
$this
->
remove
&&
$this
->
replacement
===
false
)
{
if
(
!
$this
->
replace
&&
!
$this
->
remove
&&
$this
->
replacement
===
false
)
{
throw
new
SimpleSAML_Error_Exception
(
"'replacement' must be set if neither '%replace' nor "
.
throw
new
SimpleSAML_Error_Exception
(
"'replacement' must be set if neither '%replace' nor "
.
"'%remove' are set."
);
"'%remove' are set."
);
}
}
if
(
!
$this
->
replace
&&
$this
->
replacement
===
null
)
{
if
(
!
$this
->
replace
&&
$this
->
replacement
===
null
)
{
throw
new
SimpleSAML_Error_Exception
(
"'%replace' must be set if 'replacement' is null."
);
throw
new
SimpleSAML_Error_Exception
(
"'%replace' must be set if 'replacement' is null."
);
...
@@ -125,16 +125,16 @@ class sspmod_core_Auth_Process_AttributeAlter extends SimpleSAML_Auth_Processing
...
@@ -125,16 +125,16 @@ class sspmod_core_Auth_Process_AttributeAlter extends SimpleSAML_Auth_Processing
throw
new
SimpleSAML_Error_Exception
(
"'%replace' and '%remove' cannot be used together."
);
throw
new
SimpleSAML_Error_Exception
(
"'%replace' and '%remove' cannot be used together."
);
}
}
if
(
empty
(
$this
->
target
))
{
if
(
empty
(
$this
->
target
))
{
// use subject as target if target is not set
// use subject as target if target is not set
$this
->
target
=
$this
->
subject
;
$this
->
target
=
$this
->
subject
;
}
}
if
(
$this
->
subject
!==
$this
->
target
&&
$this
->
remove
)
{
if
(
$this
->
subject
!==
$this
->
target
&&
$this
->
remove
)
{
throw
new
SimpleSAML_Error_Exception
(
"Cannot use '%remove' when 'target' is different than 'subject'."
);
throw
new
SimpleSAML_Error_Exception
(
"Cannot use '%remove' when 'target' is different than 'subject'."
);
}
}
if
(
!
array_key_exists
(
$this
->
subject
,
$attributes
))
{
if
(
!
array_key_exists
(
$this
->
subject
,
$attributes
))
{
// if no such subject, stop gracefully
// if no such subject, stop gracefully
return
;
return
;
}
}
...
@@ -179,5 +179,5 @@ class sspmod_core_Auth_Process_AttributeAlter extends SimpleSAML_Auth_Processing
...
@@ -179,5 +179,5 @@ class sspmod_core_Auth_Process_AttributeAlter extends SimpleSAML_Auth_Processing
$attributes
[
$this
->
subject
]);
$attributes
[
$this
->
subject
]);
}
}
}
}
}
}
}
}
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