Google Apps Login - Version 2.7

Version Description

Accepts filter gal_client_config_ini containing filesystem path to an INI file to supply to Google's client library on instantiation, so you can override settings. Added substitution version core/Google/IO/DebugVersionOfCurl.php to replace core/Google/IO/Curl.php temporarily to log communications to Google's server for debugging purposes.

Download this release

Release Info

Developer danlester
Plugin Icon 128x128 Google Apps Login
Version 2.7
Comparing to
See all releases

Code changes from version 2.5.2 to 2.7

core/Google/IO/DebugVersionOfCurl.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ /**
19
+ * Curl based implementation of GoogleGAL_IO.
20
+ *
21
+ * @author Stuart Langley <slangley@google.com>
22
+ */
23
+
24
+ require_once 'Google/IO/Abstract.php';
25
+
26
+ class GoogleGAL_IO_Curl extends GoogleGAL_IO_Abstract
27
+ {
28
+ // cURL hex representation of version 7.30.0
29
+ const NO_QUIRK_VERSION = 0x071E00;
30
+
31
+ private $options = array();
32
+ /**
33
+ * Execute an HTTP Request
34
+ *
35
+ * @param GoogleGAL_HttpRequest $request the http request to be executed
36
+ * @return GoogleGAL_HttpRequest http request with the response http code,
37
+ * response headers and response body filled in
38
+ * @throws GoogleGAL_IO_Exception on curl or IO error
39
+ */
40
+ public function executeRequest(GoogleGAL_Http_Request $request)
41
+ {
42
+ $curl = curl_init();
43
+
44
+ if ($request->getPostBody()) {
45
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getPostBody());
46
+ }
47
+
48
+ $requestHeaders = $request->getRequestHeaders();
49
+ if ($requestHeaders && is_array($requestHeaders)) {
50
+ $curlHeaders = array();
51
+ foreach ($requestHeaders as $k => $v) {
52
+ $curlHeaders[] = "$k: $v";
53
+ }
54
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $curlHeaders);
55
+ }
56
+
57
+ curl_setopt($curl, CURLOPT_URL, $request->getUrl());
58
+
59
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request->getRequestMethod());
60
+ curl_setopt($curl, CURLOPT_USERAGENT, $request->getUserAgent());
61
+
62
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
63
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
64
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
65
+ curl_setopt($curl, CURLOPT_HEADER, true);
66
+
67
+ // Log request
68
+ curl_setopt($curl, CURLOPT_VERBOSE, true);
69
+ $verbose = fopen(dirname(__FILE__).'/../../../../../curloutput.log','a+');
70
+ curl_setopt($curl, CURLOPT_STDERR, $verbose);
71
+ // Log request
72
+
73
+ if ($request->canGzip()) {
74
+ curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
75
+ }
76
+
77
+ foreach ($this->options as $key => $var) {
78
+ curl_setopt($curl, $key, $var);
79
+ }
80
+
81
+ if (!isset($this->options[CURLOPT_CAINFO])) {
82
+ curl_setopt($curl, CURLOPT_CAINFO, dirname(__FILE__) . '/cacerts.pem');
83
+ }
84
+
85
+ // Log request
86
+ fwrite($verbose, "--- Request Body --- \n\r");
87
+ fwrite($verbose, $request->getPostBody());
88
+ fwrite($verbose, "\n\r");
89
+ // Log request
90
+
91
+ $response = curl_exec($curl);
92
+ if ($response === false) {
93
+ throw new GoogleGAL_IO_Exception(curl_error($curl));
94
+ }
95
+ $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
96
+
97
+ list($responseHeaders, $responseBody) = $this->parseHttpResponse($response, $headerSize);
98
+
99
+ // Log request
100
+ fwrite($verbose, "--- Response Body --- \n\r");
101
+ fwrite($verbose, $responseBody);
102
+ fwrite($verbose, "\n\r");
103
+ // Log request
104
+
105
+ $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
106
+
107
+ return array($responseBody, $responseHeaders, $responseCode);
108
+ }
109
+
110
+ /**
111
+ * Set options that update the transport implementation's behavior.
112
+ * @param $options
113
+ */
114
+ public function setOptions($options)
115
+ {
116
+ $this->options = $options + $this->options;
117
+ }
118
+
119
+ /**
120
+ * Set the maximum request time in seconds.
121
+ * @param $timeout in seconds
122
+ */
123
+ public function setTimeout($timeout)
124
+ {
125
+ // Since this timeout is really for putting a bound on the time
126
+ // we'll set them both to the same. If you need to specify a longer
127
+ // CURLOPT_TIMEOUT, or a tigher CONNECTTIMEOUT, the best thing to
128
+ // do is use the setOptions method for the values individually.
129
+ $this->options[CURLOPT_CONNECTTIMEOUT] = $timeout;
130
+ $this->options[CURLOPT_TIMEOUT] = $timeout;
131
+ }
132
+
133
+ /**
134
+ * Get the maximum request time in seconds.
135
+ * @return timeout in seconds
136
+ */
137
+ public function getTimeout()
138
+ {
139
+ return $this->options[CURLOPT_TIMEOUT];
140
+ }
141
+
142
+ /**
143
+ * Test for the presence of a cURL header processing bug
144
+ *
145
+ * {@inheritDoc}
146
+ *
147
+ * @return boolean
148
+ */
149
+ protected function needsQuirk()
150
+ {
151
+ $ver = curl_version();
152
+ $versionNum = $ver['version_number'];
153
+ return $versionNum < GoogleGAL_IO_Curl::NO_QUIRK_VERSION;
154
+ }
155
+ }
core/core_google_apps_login.php CHANGED
@@ -915,8 +915,6 @@ class core_google_apps_login {
915
  'ga_force_permissions' => false,
916
  'ga_auto_login' => false,
917
  'ga_poweredby' => false,
918
- //'ga_serviceemail' => '',
919
- //'ga_keyfilepath' => '',
920
  'ga_sakey' => '',
921
  'ga_domainadmin' => '');
922
  }
@@ -1078,7 +1076,7 @@ class core_google_apps_login {
1078
  require_once( 'Google/Client.php' );
1079
  }
1080
 
1081
- $client = new GoogleGAL_Client();
1082
  $client->setApplicationName("Wordpress Site");
1083
  return $client;
1084
  }
@@ -1097,7 +1095,7 @@ class core_google_apps_login {
1097
  // HOOKS AND FILTERS
1098
  // *****************
1099
 
1100
- protected function add_actions() {
1101
  add_action('plugins_loaded', array($this, 'ga_plugins_loaded'));
1102
 
1103
  add_action('login_enqueue_scripts', array($this, 'ga_login_styles'));
@@ -1121,7 +1119,7 @@ class core_google_apps_login {
1121
  add_filter( 'plugin_action_links', array($this, 'ga_plugin_action_links'), 10, 2 );
1122
  }
1123
  }
1124
-
1125
  }
1126
 
1127
  class GAL_Service_Exception extends Exception {
915
  'ga_force_permissions' => false,
916
  'ga_auto_login' => false,
917
  'ga_poweredby' => false,
 
 
918
  'ga_sakey' => '',
919
  'ga_domainadmin' => '');
920
  }
1076
  require_once( 'Google/Client.php' );
1077
  }
1078
 
1079
+ $client = new GoogleGAL_Client(apply_filters('gal_client_config_ini', null));
1080
  $client->setApplicationName("Wordpress Site");
1081
  return $client;
1082
  }
1095
  // HOOKS AND FILTERS
1096
  // *****************
1097
 
1098
+ protected function add_actions() {
1099
  add_action('plugins_loaded', array($this, 'ga_plugins_loaded'));
1100
 
1101
  add_action('login_enqueue_scripts', array($this, 'ga_login_styles'));
1119
  add_filter( 'plugin_action_links', array($this, 'ga_plugin_action_links'), 10, 2 );
1120
  }
1121
  }
1122
+
1123
  }
1124
 
1125
  class GAL_Service_Exception extends Exception {
css/gal-admin.css CHANGED
@@ -143,3 +143,7 @@ a.gal_jsonkeytext {
143
  vertical-align: top;
144
  margin-left: 12px;
145
  }
 
 
 
 
143
  vertical-align: top;
144
  margin-left: 12px;
145
  }
146
+
147
+ #license-section table td {
148
+ padding-right: 8px;
149
+ }
google_apps_login.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Google Apps Login
5
  * Plugin URI: http://wp-glogin.com/
6
  * Description: Simple secure login for Wordpress through users' Google Apps accounts (uses secure OAuth2, and MFA if enabled)
7
- * Version: 2.5.2
8
  * Author: Dan Lester
9
  * Author URI: http://wp-glogin.com/
10
  * License: GPL3
@@ -17,7 +17,7 @@ require_once( plugin_dir_path(__FILE__).'/core/core_google_apps_login.php' );
17
 
18
  class basic_google_apps_login extends core_google_apps_login {
19
 
20
- protected $PLUGIN_VERSION = '2.5.2';
21
 
22
  // Singleton
23
  private static $instance = null;
4
  * Plugin Name: Google Apps Login
5
  * Plugin URI: http://wp-glogin.com/
6
  * Description: Simple secure login for Wordpress through users' Google Apps accounts (uses secure OAuth2, and MFA if enabled)
7
+ * Version: 2.7
8
  * Author: Dan Lester
9
  * Author URI: http://wp-glogin.com/
10
  * License: GPL3
17
 
18
  class basic_google_apps_login extends core_google_apps_login {
19
 
20
+ protected $PLUGIN_VERSION = '2.7';
21
 
22
  // Singleton
23
  private static $instance = null;
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: danlester
3
  Tags: login, google, authentication, oauth2, oauth, admin, google apps, sso, single-sign-on, auth, intranet
4
  Requires at least: 3.5
5
  Tested up to: 4.0
6
- Stable tag: 2.5.2
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -53,6 +53,7 @@ Google Apps Login works on single or multisite WordPress websites or private int
53
 
54
  One-click login will work for the following domains and user accounts:
55
 
 
56
  * Google Apps for Business
57
  * Google Apps for Education
58
  * Google Apps for Non-profits
@@ -222,6 +223,11 @@ please [click here](http://wp-glogin.com/installing-google-apps-login/basic-setu
222
 
223
  == Changelog ==
224
 
 
 
 
 
 
225
  = 2.5.2 =
226
 
227
  Service Account settings can be uploaded by copy-and-paste of JSON file contents as well as just uploading the file directly.
3
  Tags: login, google, authentication, oauth2, oauth, admin, google apps, sso, single-sign-on, auth, intranet
4
  Requires at least: 3.5
5
  Tested up to: 4.0
6
+ Stable tag: 2.7
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
53
 
54
  One-click login will work for the following domains and user accounts:
55
 
56
+ * Google Apps for Work
57
  * Google Apps for Business
58
  * Google Apps for Education
59
  * Google Apps for Non-profits
223
 
224
  == Changelog ==
225
 
226
+ = 2.7 =
227
+
228
+ Accepts filter gal_client_config_ini containing filesystem path to an INI file to supply to Google's client library on instantiation, so you can override settings.
229
+ Added substitution version core/Google/IO/DebugVersionOfCurl.php to replace core/Google/IO/Curl.php temporarily to log communications to Google's server for debugging purposes.
230
+
231
  = 2.5.2 =
232
 
233
  Service Account settings can be uploaded by copy-and-paste of JSON file contents as well as just uploading the file directly.