AccessTokenInterface.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 string $oauth_token - oauth_token to be check with.
  17. *
  18. * @return array|null - An associative array as below, and return NULL if the supplied oauth_token is invalid:
  19. * @code
  20. * array(
  21. * 'expires' => $expires, // Stored expiration in unix timestamp.
  22. * 'client_id' => $client_id, // (optional) Stored client identifier.
  23. * 'user_id' => $user_id, // (optional) Stored user identifier.
  24. * 'scope' => $scope, // (optional) Stored scope values in space-separated string.
  25. * 'id_token' => $id_token // (optional) Stored id_token (if "use_openid_connect" is true).
  26. * );
  27. * @endcode
  28. *
  29. * @ingroup oauth2_section_7
  30. */
  31. public function getAccessToken($oauth_token);
  32. /**
  33. * Store the supplied access token values to storage.
  34. *
  35. * We need to store access token data as we create and verify tokens.
  36. *
  37. * @param string $oauth_token - oauth_token to be stored.
  38. * @param mixed $client_id - client identifier to be stored.
  39. * @param mixed $user_id - user identifier to be stored.
  40. * @param int $expires - expiration to be stored as a Unix timestamp.
  41. * @param string $scope - OPTIONAL Scopes to be stored in space-separated string.
  42. *
  43. * @ingroup oauth2_section_4
  44. */
  45. public function setAccessToken($oauth_token, $client_id, $user_id, $expires, $scope = null);
  46. /**
  47. * Expire an access token.
  48. *
  49. * This is not explicitly required in the spec, but if defined in a draft RFC for token
  50. * revoking (RFC 7009) https://tools.ietf.org/html/rfc7009
  51. *
  52. * @param $access_token
  53. * Access token to be expired.
  54. *
  55. * @return BOOL true if an access token was unset, false if not
  56. * @ingroup oauth2_section_6
  57. *
  58. * @todo v2.0 include this method in interface. Omitted to maintain BC in v1.x
  59. */
  60. //public function unsetAccessToken($access_token);
  61. }