From eb80a5ede1fbe5273c4d248d87bcd2b13d2153b9 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 17 Jul 2018 16:04:00 -0700 Subject: [PATCH] Make the Conduit auth error for an unrecognized public key a little more useful Summary: Ref T13168. This is just a small quality-of-life fix: we can disclose which public key we're talking about because public keys are public. Test Plan: - Hit public key error (through my own bumbling / not reading or following instructions). Specifically, I haven't associated the key with a device in Almanac. - Before: vague error. - After: more specific error with enough key material that I could grep for it. Reviewers: amckinley Reviewed By: amckinley Subscribers: yelirekim Maniphest Tasks: T13168 Differential Revision: https://secure.phabricator.com/D19516 --- .../conduit/controller/PhabricatorConduitAPIController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/applications/conduit/controller/PhabricatorConduitAPIController.php b/src/applications/conduit/controller/PhabricatorConduitAPIController.php index 12127a1e27..aea3fc0908 100644 --- a/src/applications/conduit/controller/PhabricatorConduitAPIController.php +++ b/src/applications/conduit/controller/PhabricatorConduitAPIController.php @@ -211,9 +211,14 @@ final class PhabricatorConduitAPIController ->withIsActive(true) ->executeOne(); if (!$stored_key) { + $key_summary = id(new PhutilUTF8StringTruncator()) + ->setMaximumBytes(64) + ->truncateString($raw_key); return array( 'ERR-INVALID-AUTH', - pht('No user or device is associated with that public key.'), + pht( + 'No user or device is associated with the public key "%s".', + $key_summary), ); }