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
iv
gitlab-ce
Commits
85def2d6
Commit
85def2d6
authored
Sep 12, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1451 from tsigo/omniauth_settings
Be more resilient in the case of missing omniauth settings
parents
3643df1f
0d77209e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
8 deletions
+10
-8
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+4
-4
lib/gitlab/auth.rb
lib/gitlab/auth.rb
+3
-3
spec/lib/auth_spec.rb
spec/lib/auth_spec.rb
+3
-1
No files found.
config/initializers/1_settings.rb
View file @
85def2d6
...
@@ -121,19 +121,19 @@ class Settings < Settingslogic
...
@@ -121,19 +121,19 @@ class Settings < Settingslogic
end
end
def
ldap_enabled?
def
ldap_enabled?
ldap
[
'enabled'
]
ldap
&&
ldap
[
'enabled'
]
rescue
rescue
Settingslogic
::
MissingSetting
false
false
end
end
def
omniauth_enabled?
def
omniauth_enabled?
omniauth
&&
omniauth
[
'enabled'
]
omniauth
&&
omniauth
[
'enabled'
]
rescue
rescue
Settingslogic
::
MissingSetting
false
false
end
end
def
omniauth_providers
def
omniauth_providers
omniauth
[
'providers'
]
||
[]
(
omniauth_enabled?
&&
omniauth
[
'providers'
])
||
[]
end
end
def
disable_gravatar?
def
disable_gravatar?
...
...
lib/gitlab/auth.rb
View file @
85def2d6
...
@@ -17,7 +17,7 @@ module Gitlab
...
@@ -17,7 +17,7 @@ module Gitlab
end
end
end
end
def
create_from_omniauth
auth
,
ldap
=
false
def
create_from_omniauth
(
auth
,
ldap
=
false
)
provider
=
auth
.
provider
provider
=
auth
.
provider
uid
=
auth
.
info
.
uid
||
auth
.
uid
uid
=
auth
.
info
.
uid
||
auth
.
uid
name
=
auth
.
info
.
name
.
force_encoding
(
"utf-8"
)
name
=
auth
.
info
.
name
.
force_encoding
(
"utf-8"
)
...
@@ -39,7 +39,7 @@ module Gitlab
...
@@ -39,7 +39,7 @@ module Gitlab
password_confirmation:
password
,
password_confirmation:
password
,
projects_limit:
Gitlab
.
config
.
default_projects_limit
,
projects_limit:
Gitlab
.
config
.
default_projects_limit
,
)
)
if
Gitlab
.
config
.
omniauth
.
block_auto_created_users
&&
!
ldap
if
Gitlab
.
config
.
omniauth
[
'block_auto_created_users'
]
&&
!
ldap
@user
.
blocked
=
true
@user
.
blocked
=
true
end
end
@user
.
save!
@user
.
save!
...
@@ -52,7 +52,7 @@ module Gitlab
...
@@ -52,7 +52,7 @@ module Gitlab
if
@user
=
User
.
find_by_provider_and_extern_uid
(
provider
,
uid
)
if
@user
=
User
.
find_by_provider_and_extern_uid
(
provider
,
uid
)
@user
@user
else
else
if
Gitlab
.
config
.
omniauth
.
allow_single_sign_on
if
Gitlab
.
config
.
omniauth
[
'allow_single_sign_on'
]
@user
=
create_from_omniauth
(
auth
)
@user
=
create_from_omniauth
(
auth
)
@user
@user
end
end
...
...
spec/lib/auth_spec.rb
View file @
85def2d6
...
@@ -4,6 +4,8 @@ describe Gitlab::Auth do
...
@@ -4,6 +4,8 @@ describe Gitlab::Auth do
let
(
:gl_auth
)
{
Gitlab
::
Auth
.
new
}
let
(
:gl_auth
)
{
Gitlab
::
Auth
.
new
}
before
do
before
do
Gitlab
.
config
.
stub
(
omniauth:
{})
@info
=
mock
(
@info
=
mock
(
uid:
'12djsak321'
,
uid:
'12djsak321'
,
name:
'John'
,
name:
'John'
,
...
@@ -64,7 +66,7 @@ describe Gitlab::Auth do
...
@@ -64,7 +66,7 @@ describe Gitlab::Auth do
end
end
it
"should create user if single_sing_on"
do
it
"should create user if single_sing_on"
do
Gitlab
.
config
.
omniauth
.
stub
allow_single_sign_on:
true
Gitlab
.
config
.
omniauth
[
'allow_single_sign_on'
]
=
true
User
.
stub
find_by_provider_and_extern_uid:
nil
User
.
stub
find_by_provider_and_extern_uid:
nil
gl_auth
.
should_receive
:create_from_omniauth
gl_auth
.
should_receive
:create_from_omniauth
gl_auth
.
find_or_new_for_omniauth
(
@auth
)
gl_auth
.
find_or_new_for_omniauth
(
@auth
)
...
...
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