From f1e1029bde5790adaa5c5cac8f478a04926b5e45 Mon Sep 17 00:00:00 2001 From: Jonathan Daggerhart Date: Fri, 2 Apr 2021 07:56:24 -0400 Subject: [PATCH] Provide new filter for alternate_redirect_uri --- includes/openid-connect-generic-client-wrapper.php | 3 ++- includes/openid-connect-generic-settings-page.php | 3 ++- openid-connect-generic.php | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/openid-connect-generic-client-wrapper.php b/includes/openid-connect-generic-client-wrapper.php index 737c575e..07b58193 100644 --- a/includes/openid-connect-generic-client-wrapper.php +++ b/includes/openid-connect-generic-client-wrapper.php @@ -107,8 +107,9 @@ static public function register( OpenID_Connect_Generic_Client $client, OpenID_C } if ( $settings->alternate_redirect_uri ) { + $redirect_uri = apply_filters( 'openid-connect-generic-alter-alternate-redirect-uri', 'openid-connect-authorize' ); // Provide an alternate route for authentication_request_callback. - add_rewrite_rule( '^openid-connect-authorize/?', 'index.php?openid-connect-authorize=1', 'top' ); + add_rewrite_rule( '^' . $redirect_uri . '/?', 'index.php?openid-connect-authorize=1', 'top' ); add_rewrite_tag( '%openid-connect-authorize%', '1' ); add_action( 'parse_request', array( $client_wrapper, 'alternate_redirect_uri_parse_request' ) ); } diff --git a/includes/openid-connect-generic-settings-page.php b/includes/openid-connect-generic-settings-page.php index 197052e2..e2622a66 100644 --- a/includes/openid-connect-generic-settings-page.php +++ b/includes/openid-connect-generic-settings-page.php @@ -416,7 +416,8 @@ public function settings_page() { $redirect_uri = admin_url( 'admin-ajax.php?action=openid-connect-authorize' ); if ( $this->settings->alternate_redirect_uri ) { - $redirect_uri = site_url( '/openid-connect-authorize' ); + $redirect_uri = apply_filters( 'openid-connect-generic-alter-alternate-redirect-uri', 'openid-connect-authorize' ); + $redirect_uri = site_url( '/' . $redirect_uri ); } ?>
diff --git a/openid-connect-generic.php b/openid-connect-generic.php index a6ea4fc7..d7486799 100644 --- a/openid-connect-generic.php +++ b/openid-connect-generic.php @@ -42,6 +42,7 @@ - openid-connect-generic-alter-user-data - modify user data before a new user is created - openid-connect-modify-token-response-before-validation - modify the token response before validation - openid-connect-modify-id-token-claim-before-validation - modify the token claim before validation + - openid-connect-generic-alter-alternate-redirect-uri - modify the alternate redirect uri. Do not add starting or ending slash. Actions - openid-connect-generic-user-create - 2 args: fires when a new user is created by this plugin @@ -133,7 +134,8 @@ function init() { $redirect_uri = admin_url( 'admin-ajax.php?action=openid-connect-authorize' ); if ( $this->settings->alternate_redirect_uri ) { - $redirect_uri = site_url( '/openid-connect-authorize' ); + $redirect_uri = apply_filters( 'openid-connect-generic-alter-alternate-redirect-uri', 'openid-connect-authorize' ); + $redirect_uri = site_url( '/' . $redirect_uri ); } $state_time_limit = 180;