@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Read both older "key" and newer "accountId" identifiers from JIRA during authentication

Summary:
Depends on D21022. Ref T13493. The JIRA API has changed from using "key" to identify users to using "accountId".

By reading both identifiers, this linkage "just works" if you run against an old version of JIRA, a new version of JIRA, or an intermediate version of JIRA.

It also "just works" if you run old JIRA, upgrade to intermediate JIRA, everyone refreshes their link at least once, then you upgrade to new JIRA.

This is a subset of cases and does not include "sudden upgrade to new JIRA", but it's strictly better than the old behavior for all cases it covers.

Test Plan: Linked, unlinked, and logged in with JIRA. Looked at the "ExternalAccountIdentifier" table and saw a sensible value.

Maniphest Tasks: T13493

Differential Revision: https://secure.phabricator.com/D21023

+23 -2
+23 -2
src/applications/auth/adapter/PhutilJIRAAuthAdapter.php
··· 22 22 return $this->jiraBaseURI; 23 23 } 24 24 25 - public function getAccountID() { 25 + protected function newAccountIdentifiers() { 26 26 // Make sure the handshake is finished; this method is used for its 27 27 // side effect by Auth providers. 28 28 $this->getHandshakeData(); 29 29 30 - return idx($this->getUserInfo(), 'key'); 30 + $info = $this->getUserInfo(); 31 + 32 + // See T13493. Older versions of JIRA provide a "key" with a username or 33 + // email address. Newer versions of JIRA provide a GUID "accountId". 34 + // Intermediate versions of JIRA provide both. 35 + 36 + $identifiers = array(); 37 + 38 + $account_key = idx($info, 'key'); 39 + if ($account_key !== null) { 40 + $identifiers[] = $this->newAccountIdentifier($account_key); 41 + } 42 + 43 + $account_id = idx($info, 'accountId'); 44 + if ($account_id !== null) { 45 + $identifiers[] = $this->newAccountIdentifier( 46 + sprintf( 47 + 'accountId(%s)', 48 + $account_id)); 49 + } 50 + 51 + return $identifiers; 31 52 } 32 53 33 54 public function getAccountName() {