Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
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
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
10 deletions
+10
-10
app/models/key.rb
app/models/key.rb
+2
-2
app/observers/key_observer.rb
app/observers/key_observer.rb
+2
-2
lib/gitlab/backend/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