Skip to content

Commit e87bb47

Browse files
authored
Merge pull request #295 from auth0/dev
Release 3.2.18
2 parents 2b144e5 + 0422e3c commit e87bb47

File tree

6 files changed

+45
-45
lines changed

6 files changed

+45
-45
lines changed

WP_Auth0.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Plugin Name: PLUGIN_NAME
44
* Description: PLUGIN_DESCRIPTION
5-
* Version: 3.2.17
5+
* Version: 3.2.18
66
* Author: Auth0
77
* Author URI: https://auth0.com
88
*/
@@ -11,7 +11,7 @@
1111
define( 'WPA0_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
1212
define( 'WPA0_LANG', 'wp-auth0' );
1313
define( 'AUTH0_DB_VERSION', 13 );
14-
define( 'WPA0_VERSION', '3.2.17' );
14+
define( 'WPA0_VERSION', '3.2.18' );
1515

1616
/**
1717
* Main plugin class

lib/WP_Auth0_Lock10_Options.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function modal_button_name() {
9999
}
100100

101101
public function get_state_obj( $redirect_to = null ) {
102-
102+
103103
if ( isset( $_GET['interim-login'] ) && $_GET['interim-login'] == 1 ) {
104104
$interim_login = true;
105105
} else {
@@ -114,6 +114,8 @@ public function get_state_obj( $redirect_to = null ) {
114114
$stateObj["redirect_to"] = addslashes( $_GET['redirect_to'] );
115115
}
116116

117+
$stateObj["state"] = 'nonce';
118+
117119
return base64_encode( json_encode( $stateObj ) );
118120
}
119121

@@ -198,17 +200,15 @@ public function has_custom_signup_fields() {
198200
}
199201

200202
public function get_sso_options() {
201-
$options = $this->get_lock_options();
202-
203203
$options["scope"] = "openid ";
204204

205205
if ( $this->get_auth0_implicit_workflow() ) {
206-
$options["callbackOnLocationHash"] = true;
207-
$options["callbackURL"] = $this->get_implicit_callback_url();
206+
$options["responseType"] = 'id_token';
207+
$options["redirectUri"] = $this->get_implicit_callback_url();
208208
$options["scope"] .= "name email picture nickname email_verified";
209209
} else {
210-
$options["callbackOnLocationHash"] = false;
211-
$options["callbackURL"] = $this->get_code_callback_url();
210+
$options["responseType"] = 'code';
211+
$options["redirectUri"] = $this->get_code_callback_url();
212212
}
213213

214214
$redirect_to = null;
@@ -221,9 +221,9 @@ public function get_sso_options() {
221221

222222
unset( $options["authParams"] );
223223
$options["state"] = $this->get_state_obj( $redirect_to );
224+
$options["nonce"] = 'nonce';
224225

225226
return $options;
226-
227227
}
228228

229229
public function get_lock_options() {
@@ -241,7 +241,7 @@ public function get_lock_options() {
241241
$extended_settings = $this->build_settings( $extended_settings );
242242

243243
$extraOptions = array(
244-
"auth" => array(
244+
"auth" => array(
245245
"params" => array("state" => $state ),
246246
),
247247
);

lib/WP_Auth0_LoginManager.php

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,17 @@ public function auth0_sso_footer( $previous_html ) {
3939
return;
4040
}
4141

42-
$lock_options = new WP_Auth0_Lock_Options();
42+
$lock_options = new WP_Auth0_Lock10_Options();
4343

4444
$sso = $lock_options->get_sso();
4545

4646
if ( $sso ) {
47-
$cdn = $lock_options->get_cdn_url();
4847
$client_id = $lock_options->get_client_id();
4948
$domain = $lock_options->get_domain();
49+
$cdn = $this->a0_options->get('auth0js-cdn');
5050

51-
wp_enqueue_script( 'wpa0_lock', $cdn, 'jquery' );
52-
53-
if ($this->a0_options->get('use_lock_10')) {
54-
include WPA0_PLUGIN_DIR . 'templates/auth0-sso-handler-lock10.php';
55-
} else {
56-
include WPA0_PLUGIN_DIR . 'templates/auth0-sso-handler.php';
57-
}
58-
51+
wp_enqueue_script( 'wpa0_auth0js', $cdn );
52+
include WPA0_PLUGIN_DIR . 'templates/auth0-sso-handler-lock10.php';
5953
}
6054
}
6155
public function auth0_singlelogout_footer( $previous_html ) {
@@ -79,12 +73,11 @@ public function auth0_singlelogout_footer( $previous_html ) {
7973
return;
8074
}
8175

82-
$cdn = $this->a0_options->get( 'cdn_url' );
76+
$cdn = $this->a0_options->get('auth0js-cdn');
8377
$client_id = $this->a0_options->get( 'client_id' );
8478
$domain = $this->a0_options->get( 'domain' );
8579
$logout_url = wp_logout_url( get_permalink() ) . '&SLO=1';
8680

87-
wp_enqueue_script( 'wpa0_lock', $cdn, 'jquery' );
8881
include WPA0_PLUGIN_DIR . 'templates/auth0-singlelogout-handler.php';
8982
}
9083

@@ -162,7 +155,7 @@ public function init_auth0() {
162155
$this->implicit_login();
163156
} else {
164157
$this->redirect_login();
165-
}
158+
}
166159
} catch (WP_Auth0_LoginFlowValidationException $e) {
167160

168161
$msg = __( 'There was a problem with your log in', WPA0_LANG );
@@ -182,7 +175,7 @@ public function init_auth0() {
182175
} catch (Exception $e) {
183176

184177
}
185-
178+
186179
}
187180

188181
public function redirect_login() {
@@ -257,7 +250,7 @@ public function redirect_login() {
257250
WP_Auth0_ErrorManager::insert_auth0_error( 'init_auth0_userinfo', $response );
258251

259252
error_log( $response->get_error_message() );
260-
253+
261254
throw new WP_Auth0_LoginFlowValidationException( );
262255
}
263256

@@ -389,7 +382,7 @@ private function do_login( $user, $userinfo, $is_new, $id_token, $access_token )
389382
"user_login" => $user->user_login,
390383
"user_password" => null,
391384
"remember" => $remember_users_session
392-
)
385+
)
393386
);
394387

395388
//wp_set_current_user( $user->ID, $user->user_login );
@@ -437,7 +430,7 @@ public function login_user( $userinfo, $id_token, $access_token ) {
437430
if ( isset( $userinfo->email ) && $user->data->user_email !== $userinfo->email ) {
438431

439432
$description = $user->data->description;
440-
433+
441434
if (empty($description)){
442435
if (isset($userinfo->headline)) {
443436
$description = $userinfo->headline;
@@ -453,10 +446,10 @@ public function login_user( $userinfo, $id_token, $access_token ) {
453446
}
454447
}
455448

456-
$user_id = wp_update_user( array(
457-
'ID' => $user->data->ID,
458-
'user_email' => $userinfo->email,
459-
'description' => $description,
449+
$user_id = wp_update_user( array(
450+
'ID' => $user->data->ID,
451+
'user_email' => $userinfo->email,
452+
'description' => $description,
460453
) );
461454
}
462455

lib/WP_Auth0_Options.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ protected function defaults() {
122122
'auto_provisioning' => false,
123123
'default_login_redirection' => home_url(),
124124

125-
'auth0_server_domain' => 'auth0.auth0.com',
125+
'auth0_server_domain' => 'auth0.auth0.com',
126126

127+
'auth0js-cdn' => '//cdn.auth0.com/js/auth0/8.2.0/auth0.min.js',
127128

128129
//DASHBOARD
129130
'chart_idp_type' => 'donut',

templates/auth0-singlelogout-handler.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44

55
var uuids = '<?php echo $user_profile->user_id; ?>';
66
document.addEventListener("DOMContentLoaded", function() {
7-
var lock = new Auth0Lock('<?php echo $client_id; ?>', '<?php echo $domain; ?>');
8-
lock.$auth0.getSSOData(function(err, data) {
9-
if (!err && ( !data.sso || uuids != data.lastUsedUserID) ) {
7+
if (typeof(auth0) === 'undefined') {
8+
return;
9+
}
1010

11-
window.location = '<?php echo html_entity_decode( $logout_url ); ?>';
11+
var webAuth = new auth0.WebAuth({
12+
clientID:'<?php echo $client_id; ?>',
13+
domain:'<?php echo $domain; ?>'
14+
});
1215

16+
webAuth.client.getSSOData(function(err, data) {
17+
if (!err && ( !data.sso || uuids != data.lastUsedUserID)) {
18+
window.location = '<?php echo html_entity_decode( $logout_url ); ?>';
1319
}
1420
});
1521
});
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
<script id="auth0" src="<?php echo $cdn ?>"></script>
21
<script type="text/javascript">
32
document.addEventListener("DOMContentLoaded", function() {
43
if (typeof(ignore_sso) !== 'undefined' && ignore_sso) {
54
return;
65
}
7-
if (typeof(Auth0Lock) === 'undefined') {
8-
return;
6+
if (typeof(auth0) === 'undefined') {
7+
return;
98
}
109

11-
var auth0 = new Auth0({
10+
var webAuth = new auth0.WebAuth({
1211
clientID:'<?php echo $client_id; ?>',
1312
domain:'<?php echo $domain; ?>'
1413
});
15-
auth0.getSSOData(function(err, data) {
16-
if (!err && data.sso) {
17-
auth0.signin(<?php echo json_encode( $lock_options->get_sso_options() ); ?>);
18-
}
14+
15+
webAuth.client.getSSOData(function(err, data) {
16+
if (!err && data.sso) {
17+
webAuth.authorize(<?php echo json_encode( $lock_options->get_sso_options() ); ?>);
18+
}
1919
});
2020
});
2121
</script>

0 commit comments

Comments
 (0)