Drobbins has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/141364

Change subject: Add support for login domains, to make this work with LDAP 
Extension. Use egPushLoginDomains.
......................................................................

Add support for login domains, to make this work with LDAP Extension. Use 
egPushLoginDomains.

Change-Id: I64befa112df9a9b3b97bf7dc16522a62b9e44a4c
---
M Push_Settings.php
M api/ApiPush.php
M api/ApiPushImages.php
3 files changed, 31 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Push 
refs/changes/64/141364/1

diff --git a/Push_Settings.php b/Push_Settings.php
index ca510fc..236d3fe 100644
--- a/Push_Settings.php
+++ b/Push_Settings.php
@@ -60,6 +60,7 @@
 # no login interface. If there is, they will be filled in as default.
 $egPushLoginUser = '';
 $egPushLoginPass = '';
+$egPushLoginDomain = '';
 
 # Default login data per target. Overrides $egPushLoginUser and 
$egPushLoginPass when specified.
 # Array keys should be the urls assigned in the $egPushTargets array.
@@ -67,6 +68,7 @@
 # no login interface. If there is, they will be filled in as default.
 $egPushLoginUsers = array();
 $egPushLoginPasswords = array();
+$egPushLoginDomains = array();
 
 # The amount of push 'workers' (simultanious push requests) on Special:Push.
 $egPushBulkWorkers = 3;
diff --git a/api/ApiPush.php b/api/ApiPush.php
index 58d7ebf..1e76cb6 100644
--- a/api/ApiPush.php
+++ b/api/ApiPush.php
@@ -35,7 +35,7 @@
                        $this->dieUsageMsg( array( 'badaccess-groups' ) );
                }
 
-               global $egPushLoginUser, $egPushLoginPass, $egPushLoginUsers, 
$egPushLoginPasswords;
+               global $egPushLoginUser, $egPushLoginPass, $egPushLoginUsers, 
$egPushLoginPasswords, $egPushLoginDomain, $egPushLoginDomains;
 
                $params = $this->extractRequestParams();
 
@@ -49,10 +49,12 @@
 
                PushFunctions::flipKeys( $egPushLoginUsers, 'users' );
                PushFunctions::flipKeys( $egPushLoginPasswords, 'passwds' );
+               PushFunctions::flipKeys( $egPushLoginDomains, 'domains' );
 
                foreach ( $params['targets'] as &$target ) {
                        $user = false;
                        $pass = false;
+                       $domain = false;
 
                        if ( array_key_exists( $target, $egPushLoginUsers ) && 
array_key_exists( $target, $egPushLoginPasswords ) ) {
                                $user = $egPushLoginUsers[$target];
@@ -62,6 +64,12 @@
                                $user = $egPushLoginUser;
                                $pass = $egPushLoginPass;
                        }
+                       if ( array_key_exists( $target, $egPushLoginDomains ) ) 
{
+                               $domain = $egPushLoginDomains[$target];
+                       }
+                       elseif ( $egPushLoginDomain != '' ) {
+                               $domain = $egPushLoginDomain;
+                       }
 
                        if ( substr( $target, -1 ) !== '/' ) {
                                $target .= '/';
@@ -70,7 +78,7 @@
                        $target .= 'api.php';
 
                        if ( $user !== false ) {
-                               $this->doLogin( $user, $pass, $target );
+                               $this->doLogin( $user, $pass, $domain, $target 
);
                        }
                }
 
@@ -105,13 +113,16 @@
         * @param CookieJar $cookie
         * @param integer $attemtNr
         */
-       protected function doLogin( $user, $password, $target, $token = null, 
$cookieJar = null, $attemtNr = 0 ) {
+       protected function doLogin( $user, $password, $domain, $target, $token 
= null, $cookieJar = null, $attemtNr = 0 ) {
                $requestData = array(
                        'action' => 'login',
                        'format' => 'json',
                        'lgname' => $user,
                        'lgpassword' => $password
                );
+               if ( $domain != false )
+                       $requestData['lgdomain'] = $domain;
+
 
                if ( !is_null( $token ) ) {
                        $requestData['lgtoken'] = $token;
@@ -140,7 +151,7 @@
                                && property_exists( $response->login, 'result' 
) ) {
 
                                if ( $response->login->result == 'NeedToken' && 
$attemtNr < 3 ) {
-                                       $this->doLogin( $user, $password, 
$target, $response->login->token, $req->getCookieJar(), $attemtNr );
+                                       $this->doLogin( $user, $password, 
$domain, $target, $response->login->token, $req->getCookieJar(), $attemtNr );
                                }
                                elseif ( $response->login->result == 'Success' 
) {
                                        $this->cookieJars[$target] = 
$req->getCookieJar();
diff --git a/api/ApiPushImages.php b/api/ApiPushImages.php
index efedcd3..1adfc28 100644
--- a/api/ApiPushImages.php
+++ b/api/ApiPushImages.php
@@ -33,7 +33,7 @@
                        $this->dieUsageMsg( array( 'badaccess-groups' ) );
                }
 
-               global $egPushLoginUser, $egPushLoginPass, $egPushLoginUsers, 
$egPushLoginPasswords;
+               global $egPushLoginUser, $egPushLoginPass, $egPushLoginUsers, 
$egPushLoginPasswords, $egPushLoginDomain, $egPushLoginDomains;
 
                $params = $this->extractRequestParams();
 
@@ -47,10 +47,12 @@
 
                PushFunctions::flipKeys( $egPushLoginUsers, 'users' );
                PushFunctions::flipKeys( $egPushLoginPasswords, 'passwds' );
+               PushFunctions::flipKeys( $egPushLoginDomains, 'domains' );
 
                foreach ( $params['targets'] as &$target ) {
                        $user = false;
                        $pass = false;
+                       $domain = false;
 
                        if ( array_key_exists( $target, $egPushLoginUsers ) && 
array_key_exists( $target, $egPushLoginPasswords ) ) {
                                $user = $egPushLoginUsers[$target];
@@ -60,6 +62,12 @@
                                $user = $egPushLoginUser;
                                $pass = $egPushLoginPass;
                        }
+                       if ( array_key_exists( $target, $egPushLoginDomains ) ) 
{
+                               $domain = $egPushLoginDomains[$target];
+                       }
+                       elseif ( $egPushLoginDomain != '' ) {
+                               $domain = $egPushLoginDomain;
+                       }
 
                        if ( substr( $target, -1 ) !== '/' ) {
                                $target .= '/';
@@ -68,7 +76,7 @@
                        $target .= 'api.php';
 
                        if ( $user !== false ) {
-                               $this->doLogin( $user, $pass, $target );
+                               $this->doLogin( $user, $pass, $domain, $target 
);
                        }
                }
 
@@ -92,13 +100,15 @@
         * @param CookieJar $cookie
         * @param integer $attemtNr
         */
-       protected function doLogin( $user, $password, $target, $token = null, 
$cookieJar = null, $attemtNr = 0 ) {
+       protected function doLogin( $user, $password, $domain, $target, $token 
= null, $cookieJar = null, $attemtNr = 0 ) {
                $requestData = array(
                        'action' => 'login',
                        'format' => 'json',
                        'lgname' => $user,
                        'lgpassword' => $password
                );
+               if ( $domain != false )
+                       $requestData['lgdomain'] = $domain;
 
                if ( !is_null( $token ) ) {
                        $requestData['lgtoken'] = $token;
@@ -127,7 +137,7 @@
                                && property_exists( $response->login, 'result' 
) ) {
 
                                if ( $response->login->result == 'NeedToken' && 
$attemtNr < 3 ) {
-                                       $this->doLogin( $user, $password, 
$target, $response->login->token, $req->getCookieJar(), $attemtNr );
+                                       $this->doLogin( $user, $password, 
$domain, $target, $response->login->token, $req->getCookieJar(), $attemtNr );
                                }
                                elseif ( $response->login->result == 'Success' 
) {
                                        $this->cookieJars[$target] = 
$req->getCookieJar();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I64befa112df9a9b3b97bf7dc16522a62b9e44a4c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Push
Gerrit-Branch: master
Gerrit-Owner: Drobbins <drobb...@funtoo.org>

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

Reply via email to