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
795cd7f9
Commit
795cd7f9
authored
Apr 23, 2018
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace define_method with alias_method in Omniauth Controllers
parent
d3a8a074
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
16 deletions
+12
-16
app/controllers/ldap/omniauth_callbacks_controller.rb
app/controllers/ldap/omniauth_callbacks_controller.rb
+6
-8
app/controllers/omniauth_callbacks_controller.rb
app/controllers/omniauth_callbacks_controller.rb
+5
-7
lib/gitlab/auth/ldap/user.rb
lib/gitlab/auth/ldap/user.rb
+1
-1
No files found.
app/controllers/ldap/omniauth_callbacks_controller.rb
View file @
795cd7f9
...
...
@@ -2,23 +2,21 @@ class Ldap::OmniauthCallbacksController < OmniauthCallbacksController
extend
::
Gitlab
::
Utils
::
Override
def
self
.
define_providers!
if
Gitlab
::
Auth
::
LDAP
::
Config
.
enabled?
return
unless
Gitlab
::
Auth
::
LDAP
::
Config
.
enabled?
Gitlab
::
Auth
::
LDAP
::
Config
.
available_servers
.
each
do
|
server
|
define_method
server
[
'provider_name'
]
do
ldap
end
end
alias_method
server
[
'provider_name'
],
:ldap
end
end
define_providers!
# We only find ourselves here
# if the authentication to LDAP was successful.
def
ldap
sign_in_user_flow
(
Gitlab
::
Auth
::
LDAP
::
User
)
end
define_providers!
override
:set_remember_me
def
set_remember_me
(
user
)
user
.
remember_me
=
params
[
:remember_me
]
if
user
.
persisted?
...
...
app/controllers/omniauth_callbacks_controller.rb
View file @
795cd7f9
...
...
@@ -4,10 +4,12 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
protect_from_forgery
except:
[
:kerberos
,
:saml
,
:cas3
]
Gitlab
.
config
.
omniauth
.
providers
.
each
do
|
provider
|
define_method
provider
[
'name'
]
do
handle_omniauth
def
handle_omniauth
omniauth_flow
(
Gitlab
::
Auth
::
OAuth
)
end
Gitlab
.
config
.
omniauth
.
providers
.
each
do
|
provider
|
alias_method
provider
[
'name'
],
:handle_omniauth
end
# Extend the standard implementation to also increment
...
...
@@ -70,10 +72,6 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
private
def
handle_omniauth
omniauth_flow
(
Gitlab
::
Auth
::
OAuth
)
end
def
omniauth_flow
(
auth_module
,
identity_linker:
nil
)
if
current_user
log_audit_event
(
current_user
,
with:
oauth
[
'provider'
])
...
...
lib/gitlab/auth/ldap/user.rb
View file @
795cd7f9
...
...
@@ -49,7 +49,7 @@ module Gitlab
end
def
valid_sign_in?
allowed?
allowed?
&&
super
end
def
ldap_config
...
...
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