BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
39e37677
Commit
39e37677
authored
Feb 05, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add remove keys from gitlab-shell by id
parent
081c272b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
10 deletions
+10
-10
key.rb
app/models/key.rb
+2
-2
key_observer.rb
app/observers/key_observer.rb
+2
-2
shell.rb
lib/gitlab/backend/shell.rb
+6
-6
No files found.
app/models/key.rb
View file @
39e37677
...
...
@@ -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
app/observers/key_observer.rb
View file @
39e37677
...
...
@@ -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
...
...
@@ -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
...
...
lib/gitlab/backend/shell.rb
View file @
39e37677
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment