OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
firebase
/
vendor
/
kreait
/
firebase-php
/
src
/
Firebase
/
Auth
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/12/2024 10:35:39 AM
rwxr-xr-x
📁
ActionCodeSettings
-
08/12/2024 10:36:25 AM
rwxr-xr-x
📄
ActionCodeSettings.php
208 bytes
08/12/2024 10:35:36 AM
rw-r--r--
📄
ApiClient.php
6.1 KB
08/12/2024 10:35:36 AM
rw-r--r--
📁
CreateActionLink
-
08/12/2024 10:36:25 AM
rwxr-xr-x
📄
CreateActionLink.php
1.37 KB
08/12/2024 10:35:36 AM
rw-r--r--
📁
CreateSessionCookie
-
08/12/2024 10:36:25 AM
rwxr-xr-x
📄
CreateSessionCookie.php
2.21 KB
08/12/2024 10:35:36 AM
rw-r--r--
📄
CustomTokenViaGoogleIam.php
3.16 KB
08/12/2024 10:35:36 AM
rw-r--r--
📄
DeleteUsersRequest.php
1.69 KB
08/12/2024 10:35:36 AM
rw-r--r--
📄
DeleteUsersResult.php
1.66 KB
08/12/2024 10:35:36 AM
rw-r--r--
📄
DisabledLegacyCustomTokenGenerator.php
659 bytes
08/12/2024 10:35:36 AM
rw-r--r--
📄
DisabledLegacyIdTokenVerifier.php
505 bytes
08/12/2024 10:35:36 AM
rw-r--r--
📄
IdTokenVerifier.php
4.57 KB
08/12/2024 10:35:36 AM
rw-r--r--
📄
IsTenantAware.php
147 bytes
08/12/2024 10:35:36 AM
rw-r--r--
📁
SendActionLink
-
08/12/2024 10:36:25 AM
rwxr-xr-x
📄
SendActionLink.php
1.78 KB
08/12/2024 10:35:36 AM
rw-r--r--
📁
SignIn
-
08/12/2024 10:36:25 AM
rwxr-xr-x
📄
SignIn.php
96 bytes
08/12/2024 10:35:36 AM
rw-r--r--
📄
SignInAnonymously.php
571 bytes
08/12/2024 10:35:36 AM
rw-r--r--
📄
SignInResult.php
3.77 KB
08/12/2024 10:35:36 AM
rw-r--r--
📄
SignInWithCustomToken.php
821 bytes
08/12/2024 10:35:36 AM
rw-r--r--
📄
SignInWithEmailAndOobCode.php
973 bytes
08/12/2024 10:35:36 AM
rw-r--r--
📄
SignInWithEmailAndPassword.php
1.03 KB
08/12/2024 10:35:36 AM
rw-r--r--
📄
SignInWithIdpCredentials.php
2.75 KB
08/12/2024 10:35:36 AM
rw-r--r--
📄
SignInWithRefreshToken.php
828 bytes
08/12/2024 10:35:36 AM
rw-r--r--
📄
TenantId.php
421 bytes
08/12/2024 10:35:37 AM
rw-r--r--
📄
UserInfo.php
1.11 KB
08/12/2024 10:35:37 AM
rw-r--r--
📄
UserMetaData.php
1.63 KB
08/12/2024 10:35:37 AM
rw-r--r--
📄
UserRecord.php
3.6 KB
08/12/2024 10:35:37 AM
rw-r--r--
Editing: CustomTokenViaGoogleIam.php
Close
<?php declare(strict_types=1); namespace Kreait\Firebase\Auth; use Firebase\Auth\Token\Domain\Generator; use GuzzleHttp\ClientInterface; use InvalidArgumentException; use Kreait\Firebase\Exception\Auth\AuthError; use Kreait\Firebase\Exception\AuthApiExceptionConverter; use Kreait\Firebase\Exception\AuthException; use Kreait\Firebase\Exception\FirebaseException; use Kreait\Firebase\Util\DT; use Kreait\Firebase\Util\JSON; use Kreait\Firebase\Value\Uid; use Lcobucci\JWT\Configuration; use Lcobucci\JWT\Token; use Throwable; class CustomTokenViaGoogleIam implements Generator { private string $clientEmail; private ClientInterface $client; private Configuration $config; private ?TenantId $tenantId; public function __construct(string $clientEmail, ClientInterface $client, ?TenantId $tenantId = null) { $this->clientEmail = $clientEmail; $this->client = $client; $this->tenantId = $tenantId; $this->config = Configuration::forUnsecuredSigner(); } /** * @param Uid|string$uid * @param array<string, mixed> $claims * * @throws AuthException * @throws FirebaseException */ public function createCustomToken($uid, array $claims = [], ?\DateTimeInterface $expiresAt = null): Token { $now = new \DateTimeImmutable(); $expiresAt = ($expiresAt !== null) ? DT::toUTCDateTimeImmutable($expiresAt) : $now->add(new \DateInterval('PT1H')); $builder = $this->config->builder() ->withClaim('uid', (string) $uid) ->issuedBy($this->clientEmail) ->permittedFor('https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit') ->relatedTo($this->clientEmail) ->issuedAt($now) ->expiresAt($expiresAt) ; if ($this->tenantId !== null) { $builder->withClaim('tenantId', $this->tenantId->toString()); } if (!empty($claims)) { $builder->withClaim('claims', $claims); } $token = $builder->getToken($this->config->signer(), $this->config->signingKey()); $url = 'https://iam.googleapis.com/v1/projects/-/serviceAccounts/'.$this->clientEmail.':signBlob'; try { $response = $this->client->request('POST', $url, [ 'json' => [ 'bytesToSign' => \base64_encode($token->payload()), ], ]); } catch (Throwable $e) { throw (new AuthApiExceptionConverter())->convertException($e); } $result = JSON::decode((string) $response->getBody(), true); if ($base64EncodedSignature = $result['signature'] ?? null) { try { return $this->config->parser()->parse($token->payload().'.'.$base64EncodedSignature); } catch (InvalidArgumentException $e) { throw new AuthError('The custom token API returned an unexpected value: '.$e->getMessage(), $e->getCode(), $e); } } throw new AuthError('Unable to create custom token.'); } }