Skip to content
Snippets Groups Projects
Commit 39e37677 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

add remove keys from gitlab-shell by id

parent 081c272b
No related branches found
No related tags found
1 merge request!2940Expanding repos and hooks paths in settings
Loading
Loading
@@ -81,7 +81,7 @@ class Key < ActiveRecord::Base
Key.where(identifier: identifier).count == 0
end
 
def owner_name
user.username
def shell_id
"key-#{self.id}"
end
end
Loading
Loading
@@ -4,7 +4,7 @@ class KeyObserver < ActiveRecord::Observer
def after_save(key)
GitoliteWorker.perform_async(
:add_key,
key.owner_name,
key.shell_id,
key.key
)
end
Loading
Loading
@@ -12,7 +12,7 @@ class KeyObserver < ActiveRecord::Observer
def after_destroy(key)
GitoliteWorker.perform_async(
:remove_key,
key.owner_name,
key.shell_id,
key.key,
)
end
Loading
Loading
Loading
Loading
@@ -27,19 +27,19 @@ module Gitlab
# Add new key to gitlab-shell
#
# Ex.
# add_key("randx", "sha-rsa ...")
# add_key("key-42", "sha-rsa ...")
#
def add_key(username, key_content)
system("/home/git/gitlab-shell/bin/gitlab-keys add-key #{username} \"#{key_content}\"")
def add_key(key_id, key_content)
system("/home/git/gitlab-shell/bin/gitlab-keys add-key #{key_id} \"#{key_content}\"")
end
 
# Remove ssh key from gitlab shell
#
# Ex.
# remove_key("sha-rsa")
# remove_key("key-342", "sha-rsa ...")
#
def remove_key(username, key_content)
system("/home/git/gitlab-shell/bin/gitlab-keys rm-key #{username} \"#{key_content}\"")
def remove_key(key_id, key_content)
system("/home/git/gitlab-shell/bin/gitlab-keys rm-key #{key_id} \"#{key_content}\"")
end
 
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment