BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
c741f95a
Commit
c741f95a
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
b51f6e2c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
4 deletions
+32
-4
omniauth_callbacks_controller.rb
app/controllers/omniauth_callbacks_controller.rb
+2
-2
auth_helper.rb
app/helpers/auth_helper.rb
+6
-2
auth_helper_spec.rb
spec/helpers/auth_helper_spec.rb
+24
-0
No files found.
app/controllers/omniauth_callbacks_controller.rb
View file @
c741f95a
...
...
@@ -8,8 +8,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
omniauth_flow
(
Gitlab
::
Auth
::
OAuth
)
end
Gitlab
.
config
.
omniauth
.
providers
.
each
do
|
provider
|
alias_method
provider
[
'name'
]
,
:handle_omniauth
AuthHelper
.
providers_for_base_controller
.
each
do
|
provider
|
alias_method
provider
,
:handle_omniauth
end
# Extend the standard implementation to also increment
...
...
app/helpers/auth_helper.rb
View file @
c741f95a
module
AuthHelper
PROVIDERS_WITH_ICONS
=
%w(twitter github gitlab bitbucket google_oauth2 facebook azure_oauth2 authentiq)
.
freeze
FORM_BASED_PROVIDERS
=
[
/\Aldap/
,
'crowd'
].
freeze
LDAP_PROVIDER
=
/\Aldap/
def
ldap_enabled?
Gitlab
::
Auth
::
LDAP
::
Config
.
enabled?
...
...
@@ -23,7 +23,7 @@ module AuthHelper
end
def
form_based_provider?
(
name
)
FORM_BASED_PROVIDERS
.
any?
{
|
pattern
|
pattern
===
name
.
to_s
}
[
LDAP_PROVIDER
,
'crowd'
]
.
any?
{
|
pattern
|
pattern
===
name
.
to_s
}
end
def
form_based_providers
...
...
@@ -38,6 +38,10 @@ module AuthHelper
auth_providers
.
reject
{
|
provider
|
form_based_provider?
(
provider
)
}
end
def
providers_for_base_controller
auth_providers
.
reject
{
|
provider
|
LDAP_PROVIDER
===
provider
}
end
def
enabled_button_based_providers
disabled_providers
=
Gitlab
::
CurrentSettings
.
disabled_oauth_sign_in_sources
||
[]
...
...
spec/helpers/auth_helper_spec.rb
View file @
c741f95a
...
...
@@ -18,6 +18,30 @@ describe AuthHelper do
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
end
describe
'enabled_button_based_providers'
do
before
do
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