Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions WP_Auth0.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: PLUGIN_NAME
* Description: PLUGIN_DESCRIPTION
* Version: 3.2.17
* Version: 3.2.18
* Author: Auth0
* Author URI: https://auth0.com
*/
Expand All @@ -11,7 +11,7 @@
define( 'WPA0_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
define( 'WPA0_LANG', 'wp-auth0' );
define( 'AUTH0_DB_VERSION', 13 );
define( 'WPA0_VERSION', '3.2.17' );
define( 'WPA0_VERSION', '3.2.18' );

/**
* Main plugin class
Expand Down
18 changes: 9 additions & 9 deletions lib/WP_Auth0_Lock10_Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function modal_button_name() {
}

public function get_state_obj( $redirect_to = null ) {

if ( isset( $_GET['interim-login'] ) && $_GET['interim-login'] == 1 ) {
$interim_login = true;
} else {
Expand All @@ -114,6 +114,8 @@ public function get_state_obj( $redirect_to = null ) {
$stateObj["redirect_to"] = addslashes( $_GET['redirect_to'] );
}

$stateObj["state"] = 'nonce';

return base64_encode( json_encode( $stateObj ) );
}

Expand Down Expand Up @@ -198,17 +200,15 @@ public function has_custom_signup_fields() {
}

public function get_sso_options() {
$options = $this->get_lock_options();

$options["scope"] = "openid ";

if ( $this->get_auth0_implicit_workflow() ) {
$options["callbackOnLocationHash"] = true;
$options["callbackURL"] = $this->get_implicit_callback_url();
$options["responseType"] = 'id_token';
$options["redirectUri"] = $this->get_implicit_callback_url();
$options["scope"] .= "name email picture nickname email_verified";
} else {
$options["callbackOnLocationHash"] = false;
$options["callbackURL"] = $this->get_code_callback_url();
$options["responseType"] = 'code';
$options["redirectUri"] = $this->get_code_callback_url();
}

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

unset( $options["authParams"] );
$options["state"] = $this->get_state_obj( $redirect_to );
$options["nonce"] = 'nonce';

return $options;

}

public function get_lock_options() {
Expand All @@ -241,7 +241,7 @@ public function get_lock_options() {
$extended_settings = $this->build_settings( $extended_settings );

$extraOptions = array(
"auth" => array(
"auth" => array(
"params" => array("state" => $state ),
),
);
Expand Down
35 changes: 14 additions & 21 deletions lib/WP_Auth0_LoginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,17 @@ public function auth0_sso_footer( $previous_html ) {
return;
}

$lock_options = new WP_Auth0_Lock_Options();
$lock_options = new WP_Auth0_Lock10_Options();

$sso = $lock_options->get_sso();

if ( $sso ) {
$cdn = $lock_options->get_cdn_url();
$client_id = $lock_options->get_client_id();
$domain = $lock_options->get_domain();
$cdn = $this->a0_options->get('auth0js-cdn');

wp_enqueue_script( 'wpa0_lock', $cdn, 'jquery' );

if ($this->a0_options->get('use_lock_10')) {
include WPA0_PLUGIN_DIR . 'templates/auth0-sso-handler-lock10.php';
} else {
include WPA0_PLUGIN_DIR . 'templates/auth0-sso-handler.php';
}

wp_enqueue_script( 'wpa0_auth0js', $cdn );
include WPA0_PLUGIN_DIR . 'templates/auth0-sso-handler-lock10.php';
}
}
public function auth0_singlelogout_footer( $previous_html ) {
Expand All @@ -79,12 +73,11 @@ public function auth0_singlelogout_footer( $previous_html ) {
return;
}

$cdn = $this->a0_options->get( 'cdn_url' );
$cdn = $this->a0_options->get('auth0js-cdn');
$client_id = $this->a0_options->get( 'client_id' );
$domain = $this->a0_options->get( 'domain' );
$logout_url = wp_logout_url( get_permalink() ) . '&SLO=1';

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

Expand Down Expand Up @@ -162,7 +155,7 @@ public function init_auth0() {
$this->implicit_login();
} else {
$this->redirect_login();
}
}
} catch (WP_Auth0_LoginFlowValidationException $e) {

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

}

}

public function redirect_login() {
Expand Down Expand Up @@ -257,7 +250,7 @@ public function redirect_login() {
WP_Auth0_ErrorManager::insert_auth0_error( 'init_auth0_userinfo', $response );

error_log( $response->get_error_message() );

throw new WP_Auth0_LoginFlowValidationException( );
}

Expand Down Expand Up @@ -389,7 +382,7 @@ private function do_login( $user, $userinfo, $is_new, $id_token, $access_token )
"user_login" => $user->user_login,
"user_password" => null,
"remember" => $remember_users_session
)
)
);

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

$description = $user->data->description;

if (empty($description)){
if (isset($userinfo->headline)) {
$description = $userinfo->headline;
Expand All @@ -453,10 +446,10 @@ public function login_user( $userinfo, $id_token, $access_token ) {
}
}

$user_id = wp_update_user( array(
'ID' => $user->data->ID,
'user_email' => $userinfo->email,
'description' => $description,
$user_id = wp_update_user( array(
'ID' => $user->data->ID,
'user_email' => $userinfo->email,
'description' => $description,
) );
}

Expand Down
3 changes: 2 additions & 1 deletion lib/WP_Auth0_Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ protected function defaults() {
'auto_provisioning' => false,
'default_login_redirection' => home_url(),

'auth0_server_domain' => 'auth0.auth0.com',
'auth0_server_domain' => 'auth0.auth0.com',

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

//DASHBOARD
'chart_idp_type' => 'donut',
Expand Down
14 changes: 10 additions & 4 deletions templates/auth0-singlelogout-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@

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

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

webAuth.client.getSSOData(function(err, data) {
if (!err && ( !data.sso || uuids != data.lastUsedUserID)) {
window.location = '<?php echo html_entity_decode( $logout_url ); ?>';
}
});
});
Expand Down
16 changes: 8 additions & 8 deletions templates/auth0-sso-handler-lock10.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<script id="auth0" src="<?php echo $cdn ?>"></script>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
if (typeof(ignore_sso) !== 'undefined' && ignore_sso) {
return;
}
if (typeof(Auth0Lock) === 'undefined') {
return;
if (typeof(auth0) === 'undefined') {
return;
}

var auth0 = new Auth0({
var webAuth = new auth0.WebAuth({
clientID:'<?php echo $client_id; ?>',
domain:'<?php echo $domain; ?>'
});
auth0.getSSOData(function(err, data) {
if (!err && data.sso) {
auth0.signin(<?php echo json_encode( $lock_options->get_sso_options() ); ?>);
}

webAuth.client.getSSOData(function(err, data) {
if (!err && data.sso) {
webAuth.authorize(<?php echo json_encode( $lock_options->get_sso_options() ); ?>);
}
});
});
</script>