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
503150b6
Commit
503150b6
authored
May 06, 2021
by
Małgorzata Ksionek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change method to protect password-base login
parent
f82fbb4e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
4 deletions
+10
-4
app/controllers/sessions_controller.rb
app/controllers/sessions_controller.rb
+1
-1
app/models/user.rb
app/models/user.rb
+1
-1
ee/app/models/ee/user.rb
ee/app/models/ee/user.rb
+7
-1
lib/gitlab/auth/database/authentication.rb
lib/gitlab/auth/database/authentication.rb
+1
-1
No files found.
app/controllers/sessions_controller.rb
View file @
503150b6
...
...
@@ -76,7 +76,7 @@ class SessionsController < Devise::SessionsController
flash
[
:notice
]
=
nil
end
if
password_based_login?
&&
resource
.
user_authorized_by_provisioning_group
?
if
password_based_login?
&&
resource
.
password_based_login_forbidden
?
sign_out
flash
[
:alert
]
=
_
(
'You are not allowed to log in using password'
)
redirect_to
new_user_session_path
...
...
app/models/user.rb
View file @
503150b6
...
...
@@ -1122,7 +1122,7 @@ class User < ApplicationRecord
end
# method overriden in EE
def
user_authorized_by_provisioning_group
?
def
password_based_login_forbidden
?
false
end
...
...
ee/app/models/ee/user.rb
View file @
503150b6
...
...
@@ -328,7 +328,13 @@ module EE
super
end
override
:user_authorized_by_provisioning_group?
override
:password_based_login_forbidden?
def
password_based_login_forbidden?
return
true
if
user_authorized_by_provisioning_group?
super
end
def
user_authorized_by_provisioning_group?
user_detail
.
provisioned_by_group?
&&
::
Feature
.
enabled?
(
:block_password_auth_for_saml_users
,
user_detail
.
provisioned_by_group
,
type: :ops
)
end
...
...
lib/gitlab/auth/database/authentication.rb
View file @
503150b6
...
...
@@ -9,7 +9,7 @@ module Gitlab
class
Authentication
<
Gitlab
::
Auth
::
OAuth
::
Authentication
def
login
(
login
,
password
)
return
false
unless
Gitlab
::
CurrentSettings
.
password_authentication_enabled_for_git?
return
false
unless
user
.
allow_password_authentication_for_git
?
return
false
if
user
.
password_based_login_forbidden
?
return
user
if
user
&
.
valid_password?
(
password
)
end
...
...
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