From e117b320e27848af89f21f18e993f90f892d28cc Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 20 Jun 2013 11:19:11 -0700 Subject: [PATCH] Add Amazon and Asana providers Summary: Ref T1536. Ref T2852. Adds providers for Asana and Amazon. See D6248. Test Plan: {F46960} {F46961} Reviewers: btrahan, chad Reviewed By: chad CC: aran Maniphest Tasks: T1536, T2852 Differential Revision: https://secure.phabricator.com/D6249 --- src/__phutil_library_map__.php | 4 ++ .../PhabricatorAuthProviderOAuthAmazon.php | 46 +++++++++++++++++++ .../PhabricatorAuthProviderOAuthAsana.php | 38 +++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 src/applications/auth/provider/PhabricatorAuthProviderOAuthAmazon.php create mode 100644 src/applications/auth/provider/PhabricatorAuthProviderOAuthAsana.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 8278634593..5d155403b9 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -838,6 +838,8 @@ phutil_register_library_map(array( 'PhabricatorAuthProviderConfigTransactionQuery' => 'applications/auth/query/PhabricatorAuthProviderConfigTransactionQuery.php', 'PhabricatorAuthProviderLDAP' => 'applications/auth/provider/PhabricatorAuthProviderLDAP.php', 'PhabricatorAuthProviderOAuth' => 'applications/auth/provider/PhabricatorAuthProviderOAuth.php', + 'PhabricatorAuthProviderOAuthAmazon' => 'applications/auth/provider/PhabricatorAuthProviderOAuthAmazon.php', + 'PhabricatorAuthProviderOAuthAsana' => 'applications/auth/provider/PhabricatorAuthProviderOAuthAsana.php', 'PhabricatorAuthProviderOAuthDisqus' => 'applications/auth/provider/PhabricatorAuthProviderOAuthDisqus.php', 'PhabricatorAuthProviderOAuthFacebook' => 'applications/auth/provider/PhabricatorAuthProviderOAuthFacebook.php', 'PhabricatorAuthProviderOAuthGitHub' => 'applications/auth/provider/PhabricatorAuthProviderOAuthGitHub.php', @@ -2700,6 +2702,8 @@ phutil_register_library_map(array( 'PhabricatorAuthProviderConfigTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'PhabricatorAuthProviderLDAP' => 'PhabricatorAuthProvider', 'PhabricatorAuthProviderOAuth' => 'PhabricatorAuthProvider', + 'PhabricatorAuthProviderOAuthAmazon' => 'PhabricatorAuthProviderOAuth', + 'PhabricatorAuthProviderOAuthAsana' => 'PhabricatorAuthProviderOAuth', 'PhabricatorAuthProviderOAuthDisqus' => 'PhabricatorAuthProviderOAuth', 'PhabricatorAuthProviderOAuthFacebook' => 'PhabricatorAuthProviderOAuth', 'PhabricatorAuthProviderOAuthGitHub' => 'PhabricatorAuthProviderOAuth', diff --git a/src/applications/auth/provider/PhabricatorAuthProviderOAuthAmazon.php b/src/applications/auth/provider/PhabricatorAuthProviderOAuthAmazon.php new file mode 100644 index 0000000000..99f7fccd29 --- /dev/null +++ b/src/applications/auth/provider/PhabricatorAuthProviderOAuthAmazon.php @@ -0,0 +1,46 @@ +getLoginURI(); + + $uri = new PhutilURI(PhabricatorEnv::getProductionURI('/')); + $https_note = null; + if ($uri->getProtocol() !== 'https') { + $https_note = pht( + 'NOTE: Amazon **requires** HTTPS, but your Phabricator install does '. + 'not use HTTPS. **You will not be able to add Amazon as an '. + 'authentication provider until you configure HTTPS on this install**.'); + } + + return pht( + "%s\n\n". + "To configure Amazon OAuth, create a new 'API Project' here:". + "\n\n". + "http://login.amazon.com/manageApps". + "\n\n". + "Use these settings:". + "\n\n". + " - **Allowed Return URLs:** Add this: `%s`". + "\n\n". + "After completing configuration, copy the **Client ID** and ". + "**Client Secret** to the fields above.", + $https_note, + $login_uri); + } + + protected function newOAuthAdapter() { + return new PhutilAuthAdapterOAuthAmazon(); + } + + protected function getLoginIcon() { + return 'Amazon'; + } + +} diff --git a/src/applications/auth/provider/PhabricatorAuthProviderOAuthAsana.php b/src/applications/auth/provider/PhabricatorAuthProviderOAuthAsana.php new file mode 100644 index 0000000000..225f3aa18b --- /dev/null +++ b/src/applications/auth/provider/PhabricatorAuthProviderOAuthAsana.php @@ -0,0 +1,38 @@ +getLoginURI(); + + return pht( + "To configure Asana OAuth, create a new application by logging in to ". + "Asana and going to **Account Settings**, then **Apps**, then ". + "**Add New Application**.". + "\n\n". + "Use these settings:". + "\n\n". + " - **App URL:** Set this to: `%s`\n". + " - **Redirect URL:** Set this to: `%s`". + "\n\n". + "After completing configuration, copy the **Client ID** and ". + "**Client Secret** to the fields above.", + $app_uri, + $login_uri); + } + + protected function newOAuthAdapter() { + return new PhutilAuthAdapterOAuthAsana(); + } + + protected function getLoginIcon() { + return 'Asana'; + } + +}