Skip to content

Commit e88c56b

Browse files
committed
handle auth
Signed-off-by: Robert Landers <landers.robert@gmail.com>
1 parent 7ea3a03 commit e88c56b

7 files changed

Lines changed: 13 additions & 9 deletions

src/DurableClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function signal(EntityId|string $entityId, Closure $signal): void
171171
}
172172

173173
#[Override]
174-
public function withAuth(string $token): void
174+
public function withAuth(Provenance|string|null $token): void
175175
{
176176
$this->orchestrationClient->withAuth($token);
177177
$this->entityClient->withAuth($token);

src/EntityClientInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
namespace Bottledcode\DurablePhp;
2626

2727
use Bottledcode\DurablePhp\Events\Shares\Operation;
28+
use Bottledcode\DurablePhp\Glue\Provenance;
2829
use Bottledcode\DurablePhp\Search\EntityFilter;
2930
use Bottledcode\DurablePhp\State\EntityId;
3031
use Bottledcode\DurablePhp\State\EntityState;
@@ -34,7 +35,7 @@
3435

3536
interface EntityClientInterface
3637
{
37-
public function withAuth(string $token): void;
38+
public function withAuth(Provenance|string|null $token): void;
3839

3940
/**
4041
* Removes empty entities and releases orphaned locks

src/LocalEntityClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ public function getEntitySnapshot(EntityId $entityId): ?EntityState
115115
}
116116

117117
#[Override]
118-
public function withAuth(string $token): void
118+
public function withAuth(Provenance|string|null $token): void
119119
{
120-
throw new Exception('withAuth not implemented for LocalEntityClient - set user context directly using setUserContext');
120+
$this->setUserContext($token);
121121
}
122122

123123
public function setUserContext(?Provenance $userContext): void

src/LocalOrchestrationClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ public function waitForCompletion(OrchestrationInstance $instance): void
132132
}
133133

134134
#[Override]
135-
public function withAuth(string $token): void
135+
public function withAuth(Provenance|string|null $token): void
136136
{
137-
throw new Exception('withAuth not implemented for LocalOrchestrationClient - set user context directly using setUserContext');
137+
$this->setUserContext($token);
138138
}
139139

140140
public function setUserContext(?Provenance $userContext): void

src/OrchestrationClientInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525
namespace Bottledcode\DurablePhp;
2626

2727
use Bottledcode\DurablePhp\Events\Shares\Operation;
28+
use Bottledcode\DurablePhp\Glue\Provenance;
2829
use Bottledcode\DurablePhp\State\OrchestrationInstance;
2930
use Bottledcode\DurablePhp\State\Status;
3031
use Generator;
3132

3233
interface OrchestrationClientInterface
3334
{
34-
public function withAuth(string $token): void;
35+
public function withAuth(Provenance|string|null $token): void;
3536

3637
public function getStatus(OrchestrationInstance $instance): Status;
3738

src/RemoteEntityClient.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Amp\Http\Client\HttpClient;
2828
use Amp\Http\Client\Request;
2929
use Bottledcode\DurablePhp\Events\Shares\Operation;
30+
use Bottledcode\DurablePhp\Glue\Provenance;
3031
use Bottledcode\DurablePhp\Proxy\SpyException;
3132
use Bottledcode\DurablePhp\Proxy\SpyProxy;
3233
use Bottledcode\DurablePhp\Search\EntityFilter;
@@ -146,7 +147,7 @@ public function getEntitySnapshot(EntityId $entityId): ?EntityState
146147
}
147148

148149
#[Override]
149-
public function withAuth(string $token): void
150+
public function withAuth(Provenance|string|null $token): void
150151
{
151152
$this->userToken = $token;
152153
}

src/RemoteOrchestrationClient.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Amp\Http\Client\Request;
2929
use Amp\Http\Client\SocketException;
3030
use Bottledcode\DurablePhp\Events\Shares\Operation;
31+
use Bottledcode\DurablePhp\Glue\Provenance;
3132
use Bottledcode\DurablePhp\Proxy\SpyProxy;
3233
use Bottledcode\DurablePhp\State\Ids\StateId;
3334
use Bottledcode\DurablePhp\State\OrchestrationInstance;
@@ -195,7 +196,7 @@ public function waitForCompletion(OrchestrationInstance $instance): void
195196
}
196197

197198
#[Override]
198-
public function withAuth(string $token): void
199+
public function withAuth(Provenance|string|null $token): void
199200
{
200201
$this->userToken = $token;
201202
}

0 commit comments

Comments
 (0)