Commit b9d58c4cecd06be74c3cc32ccfb522b31544ab2e
1 parent
e219cf72
Exists in
spb-stable
and in
3 other branches
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
Showing
4 changed files
with
26 additions
and
0 deletions
Show diff stats
CHANGELOG
1 | v 6.2.0 | 1 | v 6.2.0 |
2 | + - Retrieving user ssh keys publically(github style): http://__HOST__/__USERNAME__.keys | ||
2 | - Public projects are visible from the outside | 3 | - Public projects are visible from the outside |
3 | - Add group access to permissions page | 4 | - Add group access to permissions page |
4 | - Require current password to change one | 5 | - Require current password to change one |
app/controllers/profiles/keys_controller.rb
1 | class Profiles::KeysController < ApplicationController | 1 | class Profiles::KeysController < ApplicationController |
2 | layout "profile" | 2 | layout "profile" |
3 | + skip_before_filter :authenticate_user!, only: [:get_keys] | ||
3 | 4 | ||
4 | def index | 5 | def index |
5 | @keys = current_user.keys.order('id DESC').all | 6 | @keys = current_user.keys.order('id DESC').all |
@@ -32,4 +33,21 @@ class Profiles::KeysController < ApplicationController | @@ -32,4 +33,21 @@ class Profiles::KeysController < ApplicationController | ||
32 | format.js { render nothing: true } | 33 | format.js { render nothing: true } |
33 | end | 34 | end |
34 | end | 35 | end |
36 | + | ||
37 | + #get all keys of a user(params[:username]) in a text format | ||
38 | + #helpful for sysadmins to put in respective servers | ||
39 | + def get_keys | ||
40 | + if params[:username].present? | ||
41 | + begin | ||
42 | + user = User.find_by_username(params[:username]) | ||
43 | + user.present? ? (render :text => user.all_ssh_keys) : | ||
44 | + (render_404 and return) | ||
45 | + rescue => e | ||
46 | + render text: e.message | ||
47 | + end | ||
48 | + else | ||
49 | + render_404 and return | ||
50 | + end | ||
51 | + end | ||
52 | + | ||
35 | end | 53 | end |
app/models/user.rb
config/routes.rb
@@ -11,6 +11,9 @@ Gitlab::Application.routes.draw do | @@ -11,6 +11,9 @@ Gitlab::Application.routes.draw do | ||
11 | API::API.logger Rails.logger | 11 | API::API.logger Rails.logger |
12 | mount API::API => '/api' | 12 | mount API::API => '/api' |
13 | 13 | ||
14 | + #get all keys of user | ||
15 | + get ':username.keys' => 'profiles/keys#get_keys' , constraints: { username: /.*/ } | ||
16 | + | ||
14 | constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? } | 17 | constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? } |
15 | constraints constraint do | 18 | constraints constraint do |
16 | mount Sidekiq::Web, at: "/admin/sidekiq", as: :sidekiq | 19 | mount Sidekiq::Web, at: "/admin/sidekiq", as: :sidekiq |