Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
php-client
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
php-client
Commits
f694415e
Commit
f694415e
authored
1 year ago
by
lukasmatusiewicz
Browse files
Options
Downloads
Patches
Plain Diff
Update PrivacyIDEA.php
parent
52f88d7f
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
src/PrivacyIDEA.php
+37
-1
37 additions, 1 deletion
src/PrivacyIDEA.php
with
37 additions
and
1 deletion
src/PrivacyIDEA.php
+
37
−
1
View file @
f694415e
...
@@ -336,6 +336,7 @@ class PrivacyIDEA
...
@@ -336,6 +336,7 @@ class PrivacyIDEA
return
""
;
return
""
;
}
}
$params
=
array
(
$params
=
array
(
"username"
=>
$this
->
serviceAccountName
,
"username"
=>
$this
->
serviceAccountName
,
"password"
=>
$this
->
serviceAccountPass
"password"
=>
$this
->
serviceAccountPass
...
@@ -350,13 +351,48 @@ class PrivacyIDEA
...
@@ -350,13 +351,48 @@ class PrivacyIDEA
if
(
!
empty
(
$response
[
'result'
][
'value'
]))
if
(
!
empty
(
$response
[
'result'
][
'value'
]))
{
{
return
@
$response
[
'result'
][
'value'
][
'token'
]
?:
""
;
// Ensure an admin account
if
(
!
empty
(
$response
[
'result'
][
'value'
][
"token"
]))
{
if
(
$this
->
findRecursive
(
$response
,
"role"
)
!=
'admin'
)
{
$this
->
debugLog
(
"Auth token was of a user without admin role."
);
return
""
;
}
return
$response
[
'result'
][
'value'
][
"token"
];
}
}
}
$this
->
debugLog
(
"/auth response did not contain the auth token."
);
$this
->
debugLog
(
"/auth response did not contain the auth token."
);
return
""
;
return
""
;
}
}
/**
* Find key recursively in array.
*
* @param array $haystack The array which will be searched.
* @param string $needle Search string.
* @return mixed Result of key search.
*/
public
function
findRecursive
(
array
$haystack
,
string
$needle
):
mixed
{
assert
(
is_array
(
$haystack
));
assert
(
is_string
(
$needle
));
$iterator
=
new
RecursiveArrayIterator
(
$haystack
);
$recursive
=
new
RecursiveIteratorIterator
(
$iterator
,
RecursiveIteratorIterator
::
SELF_FIRST
);
foreach
(
$recursive
as
$key
=>
$value
)
{
if
(
$key
===
$needle
)
{
return
$value
;
}
}
return
false
;
}
/**
/**
* Send requests to the endpoint with specified parameters and headers.
* Send requests to the endpoint with specified parameters and headers.
*
*
...
...
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