Skip to content

Commit

Permalink
Rename SessionTokenVerifier to SessionCookieVerifier
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegamez committed Jan 8, 2024
1 parent 749a181 commit 159d759
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/FirebaseJwtFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Beste\Firebase\JWT\Signer\CertUrl;
use Beste\Firebase\JWT\Signer\GooglePublicKeys;
use Beste\Firebase\JWT\Token\SecureIdTokenVerifier;
use Beste\Firebase\JWT\Token\SecureSessionTokenVerifier;
use Beste\Firebase\JWT\Token\SecureSessionCookieVerifier;
use DateInterval;
use DateTimeImmutable;
use Http\Discovery\Psr17FactoryDiscovery;
Expand Down Expand Up @@ -121,9 +121,9 @@ public function verifyIdToken(string $jwt, ?string $expectedTenantId = null, ?Da
return $verifier->verify($jwt);
}

private function sessionCookieVerifier(): SessionTokenVerifier
private function sessionCookieVerifier(): SessionCookieVerifier
{
return new SecureSessionTokenVerifier(
return new SecureSessionCookieVerifier(
projectId: $this->variables->projectId(),
clock: $this->clock,
keySet: new GooglePublicKeys(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* @see https://firebase.google.com/docs/auth/admin/manage-cookies#verify_session_cookie_and_check_permissions
*/
interface SessionTokenVerifier
interface SessionCookieVerifier
{
public function withLeeway(DateInterval $leeway): self;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Beste\Firebase\JWT\Token;

use Beste\Firebase\JWT\SessionTokenVerifier;
use Beste\Firebase\JWT\SessionCookieVerifier;
use Beste\Firebase\JWT\Signer\KeySet;
use Beste\Firebase\JWT\Validation\Constraint\AuthTimeValidAt;
use Beste\Firebase\JWT\Validation\Constraint\HasTenant;
Expand All @@ -18,7 +18,7 @@
use Lcobucci\JWT\Validation\Validator;
use Psr\Clock\ClockInterface;

final class SecureSessionTokenVerifier implements SessionTokenVerifier
final class SecureSessionCookieVerifier implements SessionCookieVerifier
{
private DateInterval $leeway;
private Parser $parser;
Expand All @@ -42,15 +42,15 @@ public function __construct(
$this->validator = new Validator();
}

public function withLeeway(DateInterval $leeway): SessionTokenVerifier
public function withLeeway(DateInterval $leeway): SessionCookieVerifier
{
$new = clone $this;
$new->leeway = $leeway;

return $new;
}

public function withExpectedTenantId(string $tenantId): SessionTokenVerifier
public function withExpectedTenantId(string $tenantId): SessionCookieVerifier
{
$new = clone $this;
$new->tenantId = $tenantId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Beste\Firebase\JWT\Signer\CertUrl;
use Beste\Firebase\JWT\Signer\GooglePublicKeys;
use Beste\Firebase\JWT\Tests\TestCase;
use Beste\Firebase\JWT\Token\SecureSessionTokenVerifier;
use Beste\Firebase\JWT\Token\SecureSessionCookieVerifier;
use Http\Discovery\Psr17FactoryDiscovery;
use Http\Discovery\Psr18ClientDiscovery;
use Lcobucci\JWT\Validation\RequiredConstraintsViolated;
Expand All @@ -17,11 +17,11 @@

/**
* @internal
* @covers \Beste\Firebase\JWT\Token\SecureSessionTokenVerifier
* @covers \Beste\Firebase\JWT\Token\SecureSessionCookieVerifier
*/
final class SecureSessionTokenVerifierTest extends TestCase
final class SecureSessionCookieVerifierTest extends TestCase
{
public function testItAcceptsASessionToken(): void
public function testItAcceptsASessionCookie(): void
{
$customToken = self::customTokenBuilder()->forUser($uid = 'uid')->getToken();
$sessionCookie = self::customTokenExchanger()->exchangeCustomTokenForSessionCookie($customToken);
Expand Down Expand Up @@ -91,11 +91,11 @@ public function testItAcceptsAnExpiredIdTokenWithLeeway(): void
->verify($sessionCookie);
}

private function verifier(?ClockInterface $clock = null): SecureSessionTokenVerifier
private function verifier(?ClockInterface $clock = null): SecureSessionCookieVerifier
{
$clock ??= SystemClock::create();

return new SecureSessionTokenVerifier(
return new SecureSessionCookieVerifier(
projectId: self::variables()->projectId(),
clock: $clock,
keySet: new GooglePublicKeys(
Expand Down

0 comments on commit 159d759

Please sign in to comment.