pass auth metadata context to user callback

pull/4394/head
Stanley Cheung 9 years ago
parent b5f74f1b18
commit d1cf36cdb7
  1. 4
      src/php/ext/grpc/call_credentials.c
  2. 4
      src/php/tests/interop/interop_client.php
  3. 5
      src/php/tests/unit_tests/CallCredentialsTest.php

@ -183,7 +183,9 @@ void plugin_get_metadata(void *ptr, grpc_auth_metadata_context context,
zval *arg;
zval *retval;
MAKE_STD_ZVAL(arg);
ZVAL_STRING(arg, context.service_url, 1);
object_init(arg);
add_property_string(arg, "service_url", context.service_url, true);
add_property_string(arg, "method_name", context.method_name, true);
params[0] = &arg;
state->fci->param_count = 1;
state->fci->params = params;

@ -191,8 +191,10 @@ function oauth2AuthToken($stub, $args)
'invalid email returned');
}
function updateAuthMetadataCallback($authUri)
function updateAuthMetadataCallback($context)
{
$authUri = $context->service_url;
$methodName = $context->method_name;
$auth_credentials = ApplicationDefaultCredentials::getCredentials();
return $auth_credentials->updateMetadata($metadata = [], $authUri);

@ -69,9 +69,10 @@ class CallCredentialsTest extends PHPUnit_Framework_TestCase
unset($this->server);
}
public function callbackFunc($service_url)
public function callbackFunc($context)
{
$this->assertTrue(is_string($service_url));
$this->assertTrue(is_string($context->service_url));
$this->assertTrue(is_string($context->method_name));
return ['k1' => ['v1'], 'k2' => ['v2']];
}

Loading…
Cancel
Save