Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/provider/PhabricatorJIRAAuthProvider.php
Show All 13 Lines | final class PhabricatorJIRAAuthProvider | ||||
public function getConfigurationHelp() { | public function getConfigurationHelp() { | ||||
return $this->getProviderConfigurationHelp(); | return $this->getProviderConfigurationHelp(); | ||||
} | } | ||||
protected function getProviderConfigurationHelp() { | protected function getProviderConfigurationHelp() { | ||||
if ($this->isSetup()) { | if ($this->isSetup()) { | ||||
return pht( | return pht( | ||||
"**Step 1 of 2**: Provide the name and URI for your JIRA install.\n\n". | "**Step 1 of 2**: Provide the name and URI for your JIRA ". | ||||
"installation.\n\n". | |||||
"In the next step, you will configure JIRA."); | "In the next step, you will configure JIRA."); | ||||
} else { | } else { | ||||
$login_uri = PhabricatorEnv::getURI($this->getLoginURI()); | $login_uri = PhabricatorEnv::getURI($this->getLoginURI()); | ||||
return pht( | return pht( | ||||
"**Step 2 of 2**: In this step, you will configure JIRA.\n\n". | "**Step 2 of 2**: In this step, you will configure JIRA.\n\n". | ||||
"**Create a JIRA Application**: Log into JIRA and go to ". | "**Create a JIRA Application**: Log into JIRA and go to ". | ||||
"**Administration**, then **Add-ons**, then **Application Links**. ". | "**Administration**, then **Add-ons**, then **Application Links**. ". | ||||
"Click the button labeled **Add Application Link**, and use these ". | "Click the button labeled **Add Application Link**, and use these ". | ||||
"settings to create an application:\n\n". | "settings to create an application:\n\n". | ||||
" - **Server URL**: `%s`\n". | " - **Server URL**: `%s`\n". | ||||
" - Then, click **Next**. On the second page:\n". | " - Then, click **Next**. On the second page:\n". | ||||
" - **Application Name**: `Phabricator`\n". | " - **Application Name**: `\${{{strings.platform.server.name}}}`\n". | ||||
cspeckmim: Oh I bet these need escaped | |||||
" - **Application Type**: `Generic Application`\n". | " - **Application Type**: `Generic Application`\n". | ||||
" - Then, click **Create**.\n\n". | " - Then, click **Create**.\n\n". | ||||
"**Configure Your Application**: Find the application you just ". | "**Configure Your Application**: Find the application you just ". | ||||
"created in the table, and click the **Configure** link under ". | "created in the table, and click the **Configure** link under ". | ||||
"**Actions**. Select **Incoming Authentication** and click the ". | "**Actions**. Select **Incoming Authentication** and click the ". | ||||
"**OAuth** tab (it may be selected by default). Then, use these ". | "**OAuth** tab (it may be selected by default). Then, use these ". | ||||
"settings:\n\n". | "settings:\n\n". | ||||
" - **Consumer Key**: Set this to the \"Consumer Key\" value in the ". | " - **Consumer Key**: Set this to the \"Consumer Key\" value in the ". | ||||
"form above.\n". | "form above.\n". | ||||
" - **Consumer Name**: `Phabricator`\n". | " - **Consumer Name**: `\${{{strings.platform.server.name}}}`\n". | ||||
Done Inline ActionsThese are Remarkup so I think we can do this most gracefully with some {{{platform.name}}} thing. I can send you a diff for that. epriestley: These are Remarkup so I think we can do this most gracefully with some `{{{platform.name}}}`… | |||||
" - **Public Key**: Set this to the \"Public Key\" value in the ". | " - **Public Key**: Set this to the \"Public Key\" value in the ". | ||||
"form above.\n". | "form above.\n". | ||||
" - **Consumer Callback URL**: `%s`\n". | " - **Consumer Callback URL**: `%s`\n". | ||||
"Click **Save** in JIRA. Authentication should now be configured, ". | "Click **Save** in JIRA. Authentication should now be configured, ". | ||||
"and this provider should work correctly.", | "and this provider should work correctly.", | ||||
PhabricatorEnv::getProductionURI('/'), | PhabricatorEnv::getProductionURI('/'), | ||||
$login_uri); | $login_uri); | ||||
} | } | ||||
} | } | ||||
protected function newOAuthAdapter() { | protected function newOAuthAdapter() { | ||||
$config = $this->getProviderConfig(); | $config = $this->getProviderConfig(); | ||||
return id(new PhutilJIRAAuthAdapter()) | return id(new PhutilJIRAAuthAdapter()) | ||||
->setAdapterDomain($config->getProviderDomain()) | ->setAdapterDomain($config->getProviderDomain()) | ||||
->setJIRABaseURI($config->getProperty(self::PROPERTY_JIRA_URI)) | ->setJIRABaseURI($config->getProperty(self::PROPERTY_JIRA_URI)) | ||||
->setPrivateKey( | ->setPrivateKey( | ||||
new PhutilOpaqueEnvelope( | new PhutilOpaqueEnvelope( | ||||
$config->getProperty(self::PROPERTY_PRIVATE_KEY))); | $config->getProperty(self::PROPERTY_PRIVATE_KEY))); | ||||
} | } | ||||
protected function getLoginIcon() { | protected function getLoginIcon() { | ||||
return 'Jira'; | return 'JIRA'; | ||||
} | } | ||||
private function isSetup() { | private function isSetup() { | ||||
return !$this->getProviderConfig()->getID(); | return !$this->getProviderConfig()->getID(); | ||||
} | } | ||||
const PROPERTY_JIRA_NAME = 'oauth1:jira:name'; | const PROPERTY_JIRA_NAME = 'oauth1:jira:name'; | ||||
const PROPERTY_JIRA_URI = 'oauth1:jira:uri'; | const PROPERTY_JIRA_URI = 'oauth1:jira:uri'; | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | public function extendEditForm( | ||||
if (!function_exists('openssl_pkey_new')) { | if (!function_exists('openssl_pkey_new')) { | ||||
// TODO: This could be a bit prettier. | // TODO: This could be a bit prettier. | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
"The PHP 'openssl' extension is not installed. You must install ". | "The PHP 'openssl' extension is not installed. You must install ". | ||||
"this extension in order to add a JIRA authentication provider, ". | "this extension in order to add a JIRA authentication provider, ". | ||||
"because JIRA OAuth requests use the RSA-SHA1 signing algorithm. ". | "because JIRA OAuth requests use the RSA-SHA1 signing algorithm. ". | ||||
"Install the 'openssl' extension, restart Phabricator, and try ". | "Install the 'openssl' extension, restart services for this ". | ||||
"again.")); | "installation, and try again.")); | ||||
} | } | ||||
$form->appendRemarkupInstructions( | $form->appendRemarkupInstructions( | ||||
pht( | pht( | ||||
'NOTE: This provider **only supports JIRA 6**. It will not work with '. | 'NOTE: This provider **only supports JIRA 6**. It will not work with '. | ||||
'JIRA 5 or earlier.')); | 'JIRA 5 or earlier.')); | ||||
$is_setup = $this->isSetup(); | $is_setup = $this->isSetup(); | ||||
Show All 11 Lines | public function extendEditForm( | ||||
$v_uri = $values[self::PROPERTY_JIRA_URI]; | $v_uri = $values[self::PROPERTY_JIRA_URI]; | ||||
$e_uri = idx($issues, self::PROPERTY_JIRA_URI, $e_required); | $e_uri = idx($issues, self::PROPERTY_JIRA_URI, $e_required); | ||||
if ($is_setup) { | if ($is_setup) { | ||||
$form | $form | ||||
->appendRemarkupInstructions( | ->appendRemarkupInstructions( | ||||
pht( | pht( | ||||
"**JIRA Instance Name**\n\n". | "**JIRA Instance Name**\n\n". | ||||
"Choose a permanent name for this instance of JIRA. Phabricator ". | "Choose a permanent name for this instance of JIRA. This name is ". | ||||
"uses this name internally to keep track of this instance of ". | "used internally to keep track of this particular JIRA instance, ". | ||||
"JIRA, in case the URL changes later.\n\n". | "in case the URL changes later.\n\n". | ||||
"Use lowercase letters, digits, and period. For example, ". | "Use lowercase letters, digits, and period. For example, ". | ||||
Done Inline ActionsMaybe just:
epriestley: Maybe just:
> Choose a permanent name for this instance of JIRA. This name is used internally… | |||||
"`jira`, `jira.mycompany` or `jira.engineering` are reasonable ". | "`jira`, `jira.mycompany` or `jira.engineering` are reasonable ". | ||||
"names.")) | "names.")) | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormTextControl()) | id(new AphrontFormTextControl()) | ||||
->setLabel(pht('JIRA Instance Name')) | ->setLabel(pht('JIRA Instance Name')) | ||||
->setValue($v_name) | ->setValue($v_name) | ||||
->setName(self::PROPERTY_JIRA_NAME) | ->setName(self::PROPERTY_JIRA_NAME) | ||||
->setError($e_name)); | ->setError($e_name)); | ||||
▲ Show 20 Lines • Show All 158 Lines • Show Last 20 Lines |
Oh I bet these need escaped