vendor/drenso/symfony-oidc-bundle/src/OidcSessionStorage.php line 56

Open in your IDE?
  1. <?php
  2. namespace Drenso\OidcBundle;
  3. use Symfony\Component\HttpFoundation\RequestStack;
  4. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  5. class OidcSessionStorage
  6. {
  7.   public function __construct(private readonly RequestStack $requestStack, private readonly string $clientName)
  8.   {
  9.   }
  10.   public function clearNonce(): void
  11.   {
  12.     $this->getSession()->remove($this->nonceKey());
  13.   }
  14.   public function clearCodeVerifier(): void
  15.   {
  16.     $this->getSession()->remove($this->codeVerifierKey());
  17.   }
  18.   public function clearRememberMe(): void
  19.   {
  20.     $this->getSession()->remove($this->rememberKey());
  21.   }
  22.   public function clearState(): void
  23.   {
  24.     $this->getSession()->remove($this->stateKey());
  25.   }
  26.   public function getNonce(): ?string
  27.   {
  28.     return $this->getSession()->get($this->nonceKey());
  29.   }
  30.   public function getCodeVerifier(): ?string
  31.   {
  32.     return $this->getSession()->get($this->codeVerifierKey());
  33.   }
  34.   public function getRememberMe(): bool
  35.   {
  36.     return $this->getSession()->get($this->rememberKey()) ?? false;
  37.   }
  38.   public function getState(): ?string
  39.   {
  40.     return $this->getSession()->get($this->stateKey());
  41.   }
  42.   public function storeNonce(string $value): void
  43.   {
  44.     $this->getSession()->set($this->nonceKey(), $value);
  45.   }
  46.   public function storeCodeVerifier(string $value): void
  47.   {
  48.     $this->getSession()->set($this->codeVerifierKey(), $value);
  49.   }
  50.   public function storeRememberMe(bool $value): void
  51.   {
  52.     $this->getSession()->set($this->rememberKey(), $value);
  53.   }
  54.   public function storeState(string $value): void
  55.   {
  56.     $this->getSession()->set($this->stateKey(), $value);
  57.   }
  58.   private function getSession(): SessionInterface
  59.   {
  60.     return $this->requestStack->getSession();
  61.   }
  62.   private function codeVerifierKey(): string
  63.   {
  64.     return 'drenso.oidc.session.code_verifier.' $this->clientName;
  65.   }
  66.   private function nonceKey(): string
  67.   {
  68.     return 'drenso.oidc.session.nonce.' $this->clientName;
  69.   }
  70.   private function rememberKey(): string
  71.   {
  72.     return 'drenso.oidc.session.remember_me.' $this->clientName;
  73.   }
  74.   private function stateKey(): string
  75.   {
  76.     return 'drenso.oidc.session.state.' $this->clientName;
  77.   }
  78. }