Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/86809
Change subject: Cleaned up https redirect code to be more consistent
......................................................................
Cleaned up https redirect code to be more consistent
* $wgMWOAuthSecureTokenTransfer is checked for as needed
* Also made $wgMWOAuthSecureTokenTransfer on by default
bug: 54806
Change-Id: I211909953b0215a418358a8c72bac7977b118817
---
M OAuth.config.php
M frontend/specialpages/SpecialMWOAuth.php
M frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
3 files changed, 13 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OAuth
refs/changes/09/86809/1
diff --git a/OAuth.config.php b/OAuth.config.php
index aac976d..b9e301f 100644
--- a/OAuth.config.php
+++ b/OAuth.config.php
@@ -174,7 +174,7 @@
$wgGroupPermissions['user']['mwoauthmanagemygrants'] = true;
/** @var bool Require HTTPs for user transactions that might send out secret
tokens */
-$wgMWOAuthSecureTokenTransfer = false;
+$wgMWOAuthSecureTokenTransfer = true; // RfC compliance
/** @var array List of API module classes to disable when OAuth is used for
the request. */
$wgMWOauthDisabledApiModules = array(
diff --git a/frontend/specialpages/SpecialMWOAuth.php
b/frontend/specialpages/SpecialMWOAuth.php
index e286f35..becc163 100644
--- a/frontend/specialpages/SpecialMWOAuth.php
+++ b/frontend/specialpages/SpecialMWOAuth.php
@@ -27,6 +27,8 @@
}
public function execute( $subpage ) {
+ global $wgMWOAuthSecureTokenTransfer;
+
$this->setHeaders();
$user = $this->getUser();
@@ -85,7 +87,8 @@
// We want to use HTTPS when returning
the credentials. But
// for RSA we don't need to return a
token secret, so HTTP is ok.
- if ( !$isRsa &&
$request->detectProtocol() == 'http'
+ if ( $wgMWOAuthSecureTokenTransfer &&
!$isRsa
+ && $request->detectProtocol()
== 'http'
&& substr( wfExpandUrl( '/',
PROTO_HTTPS ), 0, 8 ) === 'https://'
) {
$redirUrl = str_replace(
'http://', 'https://', $request->getFullRequestURL() );
diff --git a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
index 12adfad..68b71cb 100644
--- a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
+++ b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
@@ -37,19 +37,20 @@
public function execute( $par ) {
global $wgMWOAuthSecureTokenTransfer;
+ $request = $this->getRequest();
$user = $this->getUser();
$lang = $this->getLanguage();
$centralUserId = MWOAuthUtils::getCentralIdFromLocalUser( $user
);
// Redirect to HTTPs if attempting to access this page via HTTP.
// Proposals and updates to consumers can involve sending new
secrets.
- if ( $wgMWOAuthSecureTokenTransfer &&
WebRequest::detectProtocol() !== 'https' ) {
- $url = $this->getFullTitle()->getFullURL( array(),
false, PROTO_HTTPS );
- if ( substr( $url, 0, 8 ) === 'https://' ) {
- $this->getOutput()->redirect( $url );
- return;
- }
- throw new MWException( 'Cannot redirect to HTTPs;
$wgServer is not protocol relative' );
+ if ( $wgMWOAuthSecureTokenTransfer
+ && $request->detectProtocol() == 'http'
+ && substr( wfExpandUrl( '/', PROTO_HTTPS ), 0, 8 ) ===
'https://'
+ ) {
+ $redirUrl = str_replace( 'http://', 'https://',
$request->getFullRequestURL() );
+ $this->getOutput()->redirect( $redirUrl );
+ return;
}
$this->setHeaders();
--
To view, visit https://gerrit.wikimedia.org/r/86809
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I211909953b0215a418358a8c72bac7977b118817
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OAuth
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits