This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Custom Redirect Trigger | |
* | |
* This plugin allows all redirects to be processed. It can be dangerous if used incorrectly. This includes | |
* not adding a whitelist domain redirect. Having this wide open will all hackish redirects. | |
*/ | |
class Custom_Redirect_Rewrites { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>Introspection Test</p> | |
<form action="your-site.com/oauth/introspection/" method="POST"> | |
<input type="text" name="access_token" value=""/> | |
<button type="submit">Run Introspection Test</button> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wp_oauth_server_debug_backtrace() { | |
$friendly = array(); | |
$backtrace = debug_backtrace(); | |
foreach ( $backtrace as $file ) { | |
$friendly[] = array( | |
'file' => $file['file'], | |
'function' => $file['function'], | |
'line' => $file['line'] | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do_action( 'wo_set_access_token', array( | |
'access_token' => $access_token, | |
'client_id' => $client_id, | |
'user_id' => $user_id | |
) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'wo_authorization_code_authorize', 'before_authorization_test' ); | |
function before_authorization_test( $user_id ) { | |
$user_id = $user_id[0]; | |
$authorized = true; | |
// Do user check and authorize if allowed | |
// Present error is the user is not authorized |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This can be used in conjuction https://gist.github.com/justingreerbbi/768f1effcca69b4098c9d0f7731deba0 | |
* This code would go on the WP side. | |
*/ | |
add_action('clear_auth_cookie', 'wp_oaut_server_logout_user_rediect_to_client_rest_api_endpoint'); | |
function wp_oaut_server_logout_user_rediect_to_client_rest_api_endpoint(){ | |
wp_redirect('https://site.com/wp-json/wpoauthserver/v1/logout/'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'template_redirect', 'auto_sso_init', 11 ); | |
function auto_sso_init() { | |
if ( ! is_user_logged_in() ) { | |
wp_safe_redirect( site_url( '?auth=sso' ) ); | |
exit; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _proper_custom_login_redirect_intercept( $template ) { | |
if ( ! is_user_logged_in() ) { | |
wp_safe_redirect( site_url( '/member-login/' ) ); | |
exit; | |
} | |
return $template; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Plugin: Simple Single Sign On | |
Plugin File: /includes/callback.php | |
/* | |
* Action runs directly after a default user is created | |
*/ | |
do_action( 'wpoc_user_created', $user_info, 1 ); | |
/* | |
* Action runs directly before a user is logged in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* CUSTOM LOGIN REDIRECT | |
* | |
* Redirect a user to a custom login page for authentication | |
*/ | |
add_action( 'wo_before_authorize_method', 'custom_login_redirect' ); | |
function custom_login_redirect() { | |
if ( ! is_user_logged_in() ) { | |
wp_redirect( site_url() . '/custom-login?redirect_to=' . urlencode( site_url() . $_SERVER['REQUEST_URI'] ) ); | |
exit; |