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
7d55c135
Commit
7d55c135
authored
Jun 28, 2018
by
Ronald Claveau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
List public ssh keys by id or username without authentication
parent
227cc997
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
29 deletions
+22
-29
changelogs/unreleased/features-unauth-access-ssh-keys.yml
changelogs/unreleased/features-unauth-access-ssh-keys.yml
+5
-0
doc/api/users.md
doc/api/users.md
+1
-1
lib/api/users.rb
lib/api/users.rb
+2
-4
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+14
-24
No files found.
changelogs/unreleased/features-unauth-access-ssh-keys.yml
0 → 100644
View file @
7d55c135
---
title
:
Enable unauthenticated access to public SSH keys via the API
merge_request
:
20118
author
:
Ronald Claveau
type
:
changed
doc/api/users.md
View file @
7d55c135
...
...
@@ -556,7 +556,7 @@ Parameters:
## List SSH keys for user
Get a list of a specified user's SSH keys.
Available only for admin
Get a list of a specified user's SSH keys.
```
GET /users/:id/keys
...
...
lib/api/users.rb
View file @
7d55c135
...
...
@@ -254,7 +254,7 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
desc
'Get the SSH keys of a specified user.
Available only for admins.
'
do
desc
'Get the SSH keys of a specified user.'
do
success
Entities
::
SSHKey
end
params
do
...
...
@@ -263,10 +263,8 @@ module API
end
# rubocop: disable CodeReuse/ActiveRecord
get
':id/keys'
do
authenticated_as_admin!
user
=
User
.
find_by
(
id:
params
[
:id
])
not_found!
(
'User'
)
unless
user
not_found!
(
'User'
)
unless
user
&&
can?
(
current_user
,
:read_user
,
user
)
present
paginate
(
user
.
keys
),
with:
Entities
::
SSHKey
end
...
...
spec/requests/api/users_spec.rb
View file @
7d55c135
...
...
@@ -785,20 +785,11 @@ describe API::Users do
end
describe
'GET /user/:id/keys'
do
before
do
admin
end
it
'returns 404 for non-existing user'
do
user_id
=
not_existing_user_id
context
'when unauthenticated'
do
it
'returns authentication error'
do
get
api
(
"/users/
#{
user
.
id
}
/keys"
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
end
end
get
api
(
"/users/
#{
user_id
}
/keys"
)
context
'when authenticated'
do
it
'returns 404 for non-existing user'
do
get
api
(
'/users/999999/keys'
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 User Not Found'
)
end
...
...
@@ -807,7 +798,7 @@ describe API::Users do
user
.
keys
<<
key
user
.
save
get
api
(
"/users/
#{
user
.
id
}
/keys"
,
admin
)
get
api
(
"/users/
#{
user
.
id
}
/keys"
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
...
...
@@ -815,7 +806,6 @@ describe API::Users do
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
key
.
title
)
end
end
end
describe
'DELETE /user/:id/keys/:key_id'
do
before
do
...
...
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