I am trying to use AWS Cognito hosted UI with WordPress. i am successful to load sign-in page and after login it redirects to given redirect_url along with id_token like
http://example.com/#id_token=eyJraWQiOiJvYzVvK3pwRTFrRHJFYmE0
...
i am unable to get #id_token in my php code where i need to verify & load my local user for wordpress-php site.
any help is much appreciated
below is my plugin code
<?php
global $login_page;
$login_page = 'https://example.auth.eu-central-1.amazoncognito.com/login?response_type=token&client_id=xxxxxxxx';
$login_page .= '&redirect_uri=http://localhost/example.com';
add_action('init','goto_login_page');
add_filter( 'auth_cookie_malformed', 'check_authentication_token' );
function goto_login_page() {
global $login_page;
$page = basename($_SERVER['REQUEST_URI']);
if (isset($_GET['#id_token'])) {
$jwt = $_GET['#id_token'];
$publicKey = '';
$decoded = JWT::decode($jwt, $publicKey, array('RS256'));
}
else if( $page == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET') {
wp_redirect($login_page);
exit;
}
}
function check_authentication_token() {
global $login_page;
if (isset($_GET['#id_token'])) {
$jwt = $_GET['#id_token'];
$publicKey = '';
$decoded = JWT::decode($jwt, $publicKey, array('RS256'));
die;
}
else {
var_dump("");
}
}
i am trying to use some filters to override WordPress login stuff with AWS Cognito hosted UI