CORSMiddleware¶
-
class
OC\AppFramework\Middleware\Security\CORSMiddleware¶ - This middleware sets the correct CORS headers on a response if thecontroller has the @CORS annotation. This is needed for webapps that wantto access an API and don’t run on the same domain, see
Source: lib/private/AppFramework/Middleware/Security/CORSMiddleware.php#47 Parent: OCP\AppFramework\Middleware
Properties¶
Methods¶
-
public
OC\AppFramework\Middleware\Security\CORSMiddleware::__construct($request, $reflector, $session, $throttler)¶ Source: lib/private/AppFramework/Middleware/Security/CORSMiddleware.php#63
Parameters: - $request (
OCP\IRequest) - $reflector (
OC\AppFramework\Utility\ControllerMethodReflector) - $session (
OC\User\Session) - $throttler (
OC\Security\Bruteforce\Throttler)
- $request (
-
public
OC\AppFramework\Middleware\Security\CORSMiddleware::beforeController($controller, $methodName)¶ - This is being run in normal order before the controller is beingcalled which allows several modifications and checks
Source: lib/private/AppFramework/Middleware/Security/CORSMiddleware.php#83
Parameters: - $controller (
OCP\AppFramework\Controller) the controller that is being called - $methodName (string) the name of the method that will be called on
the controller
Throws: \OC\AppFramework\Middleware\Security\Exceptions\SecurityExceptionSince: 6.0.0
- $controller (
-
public
OC\AppFramework\Middleware\Security\CORSMiddleware::afterController($controller, $methodName, $response)¶ - This is being run after a successful controllermethod call and allowsthe manipulation of a Response object. The middleware is run in reverse order
Source: lib/private/AppFramework/Middleware/Security/CORSMiddleware.php#113
Parameters: - $controller (
OCP\AppFramework\Controller) the controller that is being called - $methodName (string) the name of the method that will be called on
the controller * $response (
OCP\AppFramework\Http\Response) the generated response from the controllerReturns: \OCP\AppFramework\Http\Responsea Response objectThrows: \OC\AppFramework\Middleware\Security\Exceptions\SecurityException - $controller (
-
public
OC\AppFramework\Middleware\Security\CORSMiddleware::afterException($controller, $methodName, $exception)¶ - If an SecurityException is being caught return a JSON error response
Source: lib/private/AppFramework/Middleware/Security/CORSMiddleware.php#146
Parameters: - $controller (
OCP\AppFramework\Controller) the controller that is being called - $methodName (string) the name of the method that will be called on
the controller * $exception (
Exception) the thrown exceptionThrows: \Exceptionthe passed in exception if it can’t handle itReturns: \OCP\AppFramework\Http\Responsea Response object or null in case that the exception could not be handled - $controller (