OidcAuthenticator.php 946 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Auth;
  4. /**
  5. * Thin abstraction over the concrete OIDC client. Lets us mock the
  6. * provider in integration tests without spinning up a real IdP.
  7. *
  8. * `authenticate()` returns the verified claims on success; the
  9. * implementation is responsible for redirecting to the IdP when the
  10. * incoming request doesn't yet carry a `code` parameter.
  11. */
  12. interface OidcAuthenticator
  13. {
  14. /**
  15. * Drive the authorization-code-with-PKCE flow.
  16. *
  17. * Behaviour:
  18. * - On the first request (no `code`): emit a redirect to the IdP
  19. * and call `exit`. The caller's PHP process ends inside this
  20. * method — it does not return.
  21. * - On the callback request (with `code`): exchange the code,
  22. * verify the ID token, and return `OidcClaims`.
  23. *
  24. * Throws `OidcException` on any verification or transport failure.
  25. */
  26. public function authenticate(): OidcClaims;
  27. }