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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e8fbf7aa
Commit
e8fbf7aa
authored
Apr 23, 2018
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exclude LDAP from OmniauthCallbackController base methods
parent
51125bfb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
4 deletions
+49
-4
app/controllers/omniauth_callbacks_controller.rb
app/controllers/omniauth_callbacks_controller.rb
+2
-2
app/helpers/auth_helper.rb
app/helpers/auth_helper.rb
+8
-2
ee/app/helpers/ee/auth_helper.rb
ee/app/helpers/ee/auth_helper.rb
+10
-0
spec/helpers/auth_helper_spec.rb
spec/helpers/auth_helper_spec.rb
+29
-0
No files found.
app/controllers/omniauth_callbacks_controller.rb
View file @
e8fbf7aa
...
@@ -9,8 +9,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
...
@@ -9,8 +9,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
omniauth_flow
(
Gitlab
::
Auth
::
OAuth
)
omniauth_flow
(
Gitlab
::
Auth
::
OAuth
)
end
end
Gitlab
.
config
.
omniauth
.
providers
.
each
do
|
provider
|
AuthHelper
.
providers_for_base_controller
.
each
do
|
provider
|
alias_method
provider
[
'name'
]
,
:handle_omniauth
alias_method
provider
,
:handle_omniauth
end
end
# Extend the standard implementation to also increment
# Extend the standard implementation to also increment
...
...
app/helpers/auth_helper.rb
View file @
e8fbf7aa
module
AuthHelper
module
AuthHelper
prepend
EE
::
AuthHelper
PROVIDERS_WITH_ICONS
=
%w(twitter github gitlab bitbucket google_oauth2 facebook azure_oauth2 authentiq)
.
freeze
PROVIDERS_WITH_ICONS
=
%w(twitter github gitlab bitbucket google_oauth2 facebook azure_oauth2 authentiq)
.
freeze
FORM_BASED_PROVIDERS
=
[
/\Aldap/
,
'kerberos'
,
'crowd'
].
freeze
LDAP_PROVIDER
=
/\Aldap/
delegate
:slack_app_id
,
to: :'Gitlab::CurrentSettings.current_application_settings'
delegate
:slack_app_id
,
to: :'Gitlab::CurrentSettings.current_application_settings'
...
@@ -29,7 +31,7 @@ module AuthHelper
...
@@ -29,7 +31,7 @@ module AuthHelper
end
end
def
form_based_provider?
(
name
)
def
form_based_provider?
(
name
)
FORM_BASED_PROVIDERS
.
any?
{
|
pattern
|
pattern
===
name
.
to_s
}
[
LDAP_PROVIDER
,
'crowd'
]
.
any?
{
|
pattern
|
pattern
===
name
.
to_s
}
end
end
def
form_based_providers
def
form_based_providers
...
@@ -44,6 +46,10 @@ module AuthHelper
...
@@ -44,6 +46,10 @@ module AuthHelper
auth_providers
.
reject
{
|
provider
|
form_based_provider?
(
provider
)
}
auth_providers
.
reject
{
|
provider
|
form_based_provider?
(
provider
)
}
end
end
def
providers_for_base_controller
auth_providers
.
reject
{
|
provider
|
LDAP_PROVIDER
===
provider
}
end
def
enabled_button_based_providers
def
enabled_button_based_providers
disabled_providers
=
Gitlab
::
CurrentSettings
.
disabled_oauth_sign_in_sources
||
[]
disabled_providers
=
Gitlab
::
CurrentSettings
.
disabled_oauth_sign_in_sources
||
[]
...
...
ee/app/helpers/ee/auth_helper.rb
0 → 100644
View file @
e8fbf7aa
module
EE
module
AuthHelper
extend
::
Gitlab
::
Utils
::
Override
override
:form_based_provider?
def
form_based_provider?
(
name
)
super
||
name
.
to_s
==
'kerberos'
end
end
end
spec/helpers/auth_helper_spec.rb
View file @
e8fbf7aa
...
@@ -18,6 +18,35 @@ describe AuthHelper do
...
@@ -18,6 +18,35 @@ describe AuthHelper do
end
end
end
end
describe
"providers_for_base_controller"
do
it
'returns all enabled providers from devise'
do
allow
(
helper
).
to
receive
(
:auth_providers
)
{
[
:twitter
,
:github
]
}
expect
(
helper
.
providers_for_base_controller
).
to
include
(
*
[
:twitter
,
:github
])
end
it
'excludes ldap providers'
do
allow
(
helper
).
to
receive
(
:auth_providers
)
{
[
:twitter
,
:ldapmain
]
}
expect
(
helper
.
providers_for_base_controller
).
not_to
include
(
:ldapmain
)
end
end
describe
"form_based_providers"
do
it
'includes LDAP providers'
do
allow
(
helper
).
to
receive
(
:auth_providers
)
{
[
:twitter
,
:ldapmain
]
}
expect
(
helper
.
form_based_providers
).
to
eq
%i(ldapmain)
end
it
'includes crowd provider'
do
allow
(
helper
).
to
receive
(
:auth_providers
)
{
[
:twitter
,
:crowd
]
}
expect
(
helper
.
form_based_providers
).
to
eq
%i(crowd)
end
it
'includes kerberos provider'
do
allow
(
helper
).
to
receive
(
:auth_providers
)
{
[
:twitter
,
:kerberos
]
}
expect
(
helper
.
form_based_providers
).
to
eq
%i(kerberos)
end
end
describe
'enabled_button_based_providers'
do
describe
'enabled_button_based_providers'
do
before
do
before
do
allow
(
helper
).
to
receive
(
:auth_providers
)
{
[
:twitter
,
:github
]
}
allow
(
helper
).
to
receive
(
:auth_providers
)
{
[
:twitter
,
:github
]
}
...
...
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