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
3a3af0c6
Commit
3a3af0c6
authored
Jul 30, 2020
by
Małgorzata Ksionek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change method to display group that is source of 2fa requirement
Add changelog entry Add cr remarks
parent
e5a5e54a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
1 deletion
+49
-1
app/controllers/concerns/enforces_two_factor_authentication.rb
...ontrollers/concerns/enforces_two_factor_authentication.rb
+1
-1
app/models/user.rb
app/models/user.rb
+6
-0
changelogs/unreleased/security-199-show-actual-group.yml
changelogs/unreleased/security-199-show-actual-group.yml
+6
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+36
-0
No files found.
app/controllers/concerns/enforces_two_factor_authentication.rb
View file @
3a3af0c6
...
@@ -43,7 +43,7 @@ module EnforcesTwoFactorAuthentication
...
@@ -43,7 +43,7 @@ module EnforcesTwoFactorAuthentication
if
Gitlab
::
CurrentSettings
.
require_two_factor_authentication?
if
Gitlab
::
CurrentSettings
.
require_two_factor_authentication?
global
.
call
global
.
call
else
else
groups
=
current_user
.
expanded_groups_requiring_two_factor_authentication
.
reorder
(
name: :asc
)
groups
=
current_user
.
source_groups_of_two_factor_authentication_requirement
.
reorder
(
name: :asc
)
group
.
call
(
groups
)
group
.
call
(
groups
)
end
end
end
end
...
...
app/models/user.rb
View file @
3a3af0c6
...
@@ -885,6 +885,12 @@ class User < ApplicationRecord
...
@@ -885,6 +885,12 @@ class User < ApplicationRecord
all_expanded_groups
.
where
(
require_two_factor_authentication:
true
)
all_expanded_groups
.
where
(
require_two_factor_authentication:
true
)
end
end
def
source_groups_of_two_factor_authentication_requirement
Gitlab
::
ObjectHierarchy
.
new
(
expanded_groups_requiring_two_factor_authentication
)
.
all_objects
.
where
(
id:
groups
)
end
# rubocop: disable CodeReuse/ServiceClass
# rubocop: disable CodeReuse/ServiceClass
def
refresh_authorized_projects
def
refresh_authorized_projects
Users
::
RefreshAuthorizedProjectsService
.
new
(
self
).
execute
Users
::
RefreshAuthorizedProjectsService
.
new
(
self
).
execute
...
...
changelogs/unreleased/security-199-show-actual-group.yml
0 → 100644
View file @
3a3af0c6
---
title
:
Show on two-factor authentication setup page groups that are the cause of this
requirement
merge_request
:
author
:
type
:
security
spec/models/user_spec.rb
View file @
3a3af0c6
...
@@ -3578,6 +3578,42 @@ RSpec.describe User do
...
@@ -3578,6 +3578,42 @@ RSpec.describe User do
end
end
end
end
describe
'#source_groups_of_two_factor_authentication_requirement'
do
let_it_be
(
:group_not_requiring_2FA
)
{
create
:group
}
let
(
:user
)
{
create
:user
}
before
do
group
.
add_user
(
user
,
GroupMember
::
OWNER
)
group_not_requiring_2FA
.
add_user
(
user
,
GroupMember
::
OWNER
)
end
context
'when user is direct member of group requiring 2FA'
do
let_it_be
(
:group
)
{
create
:group
,
require_two_factor_authentication:
true
}
it
'returns group requiring 2FA'
do
expect
(
user
.
source_groups_of_two_factor_authentication_requirement
).
to
contain_exactly
(
group
)
end
end
context
'when user is member of group which parent requires 2FA'
do
let_it_be
(
:parent_group
)
{
create
:group
,
require_two_factor_authentication:
true
}
let_it_be
(
:group
)
{
create
:group
,
parent:
parent_group
}
it
'returns group requiring 2FA'
do
expect
(
user
.
source_groups_of_two_factor_authentication_requirement
).
to
contain_exactly
(
group
)
end
end
context
'when user is member of group which child requires 2FA'
do
let_it_be
(
:group
)
{
create
:group
}
let_it_be
(
:child_group
)
{
create
:group
,
require_two_factor_authentication:
true
,
parent:
group
}
it
'returns group requiring 2FA'
do
expect
(
user
.
source_groups_of_two_factor_authentication_requirement
).
to
contain_exactly
(
group
)
end
end
end
describe
'.active'
do
describe
'.active'
do
before
do
before
do
described_class
.
ghost
described_class
.
ghost
...
...
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