{"action":"created","comment":{"url":"https://api.github.com/repos/18F/saml_idp/pulls/comments/188134899","pull_request_review_id":120052145,"id":188134899,"diff_hunk":"@@ -66,11 +66,30 @@ def clean_algorithm_name\n     private :clean_algorithm_name\n \n     def encoded\n-      key = OpenSSL::PKey::RSA.new(@secret_key, password)\n-      Base64.strict_encode64(key.sign(algorithm.new, raw))\n+      config = SamlIdp.config\n+      if config.cloudhsm_enabled\n+        cloudhsm_encoded(config)\n+      else\n+        key = OpenSSL::PKey::RSA.new(@secret_key, password)\n+        Base64.strict_encode64(key.sign(algorithm.new, raw))\n+      end\n     end\n     private :encoded\n \n+    def cloudhsm_encoded(config)\n+      config.pkcs11.active_slots.first.open do |session|\n+        session.login(:USER, config.cloudhsm_pin)\n+        begin\n+          key = session.find_objects(LABEL: @secret_key).first\n+          raise \"cloudhsm key not found for label: #{@secret_key}\" unless key\n+          Base64.strict_encode64(session.sign(:SHA256_RSA_PKCS, key, raw))\n+        ensure\n+          session.logout\n+        end","path":"lib/saml_idp/signed_info_builder.rb","position":25,"original_position":25,"commit_id":"d99beea66b90d546fbb69d3b33c3d2c357db1696","original_commit_id":"d99beea66b90d546fbb69d3b33c3d2c357db1696","user":{"login":"monfresh","id":811150,"avatar_url":"https://avatars1.githubusercontent.com/u/811150?v=4","gravatar_id":"","url":"https://api.github.com/users/monfresh","html_url":"https://github.com/monfresh","followers_url":"https://api.github.com/users/monfresh/followers","following_url":"https://api.github.com/users/monfresh/following{/other_user}","gists_url":"https://api.github.com/users/monfresh/gists{/gist_id}","starred_url":"https://api.github.com/users/monfresh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monfresh/subscriptions","organizations_url":"https://api.github.com/users/monfresh/orgs","repos_url":"https://api.github.com/users/monfresh/repos","events_url":"https://api.github.com/users/monfresh/events{/privacy}","received_events_url":"https://api.github.com/users/monfresh/received_events","type":"User","site_admin":false},"body":"Code Climate says this is not tested.","created_at":"2018-05-15T00:17:10Z","updated_at":"2018-05-15T00:17:22Z","html_url":"https://github.com/18F/saml_idp/pull/16#discussion_r188134899","pull_request_url":"https://api.github.com/repos/18F/saml_idp/pulls/16","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/18F/saml_idp/pulls/comments/188134899"},"html":{"href":"https://github.com/18F/saml_idp/pull/16#discussion_r188134899"},"pull_request":{"href":"https://api.github.com/repos/18F/saml_idp/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/18F/saml_idp/pulls/16","id":187887896,"html_url":"https://github.com/18F/saml_idp/pull/16","diff_url":"https://github.com/18F/saml_idp/pull/16.diff","patch_url":"https://github.com/18F/saml_idp/pull/16.patch","issue_url":"https://api.github.com/repos/18F/saml_idp/issues/16","number":16,"state":"open","locked":false,"title":"LG-269 Add CloudHSM to saml_idp gem","user":{"login":"stevegsa","id":34244063,"avatar_url":"https://avatars0.githubusercontent.com/u/34244063?v=4","gravatar_id":"","url":"https://api.github.com/users/stevegsa","html_url":"https://github.com/stevegsa","followers_url":"https://api.github.com/users/stevegsa/followers","following_url":"https://api.github.com/users/stevegsa/following{/other_user}","gists_url":"https://api.github.com/users/stevegsa/gists{/gist_id}","starred_url":"https://api.github.com/users/stevegsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevegsa/subscriptions","organizations_url":"https://api.github.com/users/stevegsa/orgs","repos_url":"https://api.github.com/users/stevegsa/repos","events_url":"https://api.github.com/users/stevegsa/events{/privacy}","received_events_url":"https://api.github.com/users/stevegsa/received_events","type":"User","site_admin":false},"body":"Add cloudhsm to the saml_idp gem to facilitate securing our private keys in an hsm.","created_at":"2018-05-14T16:48:29Z","updated_at":"2018-05-15T00:17:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"08d0c68cd245d372576aa303ec3f86520d4c1021","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/18F/saml_idp/pulls/16/commits","review_comments_url":"https://api.github.com/repos/18F/saml_idp/pulls/16/comments","review_comment_url":"https://api.github.com/repos/18F/saml_idp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/18F/saml_idp/issues/16/comments","statuses_url":"https://api.github.com/repos/18F/saml_idp/statuses/d99beea66b90d546fbb69d3b33c3d2c357db1696","head":{"label":"18F:stevegsa-add-cloudhsm-to-saml-idp-gem","ref":"stevegsa-add-cloudhsm-to-saml-idp-gem","sha":"d99beea66b90d546fbb69d3b33c3d2c357db1696","user":{"login":"18F","id":6233994,"avatar_url":"https://avatars0.githubusercontent.com/u/6233994?v=4","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"repo":{"id":66032570,"name":"saml_idp","full_name":"18F/saml_idp","owner":{"login":"18F","id":6233994,"avatar_url":"https://avatars0.githubusercontent.com/u/6233994?v=4","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/18F/saml_idp","description":null,"fork":true,"url":"https://api.github.com/repos/18F/saml_idp","forks_url":"https://api.github.com/repos/18F/saml_idp/forks","keys_url":"https://api.github.com/repos/18F/saml_idp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/18F/saml_idp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/18F/saml_idp/teams","hooks_url":"https://api.github.com/repos/18F/saml_idp/hooks","issue_events_url":"https://api.github.com/repos/18F/saml_idp/issues/events{/number}","events_url":"https://api.github.com/repos/18F/saml_idp/events","assignees_url":"https://api.github.com/repos/18F/saml_idp/assignees{/user}","branches_url":"https://api.github.com/repos/18F/saml_idp/branches{/branch}","tags_url":"https://api.github.com/repos/18F/saml_idp/tags","blobs_url":"https://api.github.com/repos/18F/saml_idp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/18F/saml_idp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/18F/saml_idp/git/refs{/sha}","trees_url":"https://api.github.com/repos/18F/saml_idp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/18F/saml_idp/statuses/{sha}","languages_url":"https://api.github.com/repos/18F/saml_idp/languages","stargazers_url":"https://api.github.com/repos/18F/saml_idp/stargazers","contributors_url":"https://api.github.com/repos/18F/saml_idp/contributors","subscribers_url":"https://api.github.com/repos/18F/saml_idp/subscribers","subscription_url":"https://api.github.com/repos/18F/saml_idp/subscription","commits_url":"https://api.github.com/repos/18F/saml_idp/commits{/sha}","git_commits_url":"https://api.github.com/repos/18F/saml_idp/git/commits{/sha}","comments_url":"https://api.github.com/repos/18F/saml_idp/comments{/number}","issue_comment_url":"https://api.github.com/repos/18F/saml_idp/issues/comments{/number}","contents_url":"https://api.github.com/repos/18F/saml_idp/contents/{+path}","compare_url":"https://api.github.com/repos/18F/saml_idp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/18F/saml_idp/merges","archive_url":"https://api.github.com/repos/18F/saml_idp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/18F/saml_idp/downloads","issues_url":"https://api.github.com/repos/18F/saml_idp/issues{/number}","pulls_url":"https://api.github.com/repos/18F/saml_idp/pulls{/number}","milestones_url":"https://api.github.com/repos/18F/saml_idp/milestones{/number}","notifications_url":"https://api.github.com/repos/18F/saml_idp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/18F/saml_idp/labels{/name}","releases_url":"https://api.github.com/repos/18F/saml_idp/releases{/id}","deployments_url":"https://api.github.com/repos/18F/saml_idp/deployments","created_at":"2016-08-18T21:43:04Z","updated_at":"2018-01-11T08:44:17Z","pushed_at":"2018-05-14T19:43:06Z","git_url":"git://github.com/18F/saml_idp.git","ssh_url":"git@github.com:18F/saml_idp.git","clone_url":"https://github.com/18F/saml_idp.git","svn_url":"https://github.com/18F/saml_idp","homepage":null,"size":399,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":3,"open_issues":3,"watchers":2,"default_branch":"master"}},"base":{"label":"18F:master","ref":"master","sha":"6277eb7c796cd94ce29e9405bb5a5d60a643bb98","user":{"login":"18F","id":6233994,"avatar_url":"https://avatars0.githubusercontent.com/u/6233994?v=4","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"repo":{"id":66032570,"name":"saml_idp","full_name":"18F/saml_idp","owner":{"login":"18F","id":6233994,"avatar_url":"https://avatars0.githubusercontent.com/u/6233994?v=4","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/18F/saml_idp","description":null,"fork":true,"url":"https://api.github.com/repos/18F/saml_idp","forks_url":"https://api.github.com/repos/18F/saml_idp/forks","keys_url":"https://api.github.com/repos/18F/saml_idp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/18F/saml_idp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/18F/saml_idp/teams","hooks_url":"https://api.github.com/repos/18F/saml_idp/hooks","issue_events_url":"https://api.github.com/repos/18F/saml_idp/issues/events{/number}","events_url":"https://api.github.com/repos/18F/saml_idp/events","assignees_url":"https://api.github.com/repos/18F/saml_idp/assignees{/user}","branches_url":"https://api.github.com/repos/18F/saml_idp/branches{/branch}","tags_url":"https://api.github.com/repos/18F/saml_idp/tags","blobs_url":"https://api.github.com/repos/18F/saml_idp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/18F/saml_idp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/18F/saml_idp/git/refs{/sha}","trees_url":"https://api.github.com/repos/18F/saml_idp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/18F/saml_idp/statuses/{sha}","languages_url":"https://api.github.com/repos/18F/saml_idp/languages","stargazers_url":"https://api.github.com/repos/18F/saml_idp/stargazers","contributors_url":"https://api.github.com/repos/18F/saml_idp/contributors","subscribers_url":"https://api.github.com/repos/18F/saml_idp/subscribers","subscription_url":"https://api.github.com/repos/18F/saml_idp/subscription","commits_url":"https://api.github.com/repos/18F/saml_idp/commits{/sha}","git_commits_url":"https://api.github.com/repos/18F/saml_idp/git/commits{/sha}","comments_url":"https://api.github.com/repos/18F/saml_idp/comments{/number}","issue_comment_url":"https://api.github.com/repos/18F/saml_idp/issues/comments{/number}","contents_url":"https://api.github.com/repos/18F/saml_idp/contents/{+path}","compare_url":"https://api.github.com/repos/18F/saml_idp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/18F/saml_idp/merges","archive_url":"https://api.github.com/repos/18F/saml_idp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/18F/saml_idp/downloads","issues_url":"https://api.github.com/repos/18F/saml_idp/issues{/number}","pulls_url":"https://api.github.com/repos/18F/saml_idp/pulls{/number}","milestones_url":"https://api.github.com/repos/18F/saml_idp/milestones{/number}","notifications_url":"https://api.github.com/repos/18F/saml_idp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/18F/saml_idp/labels{/name}","releases_url":"https://api.github.com/repos/18F/saml_idp/releases{/id}","deployments_url":"https://api.github.com/repos/18F/saml_idp/deployments","created_at":"2016-08-18T21:43:04Z","updated_at":"2018-01-11T08:44:17Z","pushed_at":"2018-05-14T19:43:06Z","git_url":"git://github.com/18F/saml_idp.git","ssh_url":"git@github.com:18F/saml_idp.git","clone_url":"https://github.com/18F/saml_idp.git","svn_url":"https://github.com/18F/saml_idp","homepage":null,"size":399,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":3,"open_issues":3,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/18F/saml_idp/pulls/16"},"html":{"href":"https://github.com/18F/saml_idp/pull/16"},"issue":{"href":"https://api.github.com/repos/18F/saml_idp/issues/16"},"comments":{"href":"https://api.github.com/repos/18F/saml_idp/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/18F/saml_idp/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/18F/saml_idp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/18F/saml_idp/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/18F/saml_idp/statuses/d99beea66b90d546fbb69d3b33c3d2c357db1696"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"monfresh"}}