jenkins-bot has submitted this change and it was merged.

Change subject: http: Support HTTP Basic Authentication
......................................................................


http: Support HTTP Basic Authentication

Adds two new options (username and password) to the
MWHttpRequest (and HTTP helper class) to enable
support for HTTP Basic Authentication on outgoing HTTP
connections.

Change-Id: If83f025bbe63769ba7bb4a824c5f12d5f1ec640a
---
M includes/http/Http.php
M includes/http/MWHttpRequest.php
2 files changed, 8 insertions(+), 0 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/http/Http.php b/includes/http/Http.php
index 43ae2d0..133d420 100644
--- a/includes/http/Http.php
+++ b/includes/http/Http.php
@@ -51,6 +51,8 @@
         *    - userAgent           A user agent, if you want to override the 
default
         *                          MediaWiki/$wgVersion
         *    - logger              A \Psr\Logger\LoggerInterface instance for 
debug logging
+        *    - username            Username for HTTP Basic Authentication
+        *    - password            Password for HTTP Basic Authentication
         * @param string $caller The method making this request, for profiling
         * @return string|bool (bool)false on failure or a string on success
         */
diff --git a/includes/http/MWHttpRequest.php b/includes/http/MWHttpRequest.php
index 08883ae..9318605 100644
--- a/includes/http/MWHttpRequest.php
+++ b/includes/http/MWHttpRequest.php
@@ -116,6 +116,12 @@
                if ( isset( $options['userAgent'] ) ) {
                        $this->setUserAgent( $options['userAgent'] );
                }
+               if ( isset( $options['username'] ) && isset( 
$options['password'] ) ) {
+                       $this->setHeader(
+                               'Authorization',
+                               'Basic ' . base64_encode( $options['username'] 
. ':' . $options['password'] )
+                       );
+               }
 
                $members = [ "postData", "proxy", "noProxy", "sslVerifyHost", 
"caInfo",
                                "method", "followRedirects", "maxRedirects", 
"sslVerifyCert", "callback" ];

-- 
To view, visit https://gerrit.wikimedia.org/r/320388
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If83f025bbe63769ba7bb4a824c5f12d5f1ec640a
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Chrisludt <christian.l...@isceco.admin.ch>
Gerrit-Reviewer: Chrisludt <christian.l...@isceco.admin.ch>
Gerrit-Reviewer: Legoktm <lego...@member.fsf.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to