PHP code example of kalibora / google-cloud-iap-jwt-validator
1. Go to this page and download the library: Download kalibora/google-cloud-iap-jwt-validator library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kalibora / google-cloud-iap-jwt-validator example snippets
alibora\GoogleCloud\IdentityAwareProxy\TokenValidator\{TokenValidator, InvalidTokenException};
use Http\Client\Curl\Client;
use Http\Message\MessageFactory\GuzzleMessageFactory;
$audience = '/projects/{YOUR_PROJECT_NUMBER}/apps/{YOUR_PROJECT_ID};
$tokenValidator = new TokenValidator(new Client(), new GuzzleMessageFactory(), $audience);
$jwt = 'FOO.BAR.BAZ'; // HTTP request header `x-goog-iap-jwt-assertion`
try {
$claims = $tokenValidator->validate($jwt);
} catch (InvalidTokenException $e) {
// Invalid or expired token
die($e->getMessage() . PHP_EOL);
}
echo $claims['sub'], PHP_EOL;
echo $claims['email'], PHP_EOL;
$ composer