@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.

Dirty the SSH key cache when usernames change

Summary:
Fixes T12554. The SSH key cache contains usernames, but is not currently dirtied on username changes.

An alternative solution would be to use user PHIDs instead of usernames in the file, which would make this unnecessary, but that would make debugging a bit harder. For now, I think this small added complexity is worth the easier debugging, but we could look at this again if cache management gets harder in the future.

Test Plan:
- Added a key as `ducksey`, ran `bin/ssh-auth`, saw key immediately.
- Renamed `ducksey` to `ducker`, ran `bin/ssh-auth`, saw username change immediately.
- Added another key as `ducker`, ran `bin/ssh-auth`, saw key immediately.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12554

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

+11 -3
+1 -3
src/applications/auth/editor/PhabricatorAuthSSHKeyEditor.php
··· 197 197 198 198 // After making any change to an SSH key, drop the authfile cache so it 199 199 // is regenerated the next time anyone authenticates. 200 - $cache = PhabricatorCaches::getMutableCache(); 201 - $authfile_key = PhabricatorAuthSSHKeyQuery::AUTHFILE_CACHEKEY; 202 - $cache->deleteKey($authfile_key); 200 + PhabricatorAuthSSHKeyQuery::deleteSSHKeyCache(); 203 201 204 202 return $xactions; 205 203 }
+6
src/applications/auth/query/PhabricatorAuthSSHKeyQuery.php
··· 11 11 private $keys; 12 12 private $isActive; 13 13 14 + public static function deleteSSHKeyCache() { 15 + $cache = PhabricatorCaches::getMutableCache(); 16 + $authfile_key = self::AUTHFILE_CACHEKEY; 17 + $cache->deleteKey($authfile_key); 18 + } 19 + 14 20 public function withIDs(array $ids) { 15 21 $this->ids = $ids; 16 22 return $this;
+4
src/applications/people/editor/PhabricatorUserEditor.php
··· 195 195 196 196 $user->saveTransaction(); 197 197 198 + // The SSH key cache currently includes usernames, so dirty it. See T12554 199 + // for discussion. 200 + PhabricatorAuthSSHKeyQuery::deleteSSHKeyCache(); 201 + 198 202 $user->sendUsernameChangeEmail($actor, $old_username); 199 203 } 200 204