From 39237c0854fe08a6e41b9c4b1da6d65735b56f8d Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Thu, 1 Aug 2024 16:29:41 +0200 Subject: [PATCH] Set base-uri as User-Agent for OAuth1 and Github authentication Summary: Closes T15848 Test Plan: Unclear. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: RhinosF1, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15848 Differential Revision: https://we.phorge.it/D25758 --- src/applications/auth/adapter/PhutilGitHubAuthAdapter.php | 3 ++- src/applications/auth/adapter/PhutilOAuth1AuthAdapter.php | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/applications/auth/adapter/PhutilGitHubAuthAdapter.php b/src/applications/auth/adapter/PhutilGitHubAuthAdapter.php index 5d85a2ac21..35dfc01ad9 100644 --- a/src/applications/auth/adapter/PhutilGitHubAuthAdapter.php +++ b/src/applications/auth/adapter/PhutilGitHubAuthAdapter.php @@ -55,7 +55,8 @@ final class PhutilGitHubAuthAdapter extends PhutilOAuthAuthAdapter { $future = new HTTPSFuture($uri); // NOTE: GitHub requires a User-Agent string. - $future->addHeader('User-Agent', __CLASS__); + $future->addHeader('User-Agent', + PhabricatorEnv::getEnvConfig('phabricator.base-uri')); // See T13485. Circa early 2020, GitHub has deprecated use of the // "access_token" URI parameter. diff --git a/src/applications/auth/adapter/PhutilOAuth1AuthAdapter.php b/src/applications/auth/adapter/PhutilOAuth1AuthAdapter.php index 389763da7d..d6b77d29b8 100644 --- a/src/applications/auth/adapter/PhutilOAuth1AuthAdapter.php +++ b/src/applications/auth/adapter/PhutilOAuth1AuthAdapter.php @@ -100,6 +100,8 @@ abstract class PhutilOAuth1AuthAdapter extends PhutilAuthAdapter { protected function newOAuth1Future($uri, $data = array()) { $future = id(new PhutilOAuth1Future($uri, $data)) + ->addHeader('User-Agent', + PhabricatorEnv::getEnvConfig('phabricator.base-uri')) ->setMethod('POST') ->setSignatureMethod($this->getSignatureMethod());