Skip to content

Commit c2f9569

Browse files
sl0wikjeromegamez
authored andcommitted
tenant id support
1 parent 4fa91e5 commit c2f9569

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

config/firebase.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@
5757
'auto_discovery' => true,
5858
],
5959

60+
/*
61+
* ------------------------------------------------------------------------
62+
* Firebase Auth Component
63+
* ------------------------------------------------------------------------
64+
*/
65+
66+
'auth' => [
67+
'tenant_id' => env('FIREBASE_AUTH_TENANT_ID'),
68+
],
69+
6070
/*
6171
* ------------------------------------------------------------------------
6272
* Firebase Realtime Database

src/FirebaseProjectManager.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ protected function configure(string $name): FirebaseProject
6161

6262
$config = $this->configuration($name);
6363

64+
if ($tenantId = $config['auth']['tenant_id'] ?? null) {
65+
$factory = $factory->withTenantId($tenantId);
66+
}
67+
6468
if ($credentials = $config['credentials']['file'] ?? null) {
6569
$resolvedCredentials = $this->resolveCredentials((string) $credentials);
6670

tests/FirebaseProjectManagerTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,23 @@ public function credentials_can_be_configured(): void
9292
$this->assertSame($credentials, $serviceAccount->asArray());
9393
}
9494

95+
/**
96+
* @test
97+
*/
98+
public function a_tenant_id_can_be_set(): void
99+
{
100+
$this->app->config->set('firebase.projects.app.auth.tenant_id', $expected = 'abc123');
101+
102+
$auth = $this->app->make(Firebase\Auth::class);
103+
104+
/** @var Firebase\Auth\TenantId|null $tenantId */
105+
$tenantId = ReflectionObject::createFromInstance($auth)->getProperty('tenantId')->getValue($auth);
106+
107+
$this->assertInstanceOf(Firebase\Auth\TenantId::class, $tenantId);
108+
109+
$this->assertSame($expected, $tenantId->toString());
110+
}
111+
95112
/**
96113
* @test
97114
*/

0 commit comments

Comments
 (0)