Skip to content
Snippets Groups Projects
Commit 6b69169e authored by Stanley Cheung's avatar Stanley Cheung Committed by GitHub
Browse files

Merge pull request #7959 from stanley-cheung/php-minor-fix-interop

PHP: use ssl hostname override as auth audience uri if present
parents 6ce52287 cde12a52
No related branches found
No related tags found
No related merge requests found
...@@ -41,6 +41,7 @@ namespace Grpc; ...@@ -41,6 +41,7 @@ namespace Grpc;
class BaseStub class BaseStub
{ {
private $hostname; private $hostname;
private $hostname_override;
private $channel; private $channel;
// a callback function // a callback function
...@@ -75,6 +76,9 @@ class BaseStub ...@@ -75,6 +76,9 @@ class BaseStub
} else { } else {
$opts['grpc.primary_user_agent'] = ''; $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'] .= $opts['grpc.primary_user_agent'] .=
'grpc-php/'.$package_config['version']; 'grpc-php/'.$package_config['version'];
if (!array_key_exists('credentials', $opts)) { if (!array_key_exists('credentials', $opts)) {
...@@ -173,7 +177,12 @@ class BaseStub ...@@ -173,7 +177,12 @@ class BaseStub
} }
$service_name = substr($method, 0, $last_slash_idx); $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;
} }
/** /**
......
...@@ -108,7 +108,7 @@ function performLargeUnary($stub, $fillUsername = false, $fillOauthScope = false ...@@ -108,7 +108,7 @@ function performLargeUnary($stub, $fillUsername = false, $fillOauthScope = false
$request->setFillUsername($fillUsername); $request->setFillUsername($fillUsername);
$request->setFillOauthScope($fillOauthScope); $request->setFillOauthScope($fillOauthScope);
$options = false; $options = [];
if ($callback) { if ($callback) {
$options['call_credentials_callback'] = $callback; $options['call_credentials_callback'] = $callback;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment