1
0

AuthorizeControllerInterface.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. * ex:
  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. * > $response->send();
  21. *
  22. */
  23. interface AuthorizeControllerInterface
  24. {
  25. /**
  26. * List of possible authentication response types.
  27. * The "authorization_code" mechanism exclusively supports 'code'
  28. * and the "implicit" mechanism exclusively supports 'token'.
  29. *
  30. * @var string
  31. * @see http://tools.ietf.org/html/rfc6749#section-4.1.1
  32. * @see http://tools.ietf.org/html/rfc6749#section-4.2.1
  33. */
  34. const RESPONSE_TYPE_AUTHORIZATION_CODE = 'code';
  35. const RESPONSE_TYPE_ACCESS_TOKEN = 'token';
  36. public function handleAuthorizeRequest(RequestInterface $request, ResponseInterface $response, $is_authorized, $user_id = null);
  37. public function validateAuthorizeRequest(RequestInterface $request, ResponseInterface $response);
  38. }