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
1c7bd3d2
Unverified
Commit
1c7bd3d2
authored
7 years ago
by
Tim van Dijen
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Make sure $value is of type Array (Part 2)
parent
4a634f74
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/SimpleSAML/Auth/LDAP.php
+4
-12
4 additions, 12 deletions
lib/SimpleSAML/Auth/LDAP.php
with
4 additions
and
12 deletions
lib/SimpleSAML/Auth/LDAP.php
+
4
−
12
View file @
1c7bd3d2
...
@@ -53,10 +53,8 @@ class SimpleSAML_Auth_LDAP
...
@@ -53,10 +53,8 @@ class SimpleSAML_Auth_LDAP
* @param int $port
* @param int $port
* @param bool $referrals
* @param bool $referrals
*/
*/
// TODO: Flesh out documentation
public
function
__construct
(
$hostname
,
$enable_tls
=
true
,
$debug
=
false
,
$timeout
=
0
,
$port
=
389
,
$referrals
=
true
)
public
function
__construct
(
$hostname
,
$enable_tls
=
true
,
$debug
=
false
,
$timeout
=
0
,
$port
=
389
,
$referrals
=
true
)
{
{
// Debug
// Debug
SimpleSAML\Logger
::
debug
(
'Library - LDAP __construct(): Setup LDAP with '
.
SimpleSAML\Logger
::
debug
(
'Library - LDAP __construct(): Setup LDAP with '
.
'host=\''
.
$hostname
.
'host=\''
.
$hostname
.
...
@@ -207,8 +205,7 @@ class SimpleSAML_Auth_LDAP
...
@@ -207,8 +205,7 @@ class SimpleSAML_Auth_LDAP
{
{
// Create the search filter
// Create the search filter
$attribute
=
self
::
escape_filter_value
(
$attribute
,
false
);
$attribute
=
self
::
escape_filter_value
(
$attribute
,
false
);
$value
=
\SimpleSAML\Utils\Arrays
::
Arrayize
(
$value
);
$value
=
self
::
escape_filter_value
(
$value
,
true
);
$value
=
self
::
escape_filter_value
(
$value
);
$filter
=
''
;
$filter
=
''
;
foreach
(
$attribute
as
$attr
)
{
foreach
(
$attribute
as
$attr
)
{
$filter
.
=
'('
.
$attr
.
'='
.
$value
.
')'
;
$filter
.
=
'('
.
$attr
.
'='
.
$value
.
')'
;
...
@@ -222,8 +219,7 @@ class SimpleSAML_Auth_LDAP
...
@@ -222,8 +219,7 @@ class SimpleSAML_Auth_LDAP
// Search using generated filter
// Search using generated filter
SimpleSAML\Logger
::
debug
(
'Library - LDAP search(): Searching base \''
.
$base
.
'\' for \''
.
$filter
.
'\''
);
SimpleSAML\Logger
::
debug
(
'Library - LDAP search(): Searching base \''
.
$base
.
'\' for \''
.
$filter
.
'\''
);
// TODO: Should aliases be dereferenced?
$result
=
@
ldap_search
(
$this
->
ldap
,
$base
,
$filter
,
array
(),
0
,
0
,
$this
->
timeout
,
LDAP_DEREF_NEVER
);
$result
=
@
ldap_search
(
$this
->
ldap
,
$base
,
$filter
,
array
(),
0
,
0
,
$this
->
timeout
);
if
(
$result
===
false
)
{
if
(
$result
===
false
)
{
throw
$this
->
makeException
(
'Library - LDAP search(): Failed search on base \''
.
$base
.
'\' for \''
.
$filter
.
'\''
);
throw
$this
->
makeException
(
'Library - LDAP search(): Failed search on base \''
.
$base
.
'\' for \''
.
$filter
.
'\''
);
}
}
...
@@ -250,7 +246,6 @@ class SimpleSAML_Auth_LDAP
...
@@ -250,7 +246,6 @@ class SimpleSAML_Auth_LDAP
if
(
$dn
===
false
)
{
if
(
$dn
===
false
)
{
throw
$this
->
makeException
(
'Library - LDAP search(): Unable to get DN after searching base \''
.
$base
.
'\' for \''
.
$filter
.
'\''
);
throw
$this
->
makeException
(
'Library - LDAP search(): Unable to get DN after searching base \''
.
$base
.
'\' for \''
.
$filter
.
'\''
);
}
}
// FIXME: Are we now sure, if no excepton has been thrown, that we are returning a DN?
return
$dn
;
return
$dn
;
}
}
...
@@ -598,7 +593,6 @@ class SimpleSAML_Auth_LDAP
...
@@ -598,7 +593,6 @@ class SimpleSAML_Auth_LDAP
* @param string $password
* @param string $password
* @return array|bool
* @return array|bool
*/
*/
// TODO: Documentation; only cleared up exception/log messages
public
function
validate
(
$config
,
$username
,
$password
=
null
)
public
function
validate
(
$config
,
$username
,
$password
=
null
)
{
{
/* Escape any characters with a special meaning in LDAP. The following
/* Escape any characters with a special meaning in LDAP. The following
...
@@ -644,15 +638,13 @@ class SimpleSAML_Auth_LDAP
...
@@ -644,15 +638,13 @@ class SimpleSAML_Auth_LDAP
* backslash followed by two hex digits representing the hexadecimal value of the character.
* backslash followed by two hex digits representing the hexadecimal value of the character.
*
*
* @static
* @static
* @param array $values Array of values to escape
* @param
string|
array $values Array of values to escape
* @return array Array $values, but escaped
* @return array Array $values, but escaped
*/
*/
public
static
function
escape_filter_value
(
$values
=
array
(),
$singleValue
=
true
)
public
static
function
escape_filter_value
(
$values
=
array
(),
$singleValue
=
true
)
{
{
// Parameter validation
// Parameter validation
if
(
!
is_array
(
$values
))
{
$values
=
\SimpleSAML\Utils\Arrays
::
arrayize
(
$values
);
$values
=
array
(
$values
);
}
foreach
(
$values
as
$key
=>
$val
)
{
foreach
(
$values
as
$key
=>
$val
)
{
// Escaping of filter meta characters
// Escaping of filter meta characters
...
...
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