Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mastofe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Pleroma
mastofe
Commits
b0f4fe45
Commit
b0f4fe45
authored
6 years ago
by
Immae
Committed by
Eugen Rochko
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add ldap search filter (#8151)
parent
aaac14b8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.env.production.sample
+1
-0
1 addition, 0 deletions
.env.production.sample
config/initializers/devise.rb
+3
-0
3 additions, 0 deletions
config/initializers/devise.rb
lib/devise/ldap_authenticatable.rb
+2
-1
2 additions, 1 deletion
lib/devise/ldap_authenticatable.rb
with
6 additions
and
1 deletion
.env.production.sample
+
1
−
0
View file @
b0f4fe45
...
...
@@ -162,6 +162,7 @@ STREAMING_CLUSTER_NUM=1
# LDAP_BIND_DN=
# LDAP_PASSWORD=
# LDAP_UID=cn
# LDAP_SEARCH_FILTER="%{uid}=%{email}"
# PAM authentication (optional)
# PAM authentication uses for the email generation the "email" pam variable
...
...
This diff is collapsed.
Click to expand it.
config/initializers/devise.rb
+
3
−
0
View file @
b0f4fe45
...
...
@@ -59,6 +59,8 @@ module Devise
@@ldap_password
=
nil
mattr_accessor
:ldap_tls_no_verify
@@ldap_tls_no_verify
=
false
mattr_accessor
:ldap_search_filter
@@ldap_search_filter
=
nil
class
Strategies::PamAuthenticatable
def
valid?
...
...
@@ -362,5 +364,6 @@ Devise.setup do |config|
config
.
ldap_password
=
ENV
.
fetch
(
'LDAP_PASSWORD'
)
config
.
ldap_uid
=
ENV
.
fetch
(
'LDAP_UID'
,
'cn'
)
config
.
ldap_tls_no_verify
=
ENV
[
'LDAP_TLS_NO_VERIFY'
]
==
'true'
config
.
ldap_search_filter
=
ENV
.
fetch
(
'LDAP_SEARCH_FILTER'
,
'%{uid}=%{email}'
)
end
end
This diff is collapsed.
Click to expand it.
lib/devise/ldap_authenticatable.rb
+
2
−
1
View file @
b0f4fe45
...
...
@@ -24,7 +24,8 @@ module Devise
connect_timeout:
10
)
if
(
user_info
=
ldap
.
bind_as
(
base:
Devise
.
ldap_base
,
filter:
"(
#{
Devise
.
ldap_uid
}
=
#{
email
}
)"
,
password:
password
))
filter
=
format
(
Devise
.
ldap_search_filter
,
uid:
Devise
.
ldap_uid
,
email:
email
)
if
(
user_info
=
ldap
.
bind_as
(
base:
Devise
.
ldap_base
,
filter:
filter
,
password:
password
))
user
=
User
.
ldap_get_user
(
user_info
.
first
)
success!
(
user
)
else
...
...
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