Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
010cd3de
Commit
010cd3de
authored
Sep 18, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rescue DN normalization attempts
parent
79b5cbde
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
lib/gitlab/ldap/person.rb
lib/gitlab/ldap/person.rb
+15
-0
spec/lib/gitlab/ldap/person_spec.rb
spec/lib/gitlab/ldap/person_spec.rb
+24
-0
No files found.
lib/gitlab/ldap/person.rb
View file @
010cd3de
...
@@ -43,6 +43,11 @@ module Gitlab
...
@@ -43,6 +43,11 @@ module Gitlab
else
else
normalize_uid
(
uid_or_dn
)
normalize_uid
(
uid_or_dn
)
end
end
rescue
StandardError
=>
e
Rails
.
logger
.
info
(
"Returning original DN
\"
#{
uid_or_dn
}
\"
due to error during normalization attempt:
#{
e
.
message
}
"
)
Rails
.
logger
.
info
(
e
.
backtrace
.
join
(
"
\n
"
))
uid_or_dn
end
end
# Returns true if the string looks like a DN rather than a UID.
# Returns true if the string looks like a DN rather than a UID.
...
@@ -59,6 +64,11 @@ module Gitlab
...
@@ -59,6 +64,11 @@ module Gitlab
# 2. The string is downcased (for case-insensitivity)
# 2. The string is downcased (for case-insensitivity)
def
self
.
normalize_uid
(
uid
)
def
self
.
normalize_uid
(
uid
)
normalize_dn_part
(
uid
)
normalize_dn_part
(
uid
)
rescue
StandardError
=>
e
Rails
.
logger
.
info
(
"Returning original UID
\"
#{
uid
}
\"
due to error during normalization attempt:
#{
e
.
message
}
"
)
Rails
.
logger
.
info
(
e
.
backtrace
.
join
(
"
\n
"
))
uid
end
end
# Returns the DN in a normalized form.
# Returns the DN in a normalized form.
...
@@ -69,6 +79,11 @@ module Gitlab
...
@@ -69,6 +79,11 @@ module Gitlab
dn
.
split
(
/(?<!\\)([,+=])/
).
map
do
|
part
|
dn
.
split
(
/(?<!\\)([,+=])/
).
map
do
|
part
|
normalize_dn_part
(
part
)
normalize_dn_part
(
part
)
end
.
join
(
''
)
end
.
join
(
''
)
rescue
StandardError
=>
e
Rails
.
logger
.
info
(
"Returning original DN
\"
#{
dn
}
\"
due to error during normalization attempt:
#{
e
.
message
}
"
)
Rails
.
logger
.
info
(
e
.
backtrace
.
join
(
"
\n
"
))
dn
end
end
def
initialize
(
entry
,
provider
)
def
initialize
(
entry
,
provider
)
...
...
spec/lib/gitlab/ldap/person_spec.rb
View file @
010cd3de
...
@@ -82,18 +82,42 @@ describe Gitlab::LDAP::Person do
...
@@ -82,18 +82,42 @@ describe Gitlab::LDAP::Person do
it_behaves_like
'normalizes the DN'
it_behaves_like
'normalizes the DN'
it_behaves_like
'normalizes the UID'
it_behaves_like
'normalizes the UID'
context
'with an exception during normalization'
do
let
(
:given
)
{
described_class
}
# just something that will cause an exception
it
'returns the given object unmodified'
do
expect
(
subject
).
to
eq
(
given
)
end
end
end
end
describe
'.normalize_uid'
do
describe
'.normalize_uid'
do
subject
{
described_class
.
normalize_uid
(
given
)
}
subject
{
described_class
.
normalize_uid
(
given
)
}
it_behaves_like
'normalizes the UID'
it_behaves_like
'normalizes the UID'
context
'with an exception during normalization'
do
let
(
:given
)
{
described_class
}
# just something that will cause an exception
it
'returns the given UID unmodified'
do
expect
(
subject
).
to
eq
(
given
)
end
end
end
end
describe
'.normalize_dn'
do
describe
'.normalize_dn'
do
subject
{
described_class
.
normalize_dn
(
given
)
}
subject
{
described_class
.
normalize_dn
(
given
)
}
it_behaves_like
'normalizes the DN'
it_behaves_like
'normalizes the DN'
context
'with an exception during normalization'
do
let
(
:given
)
{
described_class
}
# just something that will cause an exception
it
'returns the given DN unmodified'
do
expect
(
subject
).
to
eq
(
given
)
end
end
end
end
describe
'.dn?'
do
describe
'.dn?'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment