Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix for PHP jwt_token_creds interop test #19230

Merged
merged 2 commits into from
Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/php/lib/Grpc/BaseStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ private function _checkConnectivityState($new_state)
*/
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(
Expand All @@ -213,6 +220,12 @@ private function _get_jwt_aud_uri($method)
$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;
}

Expand Down
7 changes: 1 addition & 6 deletions src/php/tests/interop/interop_client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down