{"action":"created","comment":{"url":"https://api.github.com/repos/vanilla/vanilla/pulls/comments/169739418","pull_request_review_id":98314066,"id":169739418,"diff_hunk":"@@ -0,0 +1,61 @@\n+<?php\n+/**\n+ * @author Alexandre (DaazKu) Chouinard <alexandre.c@vanillaforums.com>\n+ * @copyright 2009-2018 Vanilla Forums Inc.\n+ * @license https://opensource.org/licenses/GPL-2.0 GPL-2.0\n+ */\n+\n+class OAuth2AuthenticatorPlugin extends Gdn_Plugin {\n+\n+    /**\n+     * Inject sign-in button into the sign in page.\n+     *\n+     * @param EntryController $sender.\n+     * @param EntryController $args.\n+     *\n+     * @return mixed|bool Return null if not configured\n+     */\n+    public function entryController_signIn_handler($sender, $args) {\n+        if (isset($sender->Data['Methods'])) {\n+            // Add the sign in button method to the controller.\n+            $method = [\n+                'Name' => 'oauth2',\n+                'SignInHtml' => $this->signInButton()\n+            ];\n+\n+            $sender->Data['Methods'][] = $method;\n+        }\n+    }\n+    /**\n+     * Inject a sign-in icon into the ME menu.\n+     *\n+     * @param Gdn_Controller $sender.\n+     * @param Gdn_Controller $args.\n+     */\n+    public function base_beforeSignInButton_handler($sender, $args) {\n+        echo ' '.$this->signInButton('icon').' ';\n+    }\n+\n+\n+    public function signInButton($type = 'button') {\n+        $auth = new \\Vanilla\\Authenticator\\OAuth2Authenticator('oauth2', new Gdn_AuthenticationProviderModel());\n+\n+        $provider = $auth->providerData;\n+        $uri = val('AuthorizeUrl', $provider);\n+        $redirect_uri = '/authenticate/oauth2';\n+        $defaultParams = [\n+            'response_type' => 'code',\n+            'client_id' => val('AssociationKey', $provider),\n+            'redirect_uri' => url($redirect_uri, true),\n+            'scope' => val('AcceptedScope', $provider)\n+        ];\n+\n+        $url =  $uri.'?'.http_build_query($defaultParams);\n+","path":"plugins/oauth2authenticator/OAuth2AuthenticatorPlugin.php","position":54,"original_position":54,"commit_id":"5d013368d15b6fb25eef487b1b2a08dcbaf49270","original_commit_id":"5d013368d15b6fb25eef487b1b2a08dcbaf49270","user":{"login":"initvector","id":1390241,"avatar_url":"https://avatars0.githubusercontent.com/u/1390241?v=4","gravatar_id":"","url":"https://api.github.com/users/initvector","html_url":"https://github.com/initvector","followers_url":"https://api.github.com/users/initvector/followers","following_url":"https://api.github.com/users/initvector/following{/other_user}","gists_url":"https://api.github.com/users/initvector/gists{/gist_id}","starred_url":"https://api.github.com/users/initvector/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/initvector/subscriptions","organizations_url":"https://api.github.com/users/initvector/orgs","repos_url":"https://api.github.com/users/initvector/repos","events_url":"https://api.github.com/users/initvector/events{/privacy}","received_events_url":"https://api.github.com/users/initvector/received_events","type":"User","site_admin":false},"body":"One too many empty lines.","created_at":"2018-02-21T18:47:35Z","updated_at":"2018-02-21T18:53:52Z","html_url":"https://github.com/vanilla/vanilla/pull/6655#discussion_r169739418","pull_request_url":"https://api.github.com/repos/vanilla/vanilla/pulls/6655","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/vanilla/vanilla/pulls/comments/169739418"},"html":{"href":"https://github.com/vanilla/vanilla/pull/6655#discussion_r169739418"},"pull_request":{"href":"https://api.github.com/repos/vanilla/vanilla/pulls/6655"}}},"pull_request":{"url":"https://api.github.com/repos/vanilla/vanilla/pulls/6655","id":170554381,"html_url":"https://github.com/vanilla/vanilla/pull/6655","diff_url":"https://github.com/vanilla/vanilla/pull/6655.diff","patch_url":"https://github.com/vanilla/vanilla/pull/6655.patch","issue_url":"https://api.github.com/repos/vanilla/vanilla/issues/6655","number":6655,"state":"open","locked":false,"title":"Add OAuth2SSOAuthenticator + empty plugin","user":{"login":"DaazKu","id":2412909,"avatar_url":"https://avatars0.githubusercontent.com/u/2412909?v=4","gravatar_id":"","url":"https://api.github.com/users/DaazKu","html_url":"https://github.com/DaazKu","followers_url":"https://api.github.com/users/DaazKu/followers","following_url":"https://api.github.com/users/DaazKu/following{/other_user}","gists_url":"https://api.github.com/users/DaazKu/gists{/gist_id}","starred_url":"https://api.github.com/users/DaazKu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaazKu/subscriptions","organizations_url":"https://api.github.com/users/DaazKu/orgs","repos_url":"https://api.github.com/users/DaazKu/repos","events_url":"https://api.github.com/users/DaazKu/events{/privacy}","received_events_url":"https://api.github.com/users/DaazKu/received_events","type":"User","site_admin":false},"body":"Closes https://github.com/vanilla/vanilla/issues/6602\r\n\r\n- Add OAuth2SSOAuthenticator which allows OAuth2 SSO connexions to work with /authenticate\r\n\r\nHow to test:\r\n\r\nHere are the providers I used to test. Because of the redirects verification you have to have your main vanilla instance run on `dev.vanilla.localhost`.\r\n```sql\r\nINSERT INTO `GDN_UserAuthenticationProvider` (`AuthenticationKey`, `AuthenticationSchemeAlias`, `Name`, `URL`, `AssociationSecret`, `AssociationHashMethod`, `AuthenticateUrl`, `RegisterUrl`, `SignInUrl`, `SignOutUrl`, `PasswordUrl`, `ProfileUrl`, `Attributes`, `Active`, `IsDefault`)\r\nVALUES\r\n\t('oauth2', 'oauth2', 'oauth2', NULL, '1234', NULL, NULL, '', 'https://sso.vanilla.localhost', '', NULL, 'https://sso.vanilla.localhost/oauth2/profile', '{\\\"AssociationKey\\\":\\\"stub_oauth2\\\",\\\"AuthorizeUrl\\\":\\\"https://sso.vanilla.localhost/oauth2/authorize\\\",\\\"TokenUrl\\\":\\\"https://sso.vanilla.localhost/oauth2/access_token?XDEBUG_SESSION=PHPSTORM\\\",\\\"AcceptedScope\\\":\\\"profile\\\",\\\"ProfileKeyEmail\\\":\\\"Email\\\",\\\"ProfileKeyPhoto\\\":\\\"\\\",\\\"ProfileKeyName\\\":\\\"Name\\\",\\\"ProfileKeyFullName\\\":\\\"Name\\\",\\\"ProfileKeyUniqueID\\\":\\\"UserID\\\",\\\"BearerToken\\\":false,\\\"BaseUrl\\\":\\\"https://sso.vanilla.localhost\\\"}', 1, 0),\r\n\t('oauth2-bak', 'oauth2-bak', NULL, NULL, '8ZosRm5QeBCO06hKH4io3TsfO7lxVppH01HButehUweSi3fzSpFOPGzPKyaKDqCe', NULL, NULL, '', 'https://vanilla.auth0.com', '', NULL, 'https://vanilla.auth0.com/userinfo', '{\\\"AssociationKey\\\":\\\"C61DLFgy5lik_7X_mPVpRdphK1FxeZYI\\\",\\\"AuthorizeUrl\\\":\\\"https://vanilla.auth0.com/authorize?audience=https%3A%2F%2Fvanilla.auth0.com%2Fapi%2Fv2%2F\\\",\\\"TokenUrl\\\":\\\"https://vanilla.auth0.com/oauth/token\\\",\\\"AcceptedScope\\\":\\\"openid profile email\\\",\\\"ProfileKeyEmail\\\":\\\"email\\\",\\\"ProfileKeyPhoto\\\":\\\"picture\\\",\\\"ProfileKeyName\\\":\\\"name\\\",\\\"ProfileKeyFullName\\\":\\\"\\\",\\\"ProfileKeyUniqueID\\\":\\\"sub\\\",\\\"BearerToken\\\":false,\\\"BaseUrl\\\":\\\"https://vanilla.auth0.com\\\"}', 1, 0);\r\n```\r\nOAuth2 does not allow multiple providers to be created right now. You'll have to switch AuthenticationKey and AuthenticationSchemeAlias to test the other provider.\r\n\r\nOne provider is Auth0\r\nThe other is in https://github.com/vanilla/stub-sso-providers\r\n\r\n**Note that the OAuth2 icon is not visible.** ","created_at":"2018-02-21T18:40:58Z","updated_at":"2018-02-21T18:53:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cfbf279daba3cc38e4012e5a1d44e1eaca3c8f01","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/vanilla/vanilla/pulls/6655/commits","review_comments_url":"https://api.github.com/repos/vanilla/vanilla/pulls/6655/comments","review_comment_url":"https://api.github.com/repos/vanilla/vanilla/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vanilla/vanilla/issues/6655/comments","statuses_url":"https://api.github.com/repos/vanilla/vanilla/statuses/5d013368d15b6fb25eef487b1b2a08dcbaf49270","head":{"label":"vanilla:feature/base-oaut2-authenticator","ref":"feature/base-oaut2-authenticator","sha":"5d013368d15b6fb25eef487b1b2a08dcbaf49270","user":{"login":"vanilla","id":7443552,"avatar_url":"https://avatars1.githubusercontent.com/u/7443552?v=4","gravatar_id":"","url":"https://api.github.com/users/vanilla","html_url":"https://github.com/vanilla","followers_url":"https://api.github.com/users/vanilla/followers","following_url":"https://api.github.com/users/vanilla/following{/other_user}","gists_url":"https://api.github.com/users/vanilla/gists{/gist_id}","starred_url":"https://api.github.com/users/vanilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanilla/subscriptions","organizations_url":"https://api.github.com/users/vanilla/orgs","repos_url":"https://api.github.com/users/vanilla/repos","events_url":"https://api.github.com/users/vanilla/events{/privacy}","received_events_url":"https://api.github.com/users/vanilla/received_events","type":"Organization","site_admin":false},"repo":{"id":232390,"name":"vanilla","full_name":"vanilla/vanilla","owner":{"login":"vanilla","id":7443552,"avatar_url":"https://avatars1.githubusercontent.com/u/7443552?v=4","gravatar_id":"","url":"https://api.github.com/users/vanilla","html_url":"https://github.com/vanilla","followers_url":"https://api.github.com/users/vanilla/followers","following_url":"https://api.github.com/users/vanilla/following{/other_user}","gists_url":"https://api.github.com/users/vanilla/gists{/gist_id}","starred_url":"https://api.github.com/users/vanilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanilla/subscriptions","organizations_url":"https://api.github.com/users/vanilla/orgs","repos_url":"https://api.github.com/users/vanilla/repos","events_url":"https://api.github.com/users/vanilla/events{/privacy}","received_events_url":"https://api.github.com/users/vanilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vanilla/vanilla","description":"Vanilla is a powerfully simple discussion forum you can easily customize to make as unique as your community.","fork":false,"url":"https://api.github.com/repos/vanilla/vanilla","forks_url":"https://api.github.com/repos/vanilla/vanilla/forks","keys_url":"https://api.github.com/repos/vanilla/vanilla/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vanilla/vanilla/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vanilla/vanilla/teams","hooks_url":"https://api.github.com/repos/vanilla/vanilla/hooks","issue_events_url":"https://api.github.com/repos/vanilla/vanilla/issues/events{/number}","events_url":"https://api.github.com/repos/vanilla/vanilla/events","assignees_url":"https://api.github.com/repos/vanilla/vanilla/assignees{/user}","branches_url":"https://api.github.com/repos/vanilla/vanilla/branches{/branch}","tags_url":"https://api.github.com/repos/vanilla/vanilla/tags","blobs_url":"https://api.github.com/repos/vanilla/vanilla/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vanilla/vanilla/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vanilla/vanilla/git/refs{/sha}","trees_url":"https://api.github.com/repos/vanilla/vanilla/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vanilla/vanilla/statuses/{sha}","languages_url":"https://api.github.com/repos/vanilla/vanilla/languages","stargazers_url":"https://api.github.com/repos/vanilla/vanilla/stargazers","contributors_url":"https://api.github.com/repos/vanilla/vanilla/contributors","subscribers_url":"https://api.github.com/repos/vanilla/vanilla/subscribers","subscription_url":"https://api.github.com/repos/vanilla/vanilla/subscription","commits_url":"https://api.github.com/repos/vanilla/vanilla/commits{/sha}","git_commits_url":"https://api.github.com/repos/vanilla/vanilla/git/commits{/sha}","comments_url":"https://api.github.com/repos/vanilla/vanilla/comments{/number}","issue_comment_url":"https://api.github.com/repos/vanilla/vanilla/issues/comments{/number}","contents_url":"https://api.github.com/repos/vanilla/vanilla/contents/{+path}","compare_url":"https://api.github.com/repos/vanilla/vanilla/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vanilla/vanilla/merges","archive_url":"https://api.github.com/repos/vanilla/vanilla/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vanilla/vanilla/downloads","issues_url":"https://api.github.com/repos/vanilla/vanilla/issues{/number}","pulls_url":"https://api.github.com/repos/vanilla/vanilla/pulls{/number}","milestones_url":"https://api.github.com/repos/vanilla/vanilla/milestones{/number}","notifications_url":"https://api.github.com/repos/vanilla/vanilla/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vanilla/vanilla/labels{/name}","releases_url":"https://api.github.com/repos/vanilla/vanilla/releases{/id}","deployments_url":"https://api.github.com/repos/vanilla/vanilla/deployments","created_at":"2009-06-21T01:41:25Z","updated_at":"2018-02-20T13:39:01Z","pushed_at":"2018-02-21T18:50:56Z","git_url":"git://github.com/vanilla/vanilla.git","ssh_url":"git@github.com:vanilla/vanilla.git","clone_url":"https://github.com/vanilla/vanilla.git","svn_url":"https://github.com/vanilla/vanilla","homepage":"https://open.vanillaforums.com","size":58617,"stargazers_count":1781,"watchers_count":1781,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":628,"mirror_url":null,"archived":false,"open_issues_count":477,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0"},"forks":628,"open_issues":477,"watchers":1781,"default_branch":"master"}},"base":{"label":"vanilla:feature/oauth2-authenticator","ref":"feature/oauth2-authenticator","sha":"061b7280bf79cfc1b2d8045aad1decc3fb36acd4","user":{"login":"vanilla","id":7443552,"avatar_url":"https://avatars1.githubusercontent.com/u/7443552?v=4","gravatar_id":"","url":"https://api.github.com/users/vanilla","html_url":"https://github.com/vanilla","followers_url":"https://api.github.com/users/vanilla/followers","following_url":"https://api.github.com/users/vanilla/following{/other_user}","gists_url":"https://api.github.com/users/vanilla/gists{/gist_id}","starred_url":"https://api.github.com/users/vanilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanilla/subscriptions","organizations_url":"https://api.github.com/users/vanilla/orgs","repos_url":"https://api.github.com/users/vanilla/repos","events_url":"https://api.github.com/users/vanilla/events{/privacy}","received_events_url":"https://api.github.com/users/vanilla/received_events","type":"Organization","site_admin":false},"repo":{"id":232390,"name":"vanilla","full_name":"vanilla/vanilla","owner":{"login":"vanilla","id":7443552,"avatar_url":"https://avatars1.githubusercontent.com/u/7443552?v=4","gravatar_id":"","url":"https://api.github.com/users/vanilla","html_url":"https://github.com/vanilla","followers_url":"https://api.github.com/users/vanilla/followers","following_url":"https://api.github.com/users/vanilla/following{/other_user}","gists_url":"https://api.github.com/users/vanilla/gists{/gist_id}","starred_url":"https://api.github.com/users/vanilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanilla/subscriptions","organizations_url":"https://api.github.com/users/vanilla/orgs","repos_url":"https://api.github.com/users/vanilla/repos","events_url":"https://api.github.com/users/vanilla/events{/privacy}","received_events_url":"https://api.github.com/users/vanilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vanilla/vanilla","description":"Vanilla is a powerfully simple discussion forum you can easily customize to make as unique as your community.","fork":false,"url":"https://api.github.com/repos/vanilla/vanilla","forks_url":"https://api.github.com/repos/vanilla/vanilla/forks","keys_url":"https://api.github.com/repos/vanilla/vanilla/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vanilla/vanilla/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vanilla/vanilla/teams","hooks_url":"https://api.github.com/repos/vanilla/vanilla/hooks","issue_events_url":"https://api.github.com/repos/vanilla/vanilla/issues/events{/number}","events_url":"https://api.github.com/repos/vanilla/vanilla/events","assignees_url":"https://api.github.com/repos/vanilla/vanilla/assignees{/user}","branches_url":"https://api.github.com/repos/vanilla/vanilla/branches{/branch}","tags_url":"https://api.github.com/repos/vanilla/vanilla/tags","blobs_url":"https://api.github.com/repos/vanilla/vanilla/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vanilla/vanilla/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vanilla/vanilla/git/refs{/sha}","trees_url":"https://api.github.com/repos/vanilla/vanilla/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vanilla/vanilla/statuses/{sha}","languages_url":"https://api.github.com/repos/vanilla/vanilla/languages","stargazers_url":"https://api.github.com/repos/vanilla/vanilla/stargazers","contributors_url":"https://api.github.com/repos/vanilla/vanilla/contributors","subscribers_url":"https://api.github.com/repos/vanilla/vanilla/subscribers","subscription_url":"https://api.github.com/repos/vanilla/vanilla/subscription","commits_url":"https://api.github.com/repos/vanilla/vanilla/commits{/sha}","git_commits_url":"https://api.github.com/repos/vanilla/vanilla/git/commits{/sha}","comments_url":"https://api.github.com/repos/vanilla/vanilla/comments{/number}","issue_comment_url":"https://api.github.com/repos/vanilla/vanilla/issues/comments{/number}","contents_url":"https://api.github.com/repos/vanilla/vanilla/contents/{+path}","compare_url":"https://api.github.com/repos/vanilla/vanilla/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vanilla/vanilla/merges","archive_url":"https://api.github.com/repos/vanilla/vanilla/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vanilla/vanilla/downloads","issues_url":"https://api.github.com/repos/vanilla/vanilla/issues{/number}","pulls_url":"https://api.github.com/repos/vanilla/vanilla/pulls{/number}","milestones_url":"https://api.github.com/repos/vanilla/vanilla/milestones{/number}","notifications_url":"https://api.github.com/repos/vanilla/vanilla/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vanilla/vanilla/labels{/name}","releases_url":"https://api.github.com/repos/vanilla/vanilla/releases{/id}","deployments_url":"https://api.github.com/repos/vanilla/vanilla/deployments","created_at":"2009-06-21T01:41:25Z","updated_at":"2018-02-20T13:39:01Z","pushed_at":"2018-02-21T18:50:56Z","git_url":"git://github.com/vanilla/vanilla.git","ssh_url":"git@github.com:vanilla/vanilla.git","clone_url":"https://github.com/vanilla/vanilla.git","svn_url":"https://github.com/vanilla/vanilla","homepage":"https://open.vanillaforums.com","size":58617,"stargazers_count":1781,"watchers_count":1781,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":628,"mirror_url":null,"archived":false,"open_issues_count":477,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0"},"forks":628,"open_issues":477,"watchers":1781,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vanilla/vanilla/pulls/6655"},"html":{"href":"https://github.com/vanilla/vanilla/pull/6655"},"issue":{"href":"https://api.github.com/repos/vanilla/vanilla/issues/6655"},"comments":{"href":"https://api.github.com/repos/vanilla/vanilla/issues/6655/comments"},"review_comments":{"href":"https://api.github.com/repos/vanilla/vanilla/pulls/6655/comments"},"review_comment":{"href":"https://api.github.com/repos/vanilla/vanilla/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vanilla/vanilla/pulls/6655/commits"},"statuses":{"href":"https://api.github.com/repos/vanilla/vanilla/statuses/5d013368d15b6fb25eef487b1b2a08dcbaf49270"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"initvector"}}