Skip to content

Commit

Permalink
Fix IAP fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepdeJong committed Jul 27, 2023
1 parent f401616 commit 4933a50
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/plugins/authiapconnect2/validate_jwt.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,18 @@ function validate_jwt($iapJwt, $expectedAudience)
]);

if (!$jwt) {
return print('Failed to validate JWT: Invalid JWT');
throw new Exception('Failed to validate JWT: Invalid JWT');
}

$expectedAudiences = explode(',', $expectedAudience);
if (!in_array($jwt['aud'], $expectedAudiences)) {
throw new Exception('Invalid audience');
}

// Validate token by checking issuer and audience fields.
assert($jwt['iss'] == 'https://cloud.google.com/iap');

$expectedAudiences = explode(',', $expectedAudience);
assert(in_array($jwt['aud'], $expectedAudiences));

return $jwt;
// print('Printing user identity information from ID token payload:');
// printf('sub: %s', $jwt['sub']);
// printf('email: %s', $jwt['email']);
// echo '<pre>';
// print_r($jwt);
// echo '</pre>';
}

0 comments on commit 4933a50

Please sign in to comment.