Merge pull request #19279 from stanley-cheung/php-interop-fix-backport

Hotfix for PHP jwt_token_creds interop test
pull/19281/head
Jan Tattermusch 6 years ago committed by GitHub
commit 1f303d2cc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      src/php/lib/Grpc/BaseStub.php
  2. 7
      src/php/tests/interop/interop_client.php

@ -199,6 +199,13 @@ class BaseStub
*/
private function _get_jwt_aud_uri($method)
{
// TODO(jtattermusch): This is not the correct implementation
// of extracting JWT "aud" claim. We should rely on
// grpc_metadata_credentials_plugin which
// also provides the correct value of "aud" claim
// in the grpc_auth_metadata_context.service_url field.
// Trying to do the construction of "aud" field ourselves
// is bad.
$last_slash_idx = strrpos($method, '/');
if ($last_slash_idx === false) {
throw new \InvalidArgumentException(
@ -213,6 +220,12 @@ class BaseStub
$hostname = $this->hostname;
}
// Remove the port if it is 443
// See https://github.com/grpc/grpc/blob/07c9f7a36b2a0d34fcffebc85649cf3b8c339b5d/src/core/lib/security/transport/client_auth_filter.cc#L205
if ((strlen($hostname) > 4) && (substr($hostname, -4) === ":443")) {
$hostname = substr($hostname, 0, -4);
}
return 'https://'.$hostname.$service_name;
}

@ -530,12 +530,7 @@ function _makeStub($args)
throw new Exception('Missing argument: --test_case is required');
}
if ($args['server_port'] === '443') {
$server_address = $args['server_host'];
} else {
$server_address = $args['server_host'].':'.$args['server_port'];
}
$server_address = $args['server_host'].':'.$args['server_port'];
$test_case = $args['test_case'];
$host_override = '';

Loading…
Cancel
Save