Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed migration for older plugins that use base64 secret #324

Merged
merged 2 commits into from
Jun 23, 2017
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
2 changes: 1 addition & 1 deletion WP_Auth0.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
define( 'WPA0_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
define( 'WPA0_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
define( 'WPA0_LANG', 'wp-auth0' );
define( 'AUTH0_DB_VERSION', 13 );
define( 'AUTH0_DB_VERSION', 14 );
define( 'WPA0_VERSION', '3.2.21' );

/**
Expand Down
8 changes: 8 additions & 0 deletions lib/WP_Auth0_DBManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ public function install_db() {
}
}

if ( $this->current_db_version < 14 && is_null($options->get('client_secret_b64_encoded' ))) {
if ( $options->get('client_id' )) {
$options->set('client_secret_b64_encoded', true);
} else {
$options->set('client_secret_b64_encoded', false);
}
}

$this->current_db_version = AUTH0_DB_VERSION;
update_option( 'auth0_db_version', AUTH0_DB_VERSION );
}
Expand Down
2 changes: 1 addition & 1 deletion lib/WP_Auth0_Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function defaults() {
'auto_login_method' => '',
'client_id' => '',
'client_secret' => '',
'client_secret_b64_encoded' => false,
'client_secret_b64_encoded' => null,
'domain' => '',
'form_title' => '',
'icon_url' => '',
Expand Down
3 changes: 1 addition & 2 deletions lib/admin/WP_Auth0_Admin_Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,9 @@ public function basic_validation( $old_options, $input ) {

// Only replace the secret or token if a new value was set. If not, we will keep the last one entered.
$input['client_secret'] = ( !empty( $input['client_secret'] ) ? $input['client_secret'] : $old_options['client_secret'] );
$input['client_secret_b64_encoded'] = ( isset( $input['client_secret_b64_encoded'] ) ? $input['client_secret_b64_encoded'] : 0 );
$input['client_secret_b64_encoded'] = ( isset( $input['client_secret_b64_encoded'] ) ? $input['client_secret_b64_encoded'] == 1 : false );
$input['auth0_app_token'] = ( !empty( $input['auth0_app_token'] ) ? $input['auth0_app_token'] : $old_options['auth0_app_token'] );


$error = '';
$completeBasicData = true;
if ( empty( $input['domain'] ) ) {
Expand Down
2 changes: 1 addition & 1 deletion lib/php-jwt/Authentication/JWT.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static function decode($jwt, $key = null, $allowed_algs = array())

// Check the signature
if (!JWT::verify("$headb64.$bodyb64", $sig, $key, $header->alg)) {
throw new SignatureInvalidException('Signature verification failed, disabling "Settings \ Basic \ Client Secret Base64 Encoded" may resolve this issue.');
throw new SignatureInvalidException('Signature verification failed, check "Client Secret Base64 Encoded" value matches your Auth0 client.');
}

// Check if the nbf if it is defined. This is the time that the
Expand Down