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
461634b8
Commit
461634b8
authored
May 05, 2021
by
Małgorzata Ksionek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix sessions controller
parent
dadc36aa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
12 deletions
+7
-12
app/controllers/sessions_controller.rb
app/controllers/sessions_controller.rb
+1
-1
app/models/user.rb
app/models/user.rb
+5
-0
ee/app/models/ee/user.rb
ee/app/models/ee/user.rb
+1
-0
spec/controllers/sessions_controller_spec.rb
spec/controllers/sessions_controller_spec.rb
+0
-11
No files found.
app/controllers/sessions_controller.rb
View file @
461634b8
...
...
@@ -76,7 +76,7 @@ class SessionsController < Devise::SessionsController
flash
[
:notice
]
=
nil
end
if
password_based_login?
&&
!
resource
.
allow_password_authentication_for_web
?
if
password_based_login?
&&
resource
.
user_authorized_by_provisioning_group
?
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 @
461634b8
...
...
@@ -1121,6 +1121,11 @@ class User < ApplicationRecord
Gitlab
::
CurrentSettings
.
password_authentication_enabled_for_git?
&&
!
password_based_omniauth_user?
end
#method overriden in EE
def
user_authorized_by_provisioning_group?
false
end
def
can_change_username?
gitlab_config
.
username_changing_enabled
end
...
...
ee/app/models/ee/user.rb
View file @
461634b8
...
...
@@ -328,6 +328,7 @@ module EE
super
end
override
:user_authorized_by_provisioning_group?
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
...
...
spec/controllers/sessions_controller_spec.rb
View file @
461634b8
...
...
@@ -119,17 +119,6 @@ RSpec.describe SessionsController do
end
end
context
'when user is not allowed to log in using password'
do
let
(
:user
)
{
create
(
:omniauth_user
,
provider:
'ldapmain'
)}
it
'does not authenticate the user'
do
post_action
expect
(
@request
.
env
[
'warden'
]).
not_to
be_authenticated
expect
(
flash
[
:alert
]).
to
include
(
'You are not allowed to log in using password'
)
end
end
context
'when using valid password'
,
:clean_gitlab_redis_shared_state
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user_params
)
{
{
login:
user
.
username
,
password:
user
.
password
}
}
...
...
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