1
0

AuthorizationCodeInterface.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace OAuth2\Storage;
  3. /**
  4. * Implement this interface to specify where the OAuth2 Server
  5. * should get/save authorization codes for the "Authorization Code"
  6. * grant type
  7. *
  8. * @author Brent Shaffer <bshafs at gmail dot com>
  9. */
  10. interface AuthorizationCodeInterface
  11. {
  12. /**
  13. * The Authorization Code grant type supports a response type of "code".
  14. *
  15. * @var string
  16. * @see http://tools.ietf.org/html/rfc6749#section-1.4.1
  17. * @see http://tools.ietf.org/html/rfc6749#section-4.2
  18. */
  19. const RESPONSE_TYPE_CODE = "code";
  20. /**
  21. * Fetch authorization code data (probably the most common grant type).
  22. *
  23. * Retrieve the stored data for the given authorization code.
  24. *
  25. * Required for OAuth2::GRANT_TYPE_AUTH_CODE.
  26. *
  27. * @param $code
  28. * Authorization code to be check with.
  29. *
  30. * @return
  31. * An associative array as below, and NULL if the code is invalid
  32. * @code
  33. * return array(
  34. * "client_id" => CLIENT_ID, // REQUIRED Stored client identifier
  35. * "user_id" => USER_ID, // REQUIRED Stored user identifier
  36. * "expires" => EXPIRES, // REQUIRED Stored expiration in unix timestamp
  37. * "redirect_uri" => REDIRECT_URI, // REQUIRED Stored redirect URI
  38. * "scope" => SCOPE, // OPTIONAL Stored scope values in space-separated string
  39. * );
  40. * @endcode
  41. *
  42. * @see http://tools.ietf.org/html/rfc6749#section-4.1
  43. *
  44. * @ingroup oauth2_section_4
  45. */
  46. public function getAuthorizationCode($code);
  47. /**
  48. * Take the provided authorization code values and store them somewhere.
  49. *
  50. * This function should be the storage counterpart to getAuthCode().
  51. *
  52. * If storage fails for some reason, we're not currently checking for
  53. * any sort of success/failure, so you should bail out of the script
  54. * and provide a descriptive fail message.
  55. *
  56. * Required for OAuth2::GRANT_TYPE_AUTH_CODE.
  57. *
  58. * @param string $code Authorization code to be stored.
  59. * @param mixed $client_id Client identifier to be stored.
  60. * @param mixed $user_id User identifier to be stored.
  61. * @param string $redirect_uri Redirect URI(s) to be stored in a space-separated string.
  62. * @param int $expires Expiration to be stored as a Unix timestamp.
  63. * @param string $scope OPTIONAL Scopes to be stored in space-separated string.
  64. *
  65. * @ingroup oauth2_section_4
  66. */
  67. public function setAuthorizationCode($code, $client_id, $user_id, $redirect_uri, $expires, $scope = null);
  68. /**
  69. * once an Authorization Code is used, it must be expired
  70. *
  71. * @see http://tools.ietf.org/html/rfc6749#section-4.1.2
  72. *
  73. * The client MUST NOT use the authorization code
  74. * more than once. If an authorization code is used more than
  75. * once, the authorization server MUST deny the request and SHOULD
  76. * revoke (when possible) all tokens previously issued based on
  77. * that authorization code
  78. *
  79. */
  80. public function expireAuthorizationCode($code);
  81. }