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
Boxiang Sun
gitlab-ce
Commits
7bca902a
Commit
7bca902a
authored
Mar 28, 2018
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fall back on ghost user when deploy key user is not set
parent
59d910f2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
4 deletions
+29
-4
app/models/deploy_key.rb
app/models/deploy_key.rb
+4
-0
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+4
-4
spec/models/deploy_key_spec.rb
spec/models/deploy_key_spec.rb
+21
-0
No files found.
app/models/deploy_key.rb
View file @
7bca902a
...
...
@@ -27,6 +27,10 @@ class DeployKey < Key
self
.
private?
end
def
user
super
||
User
.
ghost
end
def
has_access_to?
(
project
)
deploy_keys_project_for
(
project
).
present?
end
...
...
lib/gitlab/git_access.rb
View file @
7bca902a
...
...
@@ -99,8 +99,6 @@ module Gitlab
end
def
check_active_user!
return
if
deploy_key?
if
user
&&
!
user_access
.
allowed?
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:account_blocked
]
end
...
...
@@ -219,7 +217,7 @@ module Gitlab
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:read_only
]
end
if
deploy_key
if
deploy_key
?
unless
deploy_key
.
can_push_to?
(
project
)
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:deploy_key_upload
]
end
...
...
@@ -309,8 +307,10 @@ module Gitlab
case
actor
when
User
actor
when
DeployKey
nil
when
Key
actor
.
user
unless
actor
.
is_a?
(
DeployKey
)
actor
.
user
when
:ci
nil
end
...
...
spec/models/deploy_key_spec.rb
View file @
7bca902a
...
...
@@ -17,4 +17,25 @@ describe DeployKey, :mailer do
should_not_email
(
user
)
end
end
describe
'#user'
do
let
(
:deploy_key
)
{
create
(
:deploy_key
)
}
let
(
:user
)
{
create
(
:user
)
}
context
'when user is set'
do
before
do
deploy_key
.
user
=
user
end
it
'returns the user'
do
expect
(
deploy_key
.
user
).
to
be
(
user
)
end
end
context
'when user is not set'
do
it
'returns the ghost user'
do
expect
(
deploy_key
.
user
).
to
eq
(
User
.
ghost
)
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