Skip to content

Commit c8c950e

Browse files
authored
Merge pull request #16 from ingenerator/use-insecure-credentials-wrapper-for-emulator
Use InsecureCredentialsWrapper for emulator
2 parents c6ac8f4 + 06a56e2 commit c8c950e

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Unreleased
22

3+
## v0.5.2 (2023-08-15)
4+
5+
* Use InsecureCredentialsWrapper when authenticating with the emulator in dev
6+
37
## v0.5.1 (2023-03-30)
48

59
* Allow clients to specify a custom_handler_url when creating a task, to override the default handler_url provided

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@
2121
"symfony/polyfill-php80": "^1.20"
2222
},
2323
"require-dev": {
24+
"google/cloud-core": "^1.14.4",
2425
"guzzlehttp/psr7": "^1.7",
2526
"phpunit/phpunit": "^9.5.5"
2627
},
2728
"conflict": {
2829
"google/gax": "<1.16"
2930
},
31+
"suggest": {
32+
"google/cloud-core": "You need google/cloud-core >1.44.4 to use a cloud tasks emulator with insecure credentials"
33+
},
3034
"repositories": [
3135
{"type": "composer", "url": "https://php-packages.ingenerator.com"}
3236
],

src/Client/CloudTasksClientFactory.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
namespace Ingenerator\CloudTasksWrapper\Client;
55

66

7-
use Google\Cloud\Core\AnonymousCredentials;
7+
use Google\Cloud\Core\InsecureCredentialsWrapper;
88
use Google\Cloud\Tasks\V2\CloudTasksClient;
99
use Grpc\Channel;
1010
use Grpc\ChannelCredentials;
1111
use Psr\Cache\CacheItemPoolInterface;
12+
use RuntimeException;
1213

1314
class CloudTasksClientFactory
1415
{
@@ -20,11 +21,15 @@ public static function makeClient(CacheItemPoolInterface $auth_cache, array $con
2021
];
2122

2223
if ($config['use_emulator']) {
24+
if (!class_exists(InsecureCredentialsWrapper::class)) {
25+
throw new RuntimeException(
26+
'You need google/cloud-core >1.44.4 to use a cloud tasks emulator with insecure credentials');
27+
}
2328
$options = array_merge(
2429
$base_options,
2530
[
2631
'apiEndpoint' => $config['emulator_endpoint'],
27-
'credentials' => $config['credentials'] ?? new AnonymousCredentials,
32+
'credentials' => $config['credentials'] ?? new InsecureCredentialsWrapper(),
2833
'transportConfig' => [
2934
'grpc' => [
3035
'channel' => new Channel(

0 commit comments

Comments
 (0)