JwtBearerInterface.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace OAuth2\Storage;
  3. /**
  4. * Implement this interface to specify where the OAuth2 Server
  5. * should get the JWT key for clients
  6. *
  7. * @TODO consider extending ClientInterface, as this will almost always
  8. * be the same storage as retrieving clientData
  9. *
  10. * @author F21
  11. * @author Brent Shaffer <bshafs at gmail dot com>
  12. */
  13. interface JwtBearerInterface
  14. {
  15. /**
  16. * Get the public key associated with a client_id
  17. *
  18. * @param $client_id
  19. * Client identifier to be checked with.
  20. *
  21. * @return
  22. * STRING Return the public key for the client_id if it exists, and MUST return FALSE if it doesn't.
  23. */
  24. public function getClientKey($client_id, $subject);
  25. /**
  26. * Get a jti (JSON token identifier) by matching against the client_id, subject, audience and expiration.
  27. *
  28. * @param $client_id
  29. * Client identifier to match.
  30. *
  31. * @param $subject
  32. * The subject to match.
  33. *
  34. * @param $audience
  35. * The audience to match.
  36. *
  37. * @param $expiration
  38. * The expiration of the jti.
  39. *
  40. * @param $jti
  41. * The jti to match.
  42. *
  43. * @return
  44. * An associative array as below, and return NULL if the jti does not exist.
  45. * - issuer: Stored client identifier.
  46. * - subject: Stored subject.
  47. * - audience: Stored audience.
  48. * - expires: Stored expiration in unix timestamp.
  49. * - jti: The stored jti.
  50. */
  51. public function getJti($client_id, $subject, $audience, $expiration, $jti);
  52. /**
  53. * Store a used jti so that we can check against it to prevent replay attacks.
  54. * @param $client_id
  55. * Client identifier to insert.
  56. *
  57. * @param $subject
  58. * The subject to insert.
  59. *
  60. * @param $audience
  61. * The audience to insert.
  62. *
  63. * @param $expiration
  64. * The expiration of the jti.
  65. *
  66. * @param $jti
  67. * The jti to insert.
  68. */
  69. public function setJti($client_id, $subject, $audience, $expiration, $jti);
  70. }