-
Notifications
You must be signed in to change notification settings - Fork 96
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
Changing home_url() to site_url(), wp_login_url(), and wp_logout_url() #360
Changes from 3 commits
2f81402
8bd2a9f
6dc8551
31582b5
d4d8781
d59f09f
55ba3c5
4a295f1
9e56503
db037e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,29 +240,25 @@ public static function create_client( $domain, $app_token, $name ) { | |
$headers['Authorization'] = "Bearer $app_token"; | ||
$headers['content-type'] = "application/json"; | ||
|
||
$logout_url = home_url(); | ||
|
||
$response = wp_remote_post( $endpoint , array( | ||
'method' => 'POST', | ||
'headers' => $headers, | ||
'body' => json_encode( array( | ||
'name' => $name, | ||
'callbacks' => array( | ||
home_url( '/index.php?auth0=1' ), | ||
home_url( '/wp-login.php' ) | ||
site_url( 'index.php?auth0=1' ), | ||
wp_login_url() | ||
), | ||
"allowed_origins"=>array( | ||
home_url( '/wp-login.php' ) | ||
wp_login_url() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. formatting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cocojoe - Plugin is formatted both ways throughout ... my IDE can be configured whatever way. Any opinion on what we should stick with? I'm impartial. |
||
), | ||
"jwt_configuration" => array( | ||
"alg" => "RS256" | ||
), | ||
"app_type" => "regular_web", | ||
"cross_origin_auth" => true, | ||
"cross_origin_loc" => home_url('/index.php?auth0fallback=1','https'), | ||
"allowed_logout_urls" => array( | ||
$logout_url | ||
), | ||
"cross_origin_loc" => site_url('index.php?auth0fallback=1','https'), | ||
"allowed_logout_urls" => array( wp_logout_url() ), | ||
) ) | ||
) ); | ||
|
||
|
@@ -282,11 +278,11 @@ public static function create_client( $domain, $app_token, $name ) { | |
|
||
// Workaround: Can't add `web_origin` on create | ||
$payload = array( | ||
"web_origins" => array(home_url()) | ||
"web_origins" => ( home_url() === site_url() ? array( home_url() ) : array( home_url(), site_url() ) ) | ||
); | ||
$updateResponse = WP_Auth0_Api_Client::update_client($domain, $app_token, $response->client_id, false, $payload); | ||
|
||
if ( $updateClient instanceof WP_Error ) { | ||
if ( $updateResponse instanceof WP_Error ) { | ||
WP_Auth0_ErrorManager::insert_auth0_error( 'WP_Auth0_Api_Client::create_client', $updateResponse ); | ||
error_log( $updateResponse->get_error_message() ); | ||
return false; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,10 +48,10 @@ public function update_wordpress_connection( $app_token, $connection_id, $passwo | |
} | ||
|
||
$login_script = str_replace( '{THE_WS_TOKEN}', $migration_token, WP_Auth0_CustomDBLib::$login_script ); | ||
$login_script = str_replace( '{THE_WS_URL}', get_home_url() . '/index.php?a0_action=migration-ws-login', $login_script ); | ||
$login_script = str_replace( '{THE_WS_URL}', site_url( 'index.php?a0_action=migration-ws-login' ), $login_script ); | ||
|
||
$get_user_script = str_replace( '{THE_WS_TOKEN}', $migration_token, WP_Auth0_CustomDBLib::$get_user_script ); | ||
$get_user_script = str_replace( '{THE_WS_URL}', get_home_url() . '/index.php?a0_action=migration-ws-get-user', $get_user_script ); | ||
$get_user_script = str_replace( '{THE_WS_URL}', site_url(), $get_user_script ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cocojoe - Eeks, big miss on my part. Fixing. |
||
|
||
$connection->options->customScripts->login = $login_script; | ||
$connection->options->customScripts->get_user = $get_user_script; | ||
|
@@ -94,10 +94,10 @@ public function create_wordpress_connection( $app_token, $migration_enabled, $pa | |
} | ||
|
||
$login_script = str_replace( '{THE_WS_TOKEN}', $migration_token, WP_Auth0_CustomDBLib::$login_script ); | ||
$login_script = str_replace( '{THE_WS_URL}', get_home_url() . '/index.php?a0_action=migration-ws-login', $login_script ); | ||
$login_script = str_replace( '{THE_WS_URL}', site_url( 'index.php?a0_action=migration-ws-login' ), $login_script ); | ||
|
||
$get_user_script = str_replace( '{THE_WS_TOKEN}', $migration_token, WP_Auth0_CustomDBLib::$get_user_script ); | ||
$get_user_script = str_replace( '{THE_WS_URL}', get_home_url() . '/index.php?a0_action=migration-ws-get-user', $get_user_script ); | ||
$get_user_script = str_replace( '{THE_WS_URL}', site_url( 'index.php?a0_action=migration-ws-get-user' ), $get_user_script ); | ||
|
||
$body['options'] = array( | ||
'enabledDatabaseCustomization' => true, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,14 +91,12 @@ public function logout() { | |
$auto_login = absint( $this->a0_options->get( 'auto_login' ) ); | ||
|
||
if ( $slo && isset( $_REQUEST['SLO'] ) ) { | ||
$redirect_to = $_REQUEST['redirect_to']; | ||
wp_redirect( $redirect_to ); | ||
wp_redirect( $_REQUEST['redirect_to'] ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this wp_redirect method validate the redirect_to in some way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cocojoe - Uses wp_sanitize_redirect() |
||
die(); | ||
} | ||
|
||
if ( $sso ) { | ||
$redirect_to = home_url(); | ||
wp_redirect( 'https://' . $this->a0_options->get( 'domain' ) . '/v2/logout?federated&returnTo=' . urlencode( $redirect_to ) . '&client_id='.$client_id.'&auth0Client=' . base64_encode( json_encode( WP_Auth0_Api_Client::get_info_headers() ) ) ); | ||
wp_redirect( 'https://' . $this->a0_options->get( 'domain' ) . '/v2/logout?federated&returnTo=' . urlencode( home_url() ) . '&client_id='.$client_id.'&auth0Client=' . base64_encode( json_encode( WP_Auth0_Api_Client::get_info_headers() ) ) ); | ||
die(); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,7 +138,7 @@ protected function defaults() { | |
'auto_provisioning' => false, | ||
'default_login_redirection' => home_url(), | ||
|
||
'auth0_server_domain' => 'auth0.auth0.com', | ||
'auth0_server_domain' => 'auth0.auth0.com', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. formatting |
||
'auth0js-cdn' => '//cdn.auth0.com/js/auth0/9.0.0/auth0.min.js', | ||
|
||
//DASHBOARD | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,14 +80,14 @@ | |
return p; | ||
}, {}); | ||
|
||
post('<?php echo home_url( '/index.php?auth0=implicit' ); ?>', { | ||
post('<?php echo site_url( 'index.php?auth0=implicit' ); ?>', { | ||
token:data.id_token, | ||
state:data.state | ||
}, 'POST'); | ||
} | ||
|
||
// lock.on("authenticated", function(authResult) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe time to just remove this commented code? |
||
// post('<?php echo home_url( '/index.php?auth0=implicit' ); ?>', { | ||
// post('<?php echo site_url( 'index.php?auth0=implicit' ); ?>', { | ||
// token:authResult.idToken, | ||
// state:authResult.state | ||
// }, 'POST'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the site_url always includes the trailing slash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cocojoe - It will correct either way: