AuthUrl.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\ApiResources\HelloAsso;
  4. use ApiPlatform\Metadata\ApiProperty;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use ApiPlatform\Metadata\Get;
  7. use App\State\Provider\HelloAsso\AuthUrlProvider;
  8. /**
  9. * Ressource contenant l'URL d'authentification HelloAsso et le vérificateur de défi PKCE.
  10. */
  11. #[ApiResource(
  12. operations: [
  13. new Get(
  14. uriTemplate: '/helloasso/auth-url',
  15. ),
  16. ],
  17. provider: AuthUrlProvider::class,
  18. security: '(is_granted("ROLE_ORGANIZATION")'
  19. )]
  20. class AuthUrl
  21. {
  22. /**
  23. * Id 'bidon' ajouté par défaut pour permettre la construction
  24. * de l'IRI par api platform.
  25. */
  26. #[ApiProperty(identifier: true)]
  27. private int $id = 1;
  28. /**
  29. * URL d'authentification HelloAsso pour l'autorisation OAuth2.
  30. */
  31. private string $authUrl;
  32. /**
  33. * Vérificateur de défi PKCE pour sécuriser l'échange OAuth2.
  34. */
  35. private string $challengeVerifier;
  36. public function getId(): int
  37. {
  38. return $this->id;
  39. }
  40. public function setId(int $id): self
  41. {
  42. $this->id = $id;
  43. return $this;
  44. }
  45. public function getAuthUrl(): string
  46. {
  47. return $this->authUrl;
  48. }
  49. public function setAuthUrl(string $authUrl): self
  50. {
  51. $this->authUrl = $authUrl;
  52. return $this;
  53. }
  54. public function getChallengeVerifier(): string
  55. {
  56. return $this->challengeVerifier;
  57. }
  58. public function setChallengeVerifier(string $challengeVerifier): self
  59. {
  60. $this->challengeVerifier = $challengeVerifier;
  61. return $this;
  62. }
  63. }