[MediaWiki-commits] [Gerrit] mediawiki...GoogleLogin[master]: Add backend services and functions for allowed domains in th...

2017-06-10 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/358081 )

Change subject: Add backend services and functions for allowed domains in the 
database
..


Add backend services and functions for allowed domains in the database

Instead of requiring the users of this extension to manage the list of allowed
domains, from which the users can login with Google, in an array in the Local-
Settings.php file, this change implements to store this list in the database
in a new database table.

To allow different backends for the list of allowed domains, a new interface,
AllowedDomainsStore, is created, which allows different implementations for
the puprose of checking, if a specific domain is allowed or not (no matter where
the list of allowed domains is stored or comes from). There're three 
implementations,
which are inspired by the SiteStore implementations. One for the currently
used global array, one for a list out of the database and one which uses a 
BagOStuff
cache and another AllowedDomainsStore as a backend.

There's currently no api or user interface to manage the list of allowed 
domains,
therefore it has to be done in the database directly. There will be changes in
the future to allow to manage the list through an api and/or through a user
interface. The list, when the database is used, will be cached for up to 1 hour,
so changes will not take effect immediately at the moment.

Bug: T166423
Change-Id: I629534b97b0eddbc195c87b9a86d015c2e07a694
---
M extension.json
A includes/Constants.php
M includes/GoogleLogin.body.php
M includes/GoogleLogin.hooks.php
A includes/ServiceWiring.php
A includes/alloweddomains/AllowedDomainsStore.php
A includes/alloweddomains/ArrayAllowedDomainsStore.php
A includes/alloweddomains/CachedAllowedDomainsStore.php
A includes/alloweddomains/DBAllowedDomainsStore.php
A includes/alloweddomains/MutableAllowedDomainsStore.php
A includes/sql/googlelogin_allowed_domains.sql
11 files changed, 314 insertions(+), 5 deletions(-)

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



diff --git a/extension.json b/extension.json
index 4a835cd..2843a81 100644
--- a/extension.json
+++ b/extension.json
@@ -49,11 +49,17 @@
"GoogleLogin\\Specials\\SpecialManageGoogleLogin": 
"includes/specials/SpecialManageGoogleLogin.php",
"GoogleLogin\\GoogleLoginHooks": 
"includes/GoogleLogin.hooks.php",
"GoogleLogin\\GoogleUser": "includes/GoogleUser.php",
+   "GoogleLogin\\Constants": "includes/Constants.php",
"GoogleLogin\\Auth\\GooglePrimaryAuthenticationProvider": 
"includes/auth/GooglePrimaryAuthenticationProvider.php",
"GoogleLogin\\Auth\\GoogleServerAuthenticationRequest": 
"includes/auth/GoogleServerAuthenticationRequest.php",
"GoogleLogin\\Auth\\GoogleAuthenticationRequest": 
"includes/auth/GoogleAuthenticationRequest.php",
"GoogleLogin\\Auth\\GoogleRemoveAuthenticationRequest": 
"includes/auth/GoogleRemoveAuthenticationRequest.php",
"GoogleLogin\\Auth\\GoogleUserInfoAuthenticationRequest": 
"includes/auth/GoogleUserInfoAuthenticationRequest.php",
+   "GoogleLogin\\AllowedDomains\\AllowedDomainsStore": 
"includes/alloweddomains/AllowedDomainsStore.php",
+   "GoogleLogin\\AllowedDomains\\MutableAllowedDomainsStore": 
"includes/alloweddomains/MutableAllowedDomainsStore.php",
+   "GoogleLogin\\AllowedDomains\\ArrayAllowedDomainsStore": 
"includes/alloweddomains/ArrayAllowedDomainsStore.php",
+   "GoogleLogin\\AllowedDomains\\DBAllowedDomainsStore": 
"includes/alloweddomains/DBAllowedDomainsStore.php",
+   "GoogleLogin\\AllowedDomains\\CachedAllowedDomainsStore": 
"includes/alloweddomains/CachedAllowedDomainsStore.php",
"GoogleLogin\\AllowedDomains\\EmailDomain": 
"includes/alloweddomains/EmailDomain.php",
"ApiGoogleLoginInfo": "includes/api/ApiGoogleLoginInfo.php"
},
@@ -149,9 +155,13 @@
"GLAppId": "",
"GLAllowedDomains": "",
"GLAllowedDomainsStrict": false,
+   "GLAllowedDomainsDB": false,
"GLAPIKey": "",
"GLEnableEchoEvents": true
},
+   "ServiceWiringFiles": [
+   "includes/ServiceWiring.php"
+   ],
"load_composer_autoloader": true,
"manifest_version": 1
 }
diff --git a/includes/Constants.php b/includes/Constants.php
new file mode 100644
index 000..710b7e8
--- /dev/null
+++ b/includes/Constants.php
@@ -0,0 +1,13 @@
+get( 'GLAllowedDomains' ) ) ) {
+   /** @var AllowedDomainsStore $allowedDomainsStore */
+   $allowedDomainsStore = MediaWikiServices::getInstance()
+   ->getService( Constants::SERVICE_ALLOWED_DOMAINS_STORE 
);
+   if ( 

[MediaWiki-commits] [Gerrit] mediawiki...GoogleLogin[master]: Add backend services and functions for allowed domains in th...

2017-06-09 Thread Florianschmidtwelzow (Code Review)
Florianschmidtwelzow has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/358081 )

Change subject: Add backend services and functions for allowed domains in the 
database
..

Add backend services and functions for allowed domains in the database

Instead of requiring the users of this extension to manage the list of allowed
domains, from which the users can login with Google, in an array in the Local-
Settings.php file, this change implements to store this list in the database
in a new database table.

To allow different backends for the list of allowed domains, a new interface,
AllowedDomainsStore, is created, which allows different implementations for
the puprose of checking, if a specific domain is allowed or not (no matter where
the list of allowed domains is stored or comes from). There're three 
implementations,
which are inspired by the SiteStore implementations. One for the currently
used global array, one for a list out of the database and one which uses a 
BagOStuff
cache and another AllowedDomainsStore as a backend.

There's currently no api or user interface to manage the list of allowed 
domains,
therefore it has to be done in the database directly. There will be changes in
the future to allow to manage the list through an api and/or through a user
interface. The list, when the database is used, will be cached for up to 1 hour,
so changes will not take effect immediately at the moment.

Bug: T166423
Change-Id: I629534b97b0eddbc195c87b9a86d015c2e07a694
---
M extension.json
A includes/Constants.php
M includes/GoogleLogin.body.php
M includes/GoogleLogin.hooks.php
A includes/ServiceWiring.php
A includes/alloweddomains/AllowedDomainsStore.php
A includes/alloweddomains/ArrayAllowedDomainsStore.php
A includes/alloweddomains/CachedAllowedDomainsStore.php
A includes/alloweddomains/DBAllowedDomainsStore.php
A includes/alloweddomains/MutableAllowedDomainsStore.php
A includes/sql/googlelogin_allowed_domains.sql
11 files changed, 314 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GoogleLogin 
refs/changes/81/358081/1

diff --git a/extension.json b/extension.json
index 5a0349e..2843a81 100644
--- a/extension.json
+++ b/extension.json
@@ -49,12 +49,17 @@
"GoogleLogin\\Specials\\SpecialManageGoogleLogin": 
"includes/specials/SpecialManageGoogleLogin.php",
"GoogleLogin\\GoogleLoginHooks": 
"includes/GoogleLogin.hooks.php",
"GoogleLogin\\GoogleUser": "includes/GoogleUser.php",
+   "GoogleLogin\\Constants": "includes/Constants.php",
"GoogleLogin\\Auth\\GooglePrimaryAuthenticationProvider": 
"includes/auth/GooglePrimaryAuthenticationProvider.php",
"GoogleLogin\\Auth\\GoogleServerAuthenticationRequest": 
"includes/auth/GoogleServerAuthenticationRequest.php",
"GoogleLogin\\Auth\\GoogleAuthenticationRequest": 
"includes/auth/GoogleAuthenticationRequest.php",
"GoogleLogin\\Auth\\GoogleRemoveAuthenticationRequest": 
"includes/auth/GoogleRemoveAuthenticationRequest.php",
"GoogleLogin\\Auth\\GoogleUserInfoAuthenticationRequest": 
"includes/auth/GoogleUserInfoAuthenticationRequest.php",
"GoogleLogin\\AllowedDomains\\AllowedDomainsStore": 
"includes/alloweddomains/AllowedDomainsStore.php",
+   "GoogleLogin\\AllowedDomains\\MutableAllowedDomainsStore": 
"includes/alloweddomains/MutableAllowedDomainsStore.php",
+   "GoogleLogin\\AllowedDomains\\ArrayAllowedDomainsStore": 
"includes/alloweddomains/ArrayAllowedDomainsStore.php",
+   "GoogleLogin\\AllowedDomains\\DBAllowedDomainsStore": 
"includes/alloweddomains/DBAllowedDomainsStore.php",
+   "GoogleLogin\\AllowedDomains\\CachedAllowedDomainsStore": 
"includes/alloweddomains/CachedAllowedDomainsStore.php",
"GoogleLogin\\AllowedDomains\\EmailDomain": 
"includes/alloweddomains/EmailDomain.php",
"ApiGoogleLoginInfo": "includes/api/ApiGoogleLoginInfo.php"
},
@@ -150,9 +155,13 @@
"GLAppId": "",
"GLAllowedDomains": "",
"GLAllowedDomainsStrict": false,
+   "GLAllowedDomainsDB": false,
"GLAPIKey": "",
"GLEnableEchoEvents": true
},
+   "ServiceWiringFiles": [
+   "includes/ServiceWiring.php"
+   ],
"load_composer_autoloader": true,
"manifest_version": 1
 }
diff --git a/includes/Constants.php b/includes/Constants.php
new file mode 100644
index 000..e9e58d7
--- /dev/null
+++ b/includes/Constants.php
@@ -0,0 +1,14 @@
+get( 'GLAllowedDomains' ) ) ) {
+   /** @var AllowedDomainsStore $allowedDomainsStore */
+   $allowedDomainsStore = MediaWikiServices::getInstance()
+   ->getService( Constants::SERVICE_ALLOWED_DOMAINS_STORE 
);
+