Skip to content

Commit

Permalink
Merge pull request grpc#7959 from stanley-cheung/php-minor-fix-interop
Browse files Browse the repository at this point in the history
PHP: use ssl hostname override as auth audience uri if present
  • Loading branch information
stanley-cheung authored Sep 6, 2016
2 parents 6ce5228 + cde12a5 commit 6b69169
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/php/lib/Grpc/BaseStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
class BaseStub
{
private $hostname;
private $hostname_override;
private $channel;

// a callback function
Expand Down Expand Up @@ -75,6 +76,9 @@ public function __construct($hostname, $opts, $channel = null)
} else {
$opts['grpc.primary_user_agent'] = '';
}
if (!empty($opts['grpc.ssl_target_name_override'])) {
$this->hostname_override = $opts['grpc.ssl_target_name_override'];
}
$opts['grpc.primary_user_agent'] .=
'grpc-php/'.$package_config['version'];
if (!array_key_exists('credentials', $opts)) {
Expand Down Expand Up @@ -173,7 +177,12 @@ private function _get_jwt_aud_uri($method)
}
$service_name = substr($method, 0, $last_slash_idx);

return 'https://'.$this->hostname.$service_name;
if ($this->hostname_override) {
$hostname = $this->hostname_override;
} else {
$hostname = $this->hostname;
}
return 'https://'.$hostname.$service_name;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/php/tests/interop/interop_client.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function performLargeUnary($stub, $fillUsername = false, $fillOauthScope = false
$request->setFillUsername($fillUsername);
$request->setFillOauthScope($fillOauthScope);

$options = false;
$options = [];
if ($callback) {
$options['call_credentials_callback'] = $callback;
}
Expand Down

0 comments on commit 6b69169

Please sign in to comment.