{"action":"created","comment":{"url":"https://api.github.com/repos/AusDTO/gov-au-beta/pulls/comments/75256886","id":75256886,"diff_hunk":"@@ -0,0 +1,57 @@\n+module Users\n+  class TwoFactorVerificationController < ApplicationController\n+    before_action :check_direct_otp_expiry, only: [:show, :create]\n+\n+\n+    def show\n+      unless current_user.totp_enabled?\n+        current_user.create_direct_otp\n+        r = SMSService.new.send_two_factor_confirmation_code!(current_user)\n+\n+        # TODO: make this async and handle service failure\n+        unless r.code == 202\n+          raise 'There was an error sending the SMS'","path":"app/controllers/users/two_factor_verification_controller.rb","position":13,"original_position":13,"commit_id":"e045d92de52c518b00bee917f1ab4af9ff28b84f","original_commit_id":"279f7e95aa63b43c02065fe5229623c3de7be912","user":{"login":"freshtonic","id":2769,"avatar_url":"https://avatars.githubusercontent.com/u/2769?v=3","gravatar_id":"","url":"https://api.github.com/users/freshtonic","html_url":"https://github.com/freshtonic","followers_url":"https://api.github.com/users/freshtonic/followers","following_url":"https://api.github.com/users/freshtonic/following{/other_user}","gists_url":"https://api.github.com/users/freshtonic/gists{/gist_id}","starred_url":"https://api.github.com/users/freshtonic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freshtonic/subscriptions","organizations_url":"https://api.github.com/users/freshtonic/orgs","repos_url":"https://api.github.com/users/freshtonic/repos","events_url":"https://api.github.com/users/freshtonic/events{/privacy}","received_events_url":"https://api.github.com/users/freshtonic/received_events","type":"User","site_admin":false},"body":"As we discussed on slack, fire the SMS request off in a new thread and ignore it if it fails to send, but indicate to the user that they can try again if they do not receive an SMS.","created_at":"2016-08-18T06:59:59Z","updated_at":"2016-08-18T06:59:59Z","html_url":"https://github.com/AusDTO/gov-au-beta/pull/405#discussion_r75256886","pull_request_url":"https://api.github.com/repos/AusDTO/gov-au-beta/pulls/405","_links":{"self":{"href":"https://api.github.com/repos/AusDTO/gov-au-beta/pulls/comments/75256886"},"html":{"href":"https://github.com/AusDTO/gov-au-beta/pull/405#discussion_r75256886"},"pull_request":{"href":"https://api.github.com/repos/AusDTO/gov-au-beta/pulls/405"}}},"pull_request":{"url":"https://api.github.com/repos/AusDTO/gov-au-beta/pulls/405","id":81736091,"html_url":"https://github.com/AusDTO/gov-au-beta/pull/405","diff_url":"https://github.com/AusDTO/gov-au-beta/pull/405.diff","patch_url":"https://github.com/AusDTO/gov-au-beta/pull/405.patch","issue_url":"https://api.github.com/repos/AusDTO/gov-au-beta/issues/405","number":405,"state":"open","locked":false,"title":"[SITES-590] Feature/2fa","user":{"login":"ltankey","id":5369670,"avatar_url":"https://avatars.githubusercontent.com/u/5369670?v=3","gravatar_id":"","url":"https://api.github.com/users/ltankey","html_url":"https://github.com/ltankey","followers_url":"https://api.github.com/users/ltankey/followers","following_url":"https://api.github.com/users/ltankey/following{/other_user}","gists_url":"https://api.github.com/users/ltankey/gists{/gist_id}","starred_url":"https://api.github.com/users/ltankey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ltankey/subscriptions","organizations_url":"https://api.github.com/users/ltankey/orgs","repos_url":"https://api.github.com/users/ltankey/repos","events_url":"https://api.github.com/users/ltankey/events{/privacy}","received_events_url":"https://api.github.com/users/ltankey/received_events","type":"User","site_admin":false},"body":"**COMMENTS WELCOME**\r\n\r\nThis is bigger than I intended, because it essentially became an epic.\r\n\r\nThe primary goal of this PR was to introduce 2FA to the application via a Devise extension called `two_factor_authentication`. However, as this gem only handles authentication (and not subsequent identity verification or 2FA setup), there are additional functions included to support this (that aren't particularly DRY just yet).\r\n\r\nThe functions include:\r\n\r\n* sign-in with 2FA (TOTP or OTP)\r\n* initialise 2FA for accounts to complete setup\r\n* verify identity via 2FA enforced with before_action calls \r\n\r\nThe components include:\r\n\r\n- [x] SMSService (as the name suggests)\r\n- [x] one-time-password service for generating one-time-passwords (and corresponding _sent_at) values, along with validation methods\r\n- [x] two_factor_authentication extension for Devise\r\n\r\nStill to do:\r\n\r\n- [ ] 2FA-verification protection of sensitive fields\r\n- [ ] google authenticator setup (qr code generation)","created_at":"2016-08-17T23:45:13Z","updated_at":"2016-08-18T06:59:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3f1c28487af208b9615e0e6c0447e3b4f0ffe255","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/AusDTO/gov-au-beta/pulls/405/commits","review_comments_url":"https://api.github.com/repos/AusDTO/gov-au-beta/pulls/405/comments","review_comment_url":"https://api.github.com/repos/AusDTO/gov-au-beta/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AusDTO/gov-au-beta/issues/405/comments","statuses_url":"https://api.github.com/repos/AusDTO/gov-au-beta/statuses/e045d92de52c518b00bee917f1ab4af9ff28b84f","head":{"label":"AusDTO:feature/2fa","ref":"feature/2fa","sha":"e045d92de52c518b00bee917f1ab4af9ff28b84f","user":{"login":"AusDTO","id":11763427,"avatar_url":"https://avatars.githubusercontent.com/u/11763427?v=3","gravatar_id":"","url":"https://api.github.com/users/AusDTO","html_url":"https://github.com/AusDTO","followers_url":"https://api.github.com/users/AusDTO/followers","following_url":"https://api.github.com/users/AusDTO/following{/other_user}","gists_url":"https://api.github.com/users/AusDTO/gists{/gist_id}","starred_url":"https://api.github.com/users/AusDTO/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AusDTO/subscriptions","organizations_url":"https://api.github.com/users/AusDTO/orgs","repos_url":"https://api.github.com/users/AusDTO/repos","events_url":"https://api.github.com/users/AusDTO/events{/privacy}","received_events_url":"https://api.github.com/users/AusDTO/received_events","type":"Organization","site_admin":false},"repo":{"id":57357025,"name":"gov-au-beta","full_name":"AusDTO/gov-au-beta","owner":{"login":"AusDTO","id":11763427,"avatar_url":"https://avatars.githubusercontent.com/u/11763427?v=3","gravatar_id":"","url":"https://api.github.com/users/AusDTO","html_url":"https://github.com/AusDTO","followers_url":"https://api.github.com/users/AusDTO/followers","following_url":"https://api.github.com/users/AusDTO/following{/other_user}","gists_url":"https://api.github.com/users/AusDTO/gists{/gist_id}","starred_url":"https://api.github.com/users/AusDTO/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AusDTO/subscriptions","organizations_url":"https://api.github.com/users/AusDTO/orgs","repos_url":"https://api.github.com/users/AusDTO/repos","events_url":"https://api.github.com/users/AusDTO/events{/privacy}","received_events_url":"https://api.github.com/users/AusDTO/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AusDTO/gov-au-beta","description":"User facing frontend to the GOV.AU content site.","fork":false,"url":"https://api.github.com/repos/AusDTO/gov-au-beta","forks_url":"https://api.github.com/repos/AusDTO/gov-au-beta/forks","keys_url":"https://api.github.com/repos/AusDTO/gov-au-beta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AusDTO/gov-au-beta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AusDTO/gov-au-beta/teams","hooks_url":"https://api.github.com/repos/AusDTO/gov-au-beta/hooks","issue_events_url":"https://api.github.com/repos/AusDTO/gov-au-beta/issues/events{/number}","events_url":"https://api.github.com/repos/AusDTO/gov-au-beta/events","assignees_url":"https://api.github.com/repos/AusDTO/gov-au-beta/assignees{/user}","branches_url":"https://api.github.com/repos/AusDTO/gov-au-beta/branches{/branch}","tags_url":"https://api.github.com/repos/AusDTO/gov-au-beta/tags","blobs_url":"https://api.github.com/repos/AusDTO/gov-au-beta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AusDTO/gov-au-beta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AusDTO/gov-au-beta/git/refs{/sha}","trees_url":"https://api.github.com/repos/AusDTO/gov-au-beta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AusDTO/gov-au-beta/statuses/{sha}","languages_url":"https://api.github.com/repos/AusDTO/gov-au-beta/languages","stargazers_url":"https://api.github.com/repos/AusDTO/gov-au-beta/stargazers","contributors_url":"https://api.github.com/repos/AusDTO/gov-au-beta/contributors","subscribers_url":"https://api.github.com/repos/AusDTO/gov-au-beta/subscribers","subscription_url":"https://api.github.com/repos/AusDTO/gov-au-beta/subscription","commits_url":"https://api.github.com/repos/AusDTO/gov-au-beta/commits{/sha}","git_commits_url":"https://api.github.com/repos/AusDTO/gov-au-beta/git/commits{/sha}","comments_url":"https://api.github.com/repos/AusDTO/gov-au-beta/comments{/number}","issue_comment_url":"https://api.github.com/repos/AusDTO/gov-au-beta/issues/comments{/number}","contents_url":"https://api.github.com/repos/AusDTO/gov-au-beta/contents/{+path}","compare_url":"https://api.github.com/repos/AusDTO/gov-au-beta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AusDTO/gov-au-beta/merges","archive_url":"https://api.github.com/repos/AusDTO/gov-au-beta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AusDTO/gov-au-beta/downloads","issues_url":"https://api.github.com/repos/AusDTO/gov-au-beta/issues{/number}","pulls_url":"https://api.github.com/repos/AusDTO/gov-au-beta/pulls{/number}","milestones_url":"https://api.github.com/repos/AusDTO/gov-au-beta/milestones{/number}","notifications_url":"https://api.github.com/repos/AusDTO/gov-au-beta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AusDTO/gov-au-beta/labels{/name}","releases_url":"https://api.github.com/repos/AusDTO/gov-au-beta/releases{/id}","deployments_url":"https://api.github.com/repos/AusDTO/gov-au-beta/deployments","created_at":"2016-04-29T05:32:18Z","updated_at":"2016-08-18T04:56:56Z","pushed_at":"2016-08-18T06:56:42Z","git_url":"git://github.com/AusDTO/gov-au-beta.git","ssh_url":"git@github.com:AusDTO/gov-au-beta.git","clone_url":"https://github.com/AusDTO/gov-au-beta.git","svn_url":"https://github.com/AusDTO/gov-au-beta","homepage":"","size":4425,"stargazers_count":7,"watchers_count":7,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":12,"forks":0,"open_issues":12,"watchers":7,"default_branch":"develop"}},"base":{"label":"AusDTO:develop","ref":"develop","sha":"6d403a187bde1e5c1fb259e0e39bf0e2b757ed3e","user":{"login":"AusDTO","id":11763427,"avatar_url":"https://avatars.githubusercontent.com/u/11763427?v=3","gravatar_id":"","url":"https://api.github.com/users/AusDTO","html_url":"https://github.com/AusDTO","followers_url":"https://api.github.com/users/AusDTO/followers","following_url":"https://api.github.com/users/AusDTO/following{/other_user}","gists_url":"https://api.github.com/users/AusDTO/gists{/gist_id}","starred_url":"https://api.github.com/users/AusDTO/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AusDTO/subscriptions","organizations_url":"https://api.github.com/users/AusDTO/orgs","repos_url":"https://api.github.com/users/AusDTO/repos","events_url":"https://api.github.com/users/AusDTO/events{/privacy}","received_events_url":"https://api.github.com/users/AusDTO/received_events","type":"Organization","site_admin":false},"repo":{"id":57357025,"name":"gov-au-beta","full_name":"AusDTO/gov-au-beta","owner":{"login":"AusDTO","id":11763427,"avatar_url":"https://avatars.githubusercontent.com/u/11763427?v=3","gravatar_id":"","url":"https://api.github.com/users/AusDTO","html_url":"https://github.com/AusDTO","followers_url":"https://api.github.com/users/AusDTO/followers","following_url":"https://api.github.com/users/AusDTO/following{/other_user}","gists_url":"https://api.github.com/users/AusDTO/gists{/gist_id}","starred_url":"https://api.github.com/users/AusDTO/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AusDTO/subscriptions","organizations_url":"https://api.github.com/users/AusDTO/orgs","repos_url":"https://api.github.com/users/AusDTO/repos","events_url":"https://api.github.com/users/AusDTO/events{/privacy}","received_events_url":"https://api.github.com/users/AusDTO/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AusDTO/gov-au-beta","description":"User facing frontend to the GOV.AU content site.","fork":false,"url":"https://api.github.com/repos/AusDTO/gov-au-beta","forks_url":"https://api.github.com/repos/AusDTO/gov-au-beta/forks","keys_url":"https://api.github.com/repos/AusDTO/gov-au-beta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AusDTO/gov-au-beta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AusDTO/gov-au-beta/teams","hooks_url":"https://api.github.com/repos/AusDTO/gov-au-beta/hooks","issue_events_url":"https://api.github.com/repos/AusDTO/gov-au-beta/issues/events{/number}","events_url":"https://api.github.com/repos/AusDTO/gov-au-beta/events","assignees_url":"https://api.github.com/repos/AusDTO/gov-au-beta/assignees{/user}","branches_url":"https://api.github.com/repos/AusDTO/gov-au-beta/branches{/branch}","tags_url":"https://api.github.com/repos/AusDTO/gov-au-beta/tags","blobs_url":"https://api.github.com/repos/AusDTO/gov-au-beta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AusDTO/gov-au-beta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AusDTO/gov-au-beta/git/refs{/sha}","trees_url":"https://api.github.com/repos/AusDTO/gov-au-beta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AusDTO/gov-au-beta/statuses/{sha}","languages_url":"https://api.github.com/repos/AusDTO/gov-au-beta/languages","stargazers_url":"https://api.github.com/repos/AusDTO/gov-au-beta/stargazers","contributors_url":"https://api.github.com/repos/AusDTO/gov-au-beta/contributors","subscribers_url":"https://api.github.com/repos/AusDTO/gov-au-beta/subscribers","subscription_url":"https://api.github.com/repos/AusDTO/gov-au-beta/subscription","commits_url":"https://api.github.com/repos/AusDTO/gov-au-beta/commits{/sha}","git_commits_url":"https://api.github.com/repos/AusDTO/gov-au-beta/git/commits{/sha}","comments_url":"https://api.github.com/repos/AusDTO/gov-au-beta/comments{/number}","issue_comment_url":"https://api.github.com/repos/AusDTO/gov-au-beta/issues/comments{/number}","contents_url":"https://api.github.com/repos/AusDTO/gov-au-beta/contents/{+path}","compare_url":"https://api.github.com/repos/AusDTO/gov-au-beta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AusDTO/gov-au-beta/merges","archive_url":"https://api.github.com/repos/AusDTO/gov-au-beta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AusDTO/gov-au-beta/downloads","issues_url":"https://api.github.com/repos/AusDTO/gov-au-beta/issues{/number}","pulls_url":"https://api.github.com/repos/AusDTO/gov-au-beta/pulls{/number}","milestones_url":"https://api.github.com/repos/AusDTO/gov-au-beta/milestones{/number}","notifications_url":"https://api.github.com/repos/AusDTO/gov-au-beta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AusDTO/gov-au-beta/labels{/name}","releases_url":"https://api.github.com/repos/AusDTO/gov-au-beta/releases{/id}","deployments_url":"https://api.github.com/repos/AusDTO/gov-au-beta/deployments","created_at":"2016-04-29T05:32:18Z","updated_at":"2016-08-18T04:56:56Z","pushed_at":"2016-08-18T06:56:42Z","git_url":"git://github.com/AusDTO/gov-au-beta.git","ssh_url":"git@github.com:AusDTO/gov-au-beta.git","clone_url":"https://github.com/AusDTO/gov-au-beta.git","svn_url":"https://github.com/AusDTO/gov-au-beta","homepage":"","size":4425,"stargazers_count":7,"watchers_count":7,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":12,"forks":0,"open_issues":12,"watchers":7,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/AusDTO/gov-au-beta/pulls/405"},"html":{"href":"https://github.com/AusDTO/gov-au-beta/pull/405"},"issue":{"href":"https://api.github.com/repos/AusDTO/gov-au-beta/issues/405"},"comments":{"href":"https://api.github.com/repos/AusDTO/gov-au-beta/issues/405/comments"},"review_comments":{"href":"https://api.github.com/repos/AusDTO/gov-au-beta/pulls/405/comments"},"review_comment":{"href":"https://api.github.com/repos/AusDTO/gov-au-beta/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AusDTO/gov-au-beta/pulls/405/commits"},"statuses":{"href":"https://api.github.com/repos/AusDTO/gov-au-beta/statuses/e045d92de52c518b00bee917f1ab4af9ff28b84f"}}}}
{"actor":{"display_login":"freshtonic"}}