getting user keys publically through http without any authentication, the github way. E.g: http://github.com/devaroop.keys
changelog updated to include ssh key retrieval feature update
This commit is contained in:
parent
e219cf7246
commit
b9d58c4cec
|
@ -1,4 +1,5 @@
|
|||
v 6.2.0
|
||||
- Retrieving user ssh keys publically(github style): http://__HOST__/__USERNAME__.keys
|
||||
- Public projects are visible from the outside
|
||||
- Add group access to permissions page
|
||||
- Require current password to change one
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -391,4 +391,8 @@ class User < ActiveRecord::Base
|
|||
|
||||
self
|
||||
end
|
||||
|
||||
def all_ssh_keys
|
||||
keys.collect{|x| x.key}.join("\n")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,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
|
||||
|
|
Loading…
Reference in New Issue