{"action":"created","comment":{"url":"https://api.github.com/repos/MarkUsProject/Markus/pulls/comments/27843808","id":27843808,"diff_hunk":"@@ -38,36 +51,99 @@ def edit\n \n   # Given a File object to upload, save it on the file system with\n   # association to the user_name given.\n-  # Admins are able to save keys under different user names then\n-  # their own.\n+  # If a String is supplied as the first argument then it's content\n+  # is used to create the public key\n   # Creates the KEY_STORAGE directory if it does not yet exist\n-  def upload_key_file(_file, user_name)\n+  def upload_key_file(_file, user_name, time_stamp)\n     Dir.mkdir(KEY_STORAGE) unless File.exists?(KEY_STORAGE)\n-    uploaded_io = _file\n \n-    # todo: check current user to see if they have permission to\n-    # use a different user_name then their current one (admins)\n+    public_key_content = ''\n+\n+    if _file.is_a? String\n+      # Dump the string into the file\n+      public_key_content = _file\n+    else\n+      public_key_content = _file.read\n+    end\n \n-    File.open(Rails.root.join(KEY_STORAGE, user_name + '.pub'), 'wb') do |f|\n-      f.write(uploaded_io.read)\n+    File.open(Rails.root.join(KEY_STORAGE, user_name + \"@\" + time_stamp + '.pub'), 'wb') do |f|\n+      f.write(public_key_content)\n     end\n+\n+    add_key(KEY_STORAGE + '/' + user_name + \"@\" + time_stamp + '.pub')\n+\n+  end\n+\n+  # Adds a specific public key to a specific user.\n+  def add_key(_path)\n+\n+    #gitolite admin repo - these keys are for the repo-admin user - aka git on my machine\n+    settings = { :public_key => '/home/git/.ssh/id_rsa.pub', :private_key => '/home/git/.ssh/id_rsa' }\n+    ga_repo = Gitolite::GitoliteAdmin.new(REPOSITORY_STORAGE + '/gitolite-admin', settings)\n+    # The admin repo is loaded into memory\n+    conf = ga_repo.config","path":"app/controllers/key_pairs_controller.rb","position":73,"original_position":73,"commit_id":"1549202da7401f97ef3b47d97b179438f6bc8757","original_commit_id":"1549202da7401f97ef3b47d97b179438f6bc8757","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Useless assignment to variable - `conf`.","created_at":"2015-04-07T00:37:20Z","updated_at":"2015-04-07T00:37:20Z","html_url":"https://github.com/MarkUsProject/Markus/pull/2121#discussion_r27843808","pull_request_url":"https://api.github.com/repos/MarkUsProject/Markus/pulls/2121","_links":{"self":{"href":"https://api.github.com/repos/MarkUsProject/Markus/pulls/comments/27843808"},"html":{"href":"https://github.com/MarkUsProject/Markus/pull/2121#discussion_r27843808"},"pull_request":{"href":"https://api.github.com/repos/MarkUsProject/Markus/pulls/2121"}}},"pull_request":{"url":"https://api.github.com/repos/MarkUsProject/Markus/pulls/2121","id":32724487,"html_url":"https://github.com/MarkUsProject/Markus/pull/2121","diff_url":"https://github.com/MarkUsProject/Markus/pull/2121.diff","patch_url":"https://github.com/MarkUsProject/Markus/pull/2121.patch","issue_url":"https://api.github.com/repos/MarkUsProject/Markus/issues/2121","number":2121,"state":"open","locked":false,"title":"Gitolite Backend & Key Pair Upload Functionality Added","user":{"login":"SoftwareDev","id":5432316,"avatar_url":"https://avatars.githubusercontent.com/u/5432316?v=3","gravatar_id":"","url":"https://api.github.com/users/SoftwareDev","html_url":"https://github.com/SoftwareDev","followers_url":"https://api.github.com/users/SoftwareDev/followers","following_url":"https://api.github.com/users/SoftwareDev/following{/other_user}","gists_url":"https://api.github.com/users/SoftwareDev/gists{/gist_id}","starred_url":"https://api.github.com/users/SoftwareDev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SoftwareDev/subscriptions","organizations_url":"https://api.github.com/users/SoftwareDev/orgs","repos_url":"https://api.github.com/users/SoftwareDev/repos","events_url":"https://api.github.com/users/SoftwareDev/events{/privacy}","received_events_url":"https://api.github.com/users/SoftwareDev/received_events","type":"User","site_admin":false},"body":"Here are the changes to the git branch which integrate MarkUs with the fine-grained access controller and repository hoster which is Gitolite.\r\n\r\nNotable changes:\r\n- A \"Key Pairs\" page has been added which allows all users of MarkUs to upload and manage their public keys which allow SSH authentication with the git repositories and Gitolite.\r\n- Repository creation is now handled by the Gitolite server and no longer by native MarkUs code itself. (MarkUs now clones the repos which are created by Gitolite calls and maintains compatibility with the SVN branch)\r\n- Some additional constants have been added to the environment setup files.\r\n\r\n-------------------------------------------------------------------------------------------------------------\r\nAdditional Gitolite Setup and Instruction material will be added to the Wiki pages soon.\r\n\r\nI plan to do some more visual updates to the Key Pairs pages over this upcoming month.","created_at":"2015-04-07T00:37:11Z","updated_at":"2015-04-07T00:37:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/MarkUsProject/Markus/pulls/2121/commits","review_comments_url":"https://api.github.com/repos/MarkUsProject/Markus/pulls/2121/comments","review_comment_url":"https://api.github.com/repos/MarkUsProject/Markus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MarkUsProject/Markus/issues/2121/comments","statuses_url":"https://api.github.com/repos/MarkUsProject/Markus/statuses/1549202da7401f97ef3b47d97b179438f6bc8757","head":{"label":"SoftwareDev:gitolite-rugged","ref":"gitolite-rugged","sha":"1549202da7401f97ef3b47d97b179438f6bc8757","user":{"login":"SoftwareDev","id":5432316,"avatar_url":"https://avatars.githubusercontent.com/u/5432316?v=3","gravatar_id":"","url":"https://api.github.com/users/SoftwareDev","html_url":"https://github.com/SoftwareDev","followers_url":"https://api.github.com/users/SoftwareDev/followers","following_url":"https://api.github.com/users/SoftwareDev/following{/other_user}","gists_url":"https://api.github.com/users/SoftwareDev/gists{/gist_id}","starred_url":"https://api.github.com/users/SoftwareDev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SoftwareDev/subscriptions","organizations_url":"https://api.github.com/users/SoftwareDev/orgs","repos_url":"https://api.github.com/users/SoftwareDev/repos","events_url":"https://api.github.com/users/SoftwareDev/events{/privacy}","received_events_url":"https://api.github.com/users/SoftwareDev/received_events","type":"User","site_admin":false},"repo":{"id":24034862,"name":"Markus","full_name":"SoftwareDev/Markus","owner":{"login":"SoftwareDev","id":5432316,"avatar_url":"https://avatars.githubusercontent.com/u/5432316?v=3","gravatar_id":"","url":"https://api.github.com/users/SoftwareDev","html_url":"https://github.com/SoftwareDev","followers_url":"https://api.github.com/users/SoftwareDev/followers","following_url":"https://api.github.com/users/SoftwareDev/following{/other_user}","gists_url":"https://api.github.com/users/SoftwareDev/gists{/gist_id}","starred_url":"https://api.github.com/users/SoftwareDev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SoftwareDev/subscriptions","organizations_url":"https://api.github.com/users/SoftwareDev/orgs","repos_url":"https://api.github.com/users/SoftwareDev/repos","events_url":"https://api.github.com/users/SoftwareDev/events{/privacy}","received_events_url":"https://api.github.com/users/SoftwareDev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SoftwareDev/Markus","description":"Git repository of MarkUs","fork":true,"url":"https://api.github.com/repos/SoftwareDev/Markus","forks_url":"https://api.github.com/repos/SoftwareDev/Markus/forks","keys_url":"https://api.github.com/repos/SoftwareDev/Markus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SoftwareDev/Markus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SoftwareDev/Markus/teams","hooks_url":"https://api.github.com/repos/SoftwareDev/Markus/hooks","issue_events_url":"https://api.github.com/repos/SoftwareDev/Markus/issues/events{/number}","events_url":"https://api.github.com/repos/SoftwareDev/Markus/events","assignees_url":"https://api.github.com/repos/SoftwareDev/Markus/assignees{/user}","branches_url":"https://api.github.com/repos/SoftwareDev/Markus/branches{/branch}","tags_url":"https://api.github.com/repos/SoftwareDev/Markus/tags","blobs_url":"https://api.github.com/repos/SoftwareDev/Markus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SoftwareDev/Markus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SoftwareDev/Markus/git/refs{/sha}","trees_url":"https://api.github.com/repos/SoftwareDev/Markus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SoftwareDev/Markus/statuses/{sha}","languages_url":"https://api.github.com/repos/SoftwareDev/Markus/languages","stargazers_url":"https://api.github.com/repos/SoftwareDev/Markus/stargazers","contributors_url":"https://api.github.com/repos/SoftwareDev/Markus/contributors","subscribers_url":"https://api.github.com/repos/SoftwareDev/Markus/subscribers","subscription_url":"https://api.github.com/repos/SoftwareDev/Markus/subscription","commits_url":"https://api.github.com/repos/SoftwareDev/Markus/commits{/sha}","git_commits_url":"https://api.github.com/repos/SoftwareDev/Markus/git/commits{/sha}","comments_url":"https://api.github.com/repos/SoftwareDev/Markus/comments{/number}","issue_comment_url":"https://api.github.com/repos/SoftwareDev/Markus/issues/comments{/number}","contents_url":"https://api.github.com/repos/SoftwareDev/Markus/contents/{+path}","compare_url":"https://api.github.com/repos/SoftwareDev/Markus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SoftwareDev/Markus/merges","archive_url":"https://api.github.com/repos/SoftwareDev/Markus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SoftwareDev/Markus/downloads","issues_url":"https://api.github.com/repos/SoftwareDev/Markus/issues{/number}","pulls_url":"https://api.github.com/repos/SoftwareDev/Markus/pulls{/number}","milestones_url":"https://api.github.com/repos/SoftwareDev/Markus/milestones{/number}","notifications_url":"https://api.github.com/repos/SoftwareDev/Markus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SoftwareDev/Markus/labels{/name}","releases_url":"https://api.github.com/repos/SoftwareDev/Markus/releases{/id}","created_at":"2014-09-14T22:18:29Z","updated_at":"2015-02-12T05:26:34Z","pushed_at":"2015-04-07T00:34:38Z","git_url":"git://github.com/SoftwareDev/Markus.git","ssh_url":"git@github.com:SoftwareDev/Markus.git","clone_url":"https://github.com/SoftwareDev/Markus.git","svn_url":"https://github.com/SoftwareDev/Markus","homepage":"http://www.markusproject.org","size":20651,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"MarkUsProject:git","ref":"git","sha":"664fd5c98d026d680f1571c9a30ae3602b22ab0a","user":{"login":"MarkUsProject","id":415874,"avatar_url":"https://avatars.githubusercontent.com/u/415874?v=3","gravatar_id":"","url":"https://api.github.com/users/MarkUsProject","html_url":"https://github.com/MarkUsProject","followers_url":"https://api.github.com/users/MarkUsProject/followers","following_url":"https://api.github.com/users/MarkUsProject/following{/other_user}","gists_url":"https://api.github.com/users/MarkUsProject/gists{/gist_id}","starred_url":"https://api.github.com/users/MarkUsProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarkUsProject/subscriptions","organizations_url":"https://api.github.com/users/MarkUsProject/orgs","repos_url":"https://api.github.com/users/MarkUsProject/repos","events_url":"https://api.github.com/users/MarkUsProject/events{/privacy}","received_events_url":"https://api.github.com/users/MarkUsProject/received_events","type":"Organization","site_admin":false},"repo":{"id":940538,"name":"Markus","full_name":"MarkUsProject/Markus","owner":{"login":"MarkUsProject","id":415874,"avatar_url":"https://avatars.githubusercontent.com/u/415874?v=3","gravatar_id":"","url":"https://api.github.com/users/MarkUsProject","html_url":"https://github.com/MarkUsProject","followers_url":"https://api.github.com/users/MarkUsProject/followers","following_url":"https://api.github.com/users/MarkUsProject/following{/other_user}","gists_url":"https://api.github.com/users/MarkUsProject/gists{/gist_id}","starred_url":"https://api.github.com/users/MarkUsProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarkUsProject/subscriptions","organizations_url":"https://api.github.com/users/MarkUsProject/orgs","repos_url":"https://api.github.com/users/MarkUsProject/repos","events_url":"https://api.github.com/users/MarkUsProject/events{/privacy}","received_events_url":"https://api.github.com/users/MarkUsProject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MarkUsProject/Markus","description":"Git repository of MarkUs","fork":false,"url":"https://api.github.com/repos/MarkUsProject/Markus","forks_url":"https://api.github.com/repos/MarkUsProject/Markus/forks","keys_url":"https://api.github.com/repos/MarkUsProject/Markus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MarkUsProject/Markus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MarkUsProject/Markus/teams","hooks_url":"https://api.github.com/repos/MarkUsProject/Markus/hooks","issue_events_url":"https://api.github.com/repos/MarkUsProject/Markus/issues/events{/number}","events_url":"https://api.github.com/repos/MarkUsProject/Markus/events","assignees_url":"https://api.github.com/repos/MarkUsProject/Markus/assignees{/user}","branches_url":"https://api.github.com/repos/MarkUsProject/Markus/branches{/branch}","tags_url":"https://api.github.com/repos/MarkUsProject/Markus/tags","blobs_url":"https://api.github.com/repos/MarkUsProject/Markus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MarkUsProject/Markus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MarkUsProject/Markus/git/refs{/sha}","trees_url":"https://api.github.com/repos/MarkUsProject/Markus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MarkUsProject/Markus/statuses/{sha}","languages_url":"https://api.github.com/repos/MarkUsProject/Markus/languages","stargazers_url":"https://api.github.com/repos/MarkUsProject/Markus/stargazers","contributors_url":"https://api.github.com/repos/MarkUsProject/Markus/contributors","subscribers_url":"https://api.github.com/repos/MarkUsProject/Markus/subscribers","subscription_url":"https://api.github.com/repos/MarkUsProject/Markus/subscription","commits_url":"https://api.github.com/repos/MarkUsProject/Markus/commits{/sha}","git_commits_url":"https://api.github.com/repos/MarkUsProject/Markus/git/commits{/sha}","comments_url":"https://api.github.com/repos/MarkUsProject/Markus/comments{/number}","issue_comment_url":"https://api.github.com/repos/MarkUsProject/Markus/issues/comments{/number}","contents_url":"https://api.github.com/repos/MarkUsProject/Markus/contents/{+path}","compare_url":"https://api.github.com/repos/MarkUsProject/Markus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MarkUsProject/Markus/merges","archive_url":"https://api.github.com/repos/MarkUsProject/Markus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MarkUsProject/Markus/downloads","issues_url":"https://api.github.com/repos/MarkUsProject/Markus/issues{/number}","pulls_url":"https://api.github.com/repos/MarkUsProject/Markus/pulls{/number}","milestones_url":"https://api.github.com/repos/MarkUsProject/Markus/milestones{/number}","notifications_url":"https://api.github.com/repos/MarkUsProject/Markus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MarkUsProject/Markus/labels{/name}","releases_url":"https://api.github.com/repos/MarkUsProject/Markus/releases{/id}","created_at":"2010-09-26T16:18:08Z","updated_at":"2015-04-06T00:56:36Z","pushed_at":"2015-04-07T00:37:11Z","git_url":"git://github.com/MarkUsProject/Markus.git","ssh_url":"git@github.com:MarkUsProject/Markus.git","clone_url":"https://github.com/MarkUsProject/Markus.git","svn_url":"https://github.com/MarkUsProject/Markus","homepage":"http://www.markusproject.org","size":47708,"stargazers_count":123,"watchers_count":123,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":150,"mirror_url":null,"open_issues_count":105,"forks":150,"open_issues":105,"watchers":123,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/MarkUsProject/Markus/pulls/2121"},"html":{"href":"https://github.com/MarkUsProject/Markus/pull/2121"},"issue":{"href":"https://api.github.com/repos/MarkUsProject/Markus/issues/2121"},"comments":{"href":"https://api.github.com/repos/MarkUsProject/Markus/issues/2121/comments"},"review_comments":{"href":"https://api.github.com/repos/MarkUsProject/Markus/pulls/2121/comments"},"review_comment":{"href":"https://api.github.com/repos/MarkUsProject/Markus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MarkUsProject/Markus/pulls/2121/commits"},"statuses":{"href":"https://api.github.com/repos/MarkUsProject/Markus/statuses/1549202da7401f97ef3b47d97b179438f6bc8757"}}}}