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
1d2429af
Commit
1d2429af
authored
Apr 07, 2016
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing proper nil and error handling to SAML login process.
parent
4361cc39
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
18 deletions
+30
-18
app/controllers/omniauth_callbacks_controller.rb
app/controllers/omniauth_callbacks_controller.rb
+16
-10
lib/gitlab/saml/user.rb
lib/gitlab/saml/user.rb
+14
-8
No files found.
app/controllers/omniauth_callbacks_controller.rb
View file @
1d2429af
...
@@ -60,6 +60,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
...
@@ -60,6 +60,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
continue_login_process
continue_login_process
end
end
rescue
Gitlab
::
OAuth
::
SignupDisabledError
handle_signup_error
end
end
def
omniauth_error
def
omniauth_error
...
@@ -92,16 +94,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
...
@@ -92,16 +94,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
continue_login_process
continue_login_process
end
end
rescue
Gitlab
::
OAuth
::
SignupDisabledError
rescue
Gitlab
::
OAuth
::
SignupDisabledError
label
=
Gitlab
::
OAuth
::
Provider
.
label_for
(
oauth
[
'provider'
])
handle_signup_error
message
=
"Signing in using your
#{
label
}
account without a pre-existing GitLab account is not allowed."
if
current_application_settings
.
signup_enabled?
message
<<
" Create a GitLab account first, and then connect it to your
#{
label
}
account."
end
flash
[
:notice
]
=
message
redirect_to
new_user_session_path
end
end
def
handle_service_ticket
provider
,
ticket
def
handle_service_ticket
provider
,
ticket
...
@@ -122,6 +115,19 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
...
@@ -122,6 +115,19 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
end
end
end
end
def
handle_signup_error
label
=
Gitlab
::
OAuth
::
Provider
.
label_for
(
oauth
[
'provider'
])
message
=
"Signing in using your
#{
label
}
account without a pre-existing GitLab account is not allowed."
if
current_application_settings
.
signup_enabled?
message
<<
" Create a GitLab account first, and then connect it to your
#{
label
}
account."
end
flash
[
:notice
]
=
message
redirect_to
new_user_session_path
end
def
oauth
def
oauth
@oauth
||=
request
.
env
[
'omniauth.auth'
]
@oauth
||=
request
.
env
[
'omniauth.auth'
]
end
end
...
...
lib/gitlab/saml/user.rb
View file @
1d2429af
...
@@ -26,13 +26,15 @@ module Gitlab
...
@@ -26,13 +26,15 @@ module Gitlab
@user
||=
build_new_user
@user
||=
build_new_user
end
end
if
external_users_enabled?
unless
@user
.
nil?
# Check if there is overlap between the user's groups and the external groups
if
external_users_enabled?
# setting then set user as external or internal.
# Check if there is overlap between the user's groups and the external groups
if
(
auth_hash
.
groups
&
Gitlab
::
Saml
::
Config
.
external_groups
).
empty?
# setting then set user as external or internal.
@user
.
external
=
false
if
(
auth_hash
.
groups
&
Gitlab
::
Saml
::
Config
.
external_groups
).
empty?
else
@user
.
external
=
false
@user
.
external
=
true
else
@user
.
external
=
true
end
end
end
end
end
...
@@ -48,7 +50,11 @@ module Gitlab
...
@@ -48,7 +50,11 @@ module Gitlab
end
end
def
changed?
def
changed?
gl_user
.
changed?
||
gl_user
.
identities
.
any?
(
&
:changed?
)
if
gl_user
gl_user
.
changed?
||
gl_user
.
identities
.
any?
(
&
:changed?
)
else
true
end
end
end
protected
protected
...
...
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