Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
aef78288
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aef78288
编写于
2月 11, 2014
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5261 from devaroop/retrieve_ssh_keys_by_ssh
ssh keys publically available for sysadmins via http, the github way
上级
1284f21c
4b9c28bc
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
45 addition
and
0 deletion
+45
-0
CHANGELOG
CHANGELOG
+1
-0
app/controllers/profiles/keys_controller.rb
app/controllers/profiles/keys_controller.rb
+21
-0
app/models/user.rb
app/models/user.rb
+4
-0
config/routes.rb
config/routes.rb
+3
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+11
-0
spec/routing/routing_spec.rb
spec/routing/routing_spec.rb
+5
-0
未找到文件。
CHANGELOG
浏览文件 @
aef78288
v 6.6.0
- Retrieving user ssh keys publically(github style): http://__HOST__/__USERNAME__.keys
- Permissions: Developer now can manage issue tracker (modify any issue)
- Improve Code Compare page performance
- Group avatar
...
...
app/controllers/profiles/keys_controller.rb
浏览文件 @
aef78288
class
Profiles::KeysController
<
ApplicationController
layout
"profile"
skip_before_filter
:authenticate_user!
,
only:
[
:get_keys
]
def
index
@keys
=
current_user
.
keys
.
order
(
'id DESC'
)
...
...
@@ -32,4 +33,24 @@ class Profiles::KeysController < ApplicationController
format
.
js
{
render
nothing:
true
}
end
end
# Get all keys of a user(params[:username]) in a text format
# Helpful for sysadmins to put in respective servers
def
get_keys
if
params
[
:username
].
present?
begin
user
=
User
.
find_by_username
(
params
[
:username
])
if
user
.
present?
render
text:
user
.
all_ssh_keys
.
join
(
'\n'
)
else
render_404
and
return
end
rescue
=>
e
render
text:
e
.
message
end
else
render_404
and
return
end
end
end
app/models/user.rb
浏览文件 @
aef78288
...
...
@@ -435,4 +435,8 @@ class User < ActiveRecord::Base
def
short_website_url
website_url
.
gsub
(
/https?:\/\//
,
''
)
end
def
all_ssh_keys
keys
.
map
(
&
:key
)
end
end
config/routes.rb
浏览文件 @
aef78288
...
...
@@ -12,6 +12,9 @@ Gitlab::Application.routes.draw do
API
::
API
.
logger
Rails
.
logger
mount
API
::
API
=>
'/api'
# Get all keys of user
get
':username.keys'
=>
'profiles/keys#get_keys'
,
constraints:
{
username:
/.*/
}
constraint
=
lambda
{
|
request
|
request
.
env
[
"warden"
].
authenticate?
and
request
.
env
[
'warden'
].
user
.
admin?
}
constraints
constraint
do
mount
Sidekiq
::
Web
,
at:
"/admin/sidekiq"
,
as: :sidekiq
...
...
spec/models/user_spec.rb
浏览文件 @
aef78288
...
...
@@ -303,6 +303,17 @@ describe User do
end
end
describe
'all_ssh_keys'
do
it
{
should
have_many
(
:keys
).
dependent
(
:destroy
)
}
it
"should have all ssh keys"
do
user
=
create
:user
key
=
create
:key
,
key:
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD33bWLBxu48Sev9Fert1yzEO4WGcWglWF7K/AwblIUFselOt/QdOL9DSjpQGxLagO1s9wl53STIO8qGS4Ms0EJZyIXOEFMjFJ5xmjSy+S37By4sG7SsltQEHMxtbtFOaW5LV2wCrX+rUsRNqLMamZjgjcPO0/EgGCXIGMAYW4O7cwGZdXWYIhQ1Vwy+CsVMDdPkPgBXqK7nR/ey8KMs8ho5fMNgB5hBw/AL9fNGhRw3QTD6Q12Nkhl4VZES2EsZqlpNnJttnPdp847DUsT6yuLRlfiQfz5Cn9ysHFdXObMN5VYIiPFwHeYCZp1X2S4fDZooRE8uOLTfxWHPXwrhqSH"
,
user_id:
user
.
id
user
.
all_ssh_keys
.
should
include
(
key
.
key
)
end
end
describe
:avatar_type
do
let
(
:user
)
{
create
(
:user
)
}
...
...
spec/routing/routing_spec.rb
浏览文件 @
aef78288
...
...
@@ -176,6 +176,11 @@ describe Profiles::KeysController, "routing" do
it
"to #destroy"
do
delete
(
"/profile/keys/1"
).
should
route_to
(
'profiles/keys#destroy'
,
id:
'1'
)
end
# get all the ssh-keys of a user
it
"to #get_keys"
do
get
(
"/foo.keys"
).
should
route_to
(
'profiles/keys#get_keys'
,
username:
'foo'
)
end
end
# profile_avatar DELETE /profile/avatar(.:format) profiles/avatars#destroy
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录