Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp-module-proxystatistics
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
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp-module-proxystatistics
Commits
7d5d85ee
Verified
Commit
7d5d85ee
authored
3 years ago
by
Dominik František Bučík
Browse files
Options
Downloads
Patches
Plain Diff
feat:
Customizable IdPEnityID location (from attribute)
parent
9665f187
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!81
feat: 🎸 Configurable sourceIdpEntityID
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
config-templates/module_proxystatistics.php
+6
-0
6 additions, 0 deletions
config-templates/module_proxystatistics.php
lib/Config.php
+10
-0
10 additions, 0 deletions
lib/Config.php
lib/DatabaseCommand.php
+43
-11
43 additions, 11 deletions
lib/DatabaseCommand.php
with
59 additions
and
11 deletions
config-templates/module_proxystatistics.php
+
6
−
0
View file @
7d5d85ee
...
...
@@ -62,6 +62,12 @@ $config = [
*/
//'userIdAttribute' => 'uid',
/*
* Which attribute should be used for IdP Entity ID
* if left empty, it will be extracted from the request object.
*/
//'sourceIdpEntityIdAttribute' => 'sourceIdpEntityID',
/*
* Database table names. Default is to keep the name (as in `tables.sql`)
*/
...
...
This diff is collapsed.
Click to expand it.
lib/Config.php
+
10
−
0
View file @
7d5d85ee
...
...
@@ -26,6 +26,8 @@ class Config
private
const
USER_ID_ATTRIBUTE
=
'userIdAttribute'
;
private
const
SOURCE_IDP_ENTITY_ID_ATTRIBUTE
=
'sourceIdpEntityIdAttribute'
;
private
const
REQUIRE_AUTH_SOURCE
=
'requireAuth.source'
;
private
const
KEEP_PER_USER
=
'keepPerUser'
;
...
...
@@ -36,6 +38,8 @@ class Config
private
$mode
;
private
$sourceIdpEntityIdAttribute
;
private
static
$instance
;
private
function
__construct
()
...
...
@@ -44,6 +48,7 @@ class Config
$this
->
store
=
$this
->
config
->
getConfigItem
(
self
::
STORE
,
null
);
$this
->
tables
=
$this
->
config
->
getArray
(
'tables'
,
[]);
$this
->
mode
=
$this
->
config
->
getValueValidate
(
self
::
MODE
,
[
'PROXY'
,
'IDP'
,
'SP'
,
'MULTI_IDP'
],
'PROXY'
);
$this
->
sourceIdpEntityIdAttribute
=
$this
->
config
->
getString
(
self
::
SOURCE_IDP_ENTITY_ID_ATTRIBUTE
,
''
);
}
private
function
__clone
()
...
...
@@ -79,6 +84,11 @@ class Config
return
$this
->
config
->
getString
(
self
::
USER_ID_ATTRIBUTE
,
'uid'
);
}
public
function
getSourceIdpEntityIdAttribute
()
{
return
$this
->
sourceIdpEntityIdAttribute
;
}
public
function
getSideInfo
(
$side
)
{
assert
(
in_array
(
$side
,
[
self
::
SIDES
],
true
));
...
...
This diff is collapsed.
Click to expand it.
lib/DatabaseCommand.php
+
43
−
11
View file @
7d5d85ee
...
...
@@ -71,8 +71,7 @@ class DatabaseCommand
}
}
$idAttribute
=
$this
->
config
->
getIdAttribute
();
$userId
=
isset
(
$request
[
'Attributes'
][
$idAttribute
])
?
$request
[
'Attributes'
][
$idAttribute
][
0
]
:
''
;
$userId
=
$this
->
getUserId
(
$request
);
$ids
=
[];
foreach
(
self
::
TABLE_SIDES
as
$side
=>
$table
)
{
...
...
@@ -273,23 +272,19 @@ class DatabaseCommand
return
$this
->
conn
->
write
(
$query
,
$params
);
}
private
function
getEntities
(
$request
)
private
function
getEntities
(
$request
)
:
array
{
$entities
=
[
Config
::
MODE_IDP
=>
[],
Config
::
MODE_SP
=>
[],
];
if
(
Config
::
MODE_IDP
!==
$this
->
mode
&&
Config
::
MODE_MULTI_IDP
!==
$this
->
mode
)
{
$entities
[
Config
::
MODE_IDP
][
'id'
]
=
$
request
[
'saml:sp:IdP'
]
;
$entities
[
Config
::
MODE_IDP
][
'name'
]
=
$
request
[
'Attributes'
][
'source
Id
P
Name
'
][
0
]
;
$entities
[
Config
::
MODE_IDP
][
'id'
]
=
$
this
->
getIdpIdentifier
(
$request
)
;
$entities
[
Config
::
MODE_IDP
][
'name'
]
=
$
this
->
get
Id
p
Name
(
$request
)
;
}
if
(
Config
::
MODE_SP
!==
$this
->
mode
)
{
$entities
[
Config
::
MODE_SP
][
'id'
]
=
$request
[
'Destination'
][
'entityid'
];
if
(
isset
(
$request
[
'Destination'
][
'UIInfo'
][
'DisplayName'
][
'en'
]))
{
$entities
[
Config
::
MODE_SP
][
'name'
]
=
$request
[
'Destination'
][
'UIInfo'
][
'DisplayName'
][
'en'
];
}
else
{
$entities
[
Config
::
MODE_SP
][
'name'
]
=
$request
[
'Destination'
][
'name'
][
'en'
]
??
''
;
}
$entities
[
Config
::
MODE_SP
][
'id'
]
=
$this
->
getSpIdentifier
(
$request
);
$entities
[
Config
::
MODE_SP
][
'name'
]
=
$this
->
getSpName
(
$request
);
}
if
(
Config
::
MODE_PROXY
!==
$this
->
mode
&&
Config
::
MODE_MULTI_IDP
!==
$this
->
mode
)
{
...
...
@@ -372,4 +367,41 @@ class DatabaseCommand
return
$this
->
escape_cols
(
$columns
);
}
private
function
getIdpIdentifier
(
$request
)
{
$sourceIdpEntityIdAttribute
=
$this
->
config
->
getSourceIdpEntityIdAttribute
();
if
(
!
empty
(
$sourceIdpEntityIdAttribute
)
&&
!
empty
(
$request
[
'Attributes'
][
$sourceIdpEntityIdAttribute
][
0
]))
{
return
$request
[
'Attributes'
][
$sourceIdpEntityIdAttribute
][
0
];
}
return
$request
[
'saml:sp:IdP'
];
}
private
function
getUserId
(
$request
)
{
$idAttribute
=
$this
->
config
->
getIdAttribute
();
return
isset
(
$request
[
'Attributes'
][
$idAttribute
])
?
$request
[
'Attributes'
][
$idAttribute
][
0
]
:
''
;
}
private
function
getIdpName
(
$request
)
{
return
$request
[
'Attributes'
][
'sourceIdPName'
][
0
];
}
private
function
getSpIdentifier
(
$request
)
{
return
$request
[
'Destination'
][
'entityid'
];
}
private
function
getSpName
(
$request
)
{
$displayName
=
$request
[
'Destination'
][
'UIInfo'
][
'DisplayName'
][
'en'
]
??
''
;
if
(
empty
(
$displayName
))
{
$displayName
=
$request
[
'Destination'
][
'name'
][
'en'
]
??
''
;
}
return
$displayName
;
}
}
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