Cicalese has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/384625 )
Change subject: Added optional extra fields for authentication request.
......................................................................
Added optional extra fields for authentication request.
Change-Id: I15ecbc81304294548ae9cf1aed32a3dc44a38f03
---
M extension.json
M includes/PluggableAuthBeginAuthenticationRequest.php
M includes/PluggableAuthLogin.php
M includes/PluggableAuthPrimaryAuthenticationProvider.php
4 files changed, 22 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PluggableAuth
refs/changes/25/384625/1
diff --git a/extension.json b/extension.json
index 20b3714..0705026 100644
--- a/extension.json
+++ b/extension.json
@@ -49,7 +49,8 @@
"config": {
"PluggableAuth_EnableAutoLogin": false,
"PluggableAuth_EnableLocalLogin": false,
- "PluggableAuth_EnableLocalProperties": false
+ "PluggableAuth_EnableLocalProperties": false,
+ "PluggableAuth_ExtraLoginFields": []
},
"manifest_version": 1
}
diff --git a/includes/PluggableAuthBeginAuthenticationRequest.php
b/includes/PluggableAuthBeginAuthenticationRequest.php
index 9bcbe49..fb3f151 100644
--- a/includes/PluggableAuthBeginAuthenticationRequest.php
+++ b/includes/PluggableAuthBeginAuthenticationRequest.php
@@ -1,8 +1,10 @@
<?php
use \MediaWiki\Auth\ButtonAuthenticationRequest;
+use \MediaWiki\Auth\AuthManager;
-class PluggableAuthBeginAuthenticationRequest extends
ButtonAuthenticationRequest {
+class PluggableAuthBeginAuthenticationRequest extends
+ ButtonAuthenticationRequest {
public function __construct() {
parent::__construct(
@@ -12,4 +14,11 @@
true);
}
+ public function getFieldInfo() {
+ if ( $this->action !== AuthManager::ACTION_LOGIN ) {
+ return [];
+ }
+ return array_merge(
$GLOBALS['wgPluggableAuth_ExtraLoginFields'],
+ parent::getFieldInfo() );
+ }
}
diff --git a/includes/PluggableAuthLogin.php b/includes/PluggableAuthLogin.php
index 0eb4cca..113b226 100644
--- a/includes/PluggableAuthLogin.php
+++ b/includes/PluggableAuthLogin.php
@@ -7,6 +7,7 @@
const RETURNTOURL_SESSION_KEY = 'PluggableAuthLoginReturnToUrl';
const RETURNTOPAGE_SESSION_KEY = 'PluggableAuthLoginReturnToPage';
const RETURNTOQUERY_SESSION_KEY = 'PluggableAuthLoginReturnToQuery';
+ const EXTRALOGINFIELDS_SESSION_KEY =
'PluggableAuthLoginExtraLoginFields';
const USERNAME_SESSION_KEY = 'PluggableAuthLoginUsername';
const REALNAME_SESSION_KEY = 'PluggableAuthLoginRealname';
const EMAIL_SESSION_KEY = 'PluggableAuthLoginEmail';
diff --git a/includes/PluggableAuthPrimaryAuthenticationProvider.php
b/includes/PluggableAuthPrimaryAuthenticationProvider.php
index 4b62b5b..3f47ca0 100644
--- a/includes/PluggableAuthPrimaryAuthenticationProvider.php
+++ b/includes/PluggableAuthPrimaryAuthenticationProvider.php
@@ -15,9 +15,17 @@
if ( !$request ) {
return AuthenticationResponse::newAbstain();
}
+ $extraLoginFields = [];
+ foreach ( $GLOBALS['wgPluggableAuth_ExtraLoginFields'] as $key
=> $value ) {
+ if ( isset( $request, $key ) ) {
+ $extraLoginFields[$key] = $request->$key;
+ }
+ }
$url = Title::newFromText( 'Special:PluggableAuthLogin'
)->getFullURL();
$this->manager->setAuthenticationSessionData(
PluggableAuthLogin::RETURNTOURL_SESSION_KEY,
$request->returnToUrl );
+ $this->manager->setAuthenticationSessionData(
+ PluggableAuthLogin::EXTRALOGINFIELDS_SESSION_KEY,
$extraLoginFields );
if ( isset( $_GET['returnto'] ) ) {
$returnto = $_GET['returnto'];
} else {
@@ -124,7 +132,7 @@
switch ( $action ) {
case AuthManager::ACTION_LOGIN:
return [
- new
PluggableAuthBeginAuthenticationRequest()
+ new
PluggableAuthBeginAuthenticationRequest()
];
default:
return [];
--
To view, visit https://gerrit.wikimedia.org/r/384625
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I15ecbc81304294548ae9cf1aed32a3dc44a38f03
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PluggableAuth
Gerrit-Branch: master
Gerrit-Owner: Cicalese <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits