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
79611ed1
Commit
79611ed1
authored
Mar 01, 2022
by
Serena Fang
Committed by
Douglas Barbosa Alexandre
Mar 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply reviewer suggestions
parent
de35bb22
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
20 deletions
+18
-20
app/graphql/types/user_interface.rb
app/graphql/types/user_interface.rb
+2
-10
app/helpers/users_helper.rb
app/helpers/users_helper.rb
+13
-0
lib/api/entities/user_safe.rb
lib/api/entities/user_safe.rb
+3
-10
No files found.
app/graphql/types/user_interface.rb
View file @
79611ed1
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
module
Types
module
Types
module
UserInterface
module
UserInterface
include
Types
::
BaseInterface
include
Types
::
BaseInterface
include
UsersHelper
graphql_name
'User'
graphql_name
'User'
description
'Representation of a GitLab user.'
description
'Representation of a GitLab user.'
...
@@ -136,16 +137,7 @@ module Types
...
@@ -136,16 +137,7 @@ module Types
def
redacted_name
def
redacted_name
return
object
.
name
unless
object
.
project_bot?
return
object
.
name
unless
object
.
project_bot?
if
object
.
groups
secure_project_bot_name
(
context
[
:current_user
],
object
)
return
object
.
name
if
context
[
:current_user
]
&
.
can?
(
:read_group
,
object
.
groups
.
first
)
end
return
object
.
name
if
context
[
:current_user
]
&
.
can?
(
:read_project
,
object
.
projects
.
first
)
# If the requester does not have permission to read the project bot name,
# the API returns an arbitrary string. UI changes will be addressed in a follow up issue:
# https://gitlab.com/gitlab-org/gitlab/-/issues/346058
'****'
end
end
end
end
end
end
app/helpers/users_helper.rb
View file @
79611ed1
...
@@ -176,6 +176,19 @@ module UsersHelper
...
@@ -176,6 +176,19 @@ module UsersHelper
user
.
public_email
.
present?
user
.
public_email
.
present?
end
end
def
secure_project_bot_name
(
current_user
,
user
)
if
user
.
groups
.
any?
return
user
.
name
if
current_user
&
.
can?
(
:read_group
,
user
.
groups
.
first
)
end
return
user
.
name
if
current_user
&
.
can?
(
:read_project
,
user
.
projects
.
first
)
# If the requester does not have permission to read the project bot name,
# the API returns an arbitrary string. UI changes will be addressed in a follow up issue:
# https://gitlab.com/gitlab-org/gitlab/-/issues/346058
'****'
end
private
private
def
admin_users_paths
def
admin_users_paths
...
...
lib/api/entities/user_safe.rb
View file @
79611ed1
...
@@ -3,20 +3,13 @@
...
@@ -3,20 +3,13 @@
module
API
module
API
module
Entities
module
Entities
class
UserSafe
<
Grape
::
Entity
class
UserSafe
<
Grape
::
Entity
include
UsersHelper
expose
:id
,
:username
expose
:id
,
:username
expose
:name
do
|
user
|
expose
:name
do
|
user
|
next
user
.
name
unless
user
.
project_bot?
next
user
.
name
unless
user
.
project_bot?
if
user
.
groups
secure_project_bot_name
(
options
[
:current_user
],
user
)
next
user
.
name
if
options
[
:current_user
]
&
.
can?
(
:read_group
,
user
.
groups
.
first
)
end
next
user
.
name
if
options
[
:current_user
]
&
.
can?
(
:read_project
,
user
.
projects
.
first
)
# If the requester does not have permission to read the project bot name,
# the API returns an arbitrary string. UI changes will be addressed in a follow up issue:
# https://gitlab.com/gitlab-org/gitlab/-/issues/346058
'****'
end
end
end
end
end
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