1
0

AuthorizeControllerInterface.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace OAuth2\Controller;
  3. use OAuth2\RequestInterface;
  4. use OAuth2\ResponseInterface;
  5. /**
  6. * This controller is called when a user should be authorized
  7. * by an authorization server. As OAuth2 does not handle
  8. * authorization directly, this controller ensures the request is valid, but
  9. * requires the application to determine the value of $is_authorized
  10. *
  11. * @code
  12. * $user_id = $this->somehowDetermineUserId();
  13. * $is_authorized = $this->somehowDetermineUserAuthorization();
  14. * $response = new OAuth2\Response();
  15. * $authorizeController->handleAuthorizeRequest(
  16. * OAuth2\Request::createFromGlobals(),
  17. * $response,
  18. * $is_authorized,
  19. * $user_id
  20. * );
  21. * $response->send();
  22. * @endcode
  23. */
  24. interface AuthorizeControllerInterface
  25. {
  26. /**
  27. * List of possible authentication response types.
  28. * The "authorization_code" mechanism exclusively supports 'code'
  29. * and the "implicit" mechanism exclusively supports 'token'.
  30. *
  31. * @var string
  32. * @see http://tools.ietf.org/html/rfc6749#section-4.1.1
  33. * @see http://tools.ietf.org/html/rfc6749#section-4.2.1
  34. */
  35. const RESPONSE_TYPE_AUTHORIZATION_CODE = 'code';
  36. const RESPONSE_TYPE_ACCESS_TOKEN = 'token';
  37. /**
  38. * Handle the OAuth request
  39. *
  40. * @param RequestInterface $request
  41. * @param ResponseInterface $response
  42. * @param $is_authorized
  43. * @param null $user_id
  44. * @return mixed
  45. */
  46. public function handleAuthorizeRequest(RequestInterface $request, ResponseInterface $response, $is_authorized, $user_id = null);
  47. /**
  48. * @param RequestInterface $request
  49. * @param ResponseInterface $response
  50. * @return bool
  51. */
  52. public function validateAuthorizeRequest(RequestInterface $request, ResponseInterface $response);
  53. }