AccessTokenInterface.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace OAuth2\Storage;
  3. /**
  4. * Implement this interface to specify where the OAuth2 Server
  5. * should get/save access tokens
  6. *
  7. * @author Brent Shaffer <bshafs at gmail dot com>
  8. */
  9. interface AccessTokenInterface
  10. {
  11. /**
  12. * Look up the supplied oauth_token from storage.
  13. *
  14. * We need to retrieve access token data as we create and verify tokens.
  15. *
  16. * @param $oauth_token
  17. * oauth_token to be check with.
  18. *
  19. * @return
  20. * An associative array as below, and return NULL if the supplied oauth_token
  21. * is invalid:
  22. * - expires: Stored expiration in unix timestamp.
  23. * - client_id: (optional) Stored client identifier.
  24. * - user_id: (optional) Stored user identifier.
  25. * - scope: (optional) Stored scope values in space-separated string.
  26. * - id_token: (optional) Stored id_token (if "use_openid_connect" is true).
  27. *
  28. * @ingroup oauth2_section_7
  29. */
  30. public function getAccessToken($oauth_token);
  31. /**
  32. * Store the supplied access token values to storage.
  33. *
  34. * We need to store access token data as we create and verify tokens.
  35. *
  36. * @param $oauth_token oauth_token to be stored.
  37. * @param $client_id client identifier to be stored.
  38. * @param $user_id user identifier to be stored.
  39. * @param int $expires expiration to be stored as a Unix timestamp.
  40. * @param string $scope OPTIONAL Scopes to be stored in space-separated string.
  41. *
  42. * @ingroup oauth2_section_4
  43. */
  44. public function setAccessToken($oauth_token, $client_id, $user_id, $expires, $scope = null);
  45. /**
  46. * Expire an access token.
  47. *
  48. * This is not explicitly required in the spec, but if defined in a draft RFC for token
  49. * revoking (RFC 7009) https://tools.ietf.org/html/rfc7009
  50. *
  51. * @param $access_token
  52. * Access token to be expired.
  53. *
  54. * @return BOOL true if an access token was unset, false if not
  55. * @ingroup oauth2_section_6
  56. *
  57. * @todo v2.0 include this method in interface. Omitted to maintain BC in v1.x
  58. */
  59. //public function unsetAccessToken($access_token);
  60. }