diff options
author | devaroop <devaroop123@yahoo.co.in> | 2013-10-02 20:39:29 +0530 |
---|---|---|
committer | devaroop <devaroop123@yahoo.co.in> | 2013-10-02 20:39:29 +0530 |
commit | b6bd4856a33df3d144be66c4ed1f1396009bb08b (patch) | |
tree | ea43eb96db85741b96c062718580c852bd536bb2 /app/controllers | |
parent | e219cf7246c6a0495e4507deaffeba11e79f13b8 (diff) | |
download | gitlab-ce-b6bd4856a33df3d144be66c4ed1f1396009bb08b.tar.gz |
getting user keys publically through http without any authentication, the github way. E.g: http://github.com/devaroop.keys
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/profiles/keys_controller.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/controllers/profiles/keys_controller.rb b/app/controllers/profiles/keys_controller.rb index c36dae2abd3..2b991957b70 100644 --- a/app/controllers/profiles/keys_controller.rb +++ b/app/controllers/profiles/keys_controller.rb @@ -1,5 +1,6 @@ class Profiles::KeysController < ApplicationController layout "profile" + skip_before_filter :authenticate_user!, only: [:get_keys] def index @keys = current_user.keys.order('id DESC').all @@ -32,4 +33,21 @@ 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]) + user.present? ? (render :text => user.all_ssh_keys) : + (render_404 and return) + rescue => e + render text: e.message + end + else + render_404 and return + end + end + end |