From 07dd5df33bf83a7e0a26c7e66cff3af131a823f4 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 8 Aug 2013 13:34:30 -0700 Subject: [PATCH] Support Twitch.tv as an OAuth provider Summary: This is mostly for personal reasons / lols, but they have a perfectly functional OAuth2 API and it takes like 15 minutes to add a provider now and I was in this code anyway... @chad, we could use JIRA, Twitter and Twitch.tv auth icons if you have a chance. Test Plan: {F53564} Reviewers: btrahan, chad Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D6706 --- src/__phutil_library_map__.php | 2 ++ .../PhabricatorAuthProviderOAuthTwitch.php | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/applications/auth/provider/PhabricatorAuthProviderOAuthTwitch.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 172c796c8a..b283398dae 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -901,6 +901,7 @@ phutil_register_library_map(array( 'PhabricatorAuthProviderOAuthFacebook' => 'applications/auth/provider/PhabricatorAuthProviderOAuthFacebook.php', 'PhabricatorAuthProviderOAuthGitHub' => 'applications/auth/provider/PhabricatorAuthProviderOAuthGitHub.php', 'PhabricatorAuthProviderOAuthGoogle' => 'applications/auth/provider/PhabricatorAuthProviderOAuthGoogle.php', + 'PhabricatorAuthProviderOAuthTwitch' => 'applications/auth/provider/PhabricatorAuthProviderOAuthTwitch.php', 'PhabricatorAuthProviderPassword' => 'applications/auth/provider/PhabricatorAuthProviderPassword.php', 'PhabricatorAuthRegisterController' => 'applications/auth/controller/PhabricatorAuthRegisterController.php', 'PhabricatorAuthStartController' => 'applications/auth/controller/PhabricatorAuthStartController.php', @@ -2939,6 +2940,7 @@ phutil_register_library_map(array( 'PhabricatorAuthProviderOAuthFacebook' => 'PhabricatorAuthProviderOAuth', 'PhabricatorAuthProviderOAuthGitHub' => 'PhabricatorAuthProviderOAuth', 'PhabricatorAuthProviderOAuthGoogle' => 'PhabricatorAuthProviderOAuth', + 'PhabricatorAuthProviderOAuthTwitch' => 'PhabricatorAuthProviderOAuth', 'PhabricatorAuthProviderPassword' => 'PhabricatorAuthProvider', 'PhabricatorAuthRegisterController' => 'PhabricatorAuthController', 'PhabricatorAuthStartController' => 'PhabricatorAuthController', diff --git a/src/applications/auth/provider/PhabricatorAuthProviderOAuthTwitch.php b/src/applications/auth/provider/PhabricatorAuthProviderOAuthTwitch.php new file mode 100644 index 0000000000..4cd192757c --- /dev/null +++ b/src/applications/auth/provider/PhabricatorAuthProviderOAuthTwitch.php @@ -0,0 +1,36 @@ +getLoginURI(); + + return pht( + "To configure Twitch.tv OAuth, create a new application here:". + "\n\n". + "http://www.twitch.tv/settings/applications". + "\n\n". + "When creating your application, use these settings:". + "\n\n". + " - **Redirect URI:** Set this to: `%s`". + "\n\n". + "After completing configuration, copy the **Client ID** and ". + "**Client Secret** to the fields above. (You may need to generate the ". + "client secret by clicking 'New Secret' first.)", + $login_uri); + } + + protected function newOAuthAdapter() { + return new PhutilAuthAdapterOAuthTwitch(); + } + + protected function getLoginIcon() { + return 'Twitch'; + } + +}