@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | /** |
| 4 | 4 | * @copyright Copyright (c) 2016, ownCloud, Inc. |
| 5 | 5 | * |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | * @package OC\AppFramework\Middleware\Security\Exceptions |
| 37 | 37 | */ |
| 38 | 38 | class NotAdminException extends SecurityException { |
| 39 | - public function __construct(string $message) { |
|
| 40 | - parent::__construct($message, Http::STATUS_FORBIDDEN); |
|
| 41 | - } |
|
| 39 | + public function __construct(string $message) { |
|
| 40 | + parent::__construct($message, Http::STATUS_FORBIDDEN); |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -101,7 +101,7 @@ |
||
| 101 | 101 | * @param bool $isLoggedIn |
| 102 | 102 | * @param bool $isAdminUser |
| 103 | 103 | * @param ContentSecurityPolicyManager $contentSecurityPolicyManager |
| 104 | - * @param CSRFTokenManager $csrfTokenManager |
|
| 104 | + * @param CsrfTokenManager $csrfTokenManager |
|
| 105 | 105 | * @param ContentSecurityPolicyNonceManager $cspNonceManager |
| 106 | 106 | * @param IAppManager $appManager |
| 107 | 107 | * @param IL10N $l10n |
@@ -64,115 +64,115 @@ discard block |
||
| 64 | 64 | * check fails |
| 65 | 65 | */ |
| 66 | 66 | class SecurityMiddleware extends Middleware { |
| 67 | - /** @var INavigationManager */ |
|
| 68 | - private $navigationManager; |
|
| 69 | - /** @var IRequest */ |
|
| 70 | - private $request; |
|
| 71 | - /** @var ControllerMethodReflector */ |
|
| 72 | - private $reflector; |
|
| 73 | - /** @var string */ |
|
| 74 | - private $appName; |
|
| 75 | - /** @var IURLGenerator */ |
|
| 76 | - private $urlGenerator; |
|
| 77 | - /** @var ILogger */ |
|
| 78 | - private $logger; |
|
| 79 | - /** @var bool */ |
|
| 80 | - private $isLoggedIn; |
|
| 81 | - /** @var bool */ |
|
| 82 | - private $isAdminUser; |
|
| 83 | - /** @var ContentSecurityPolicyManager */ |
|
| 84 | - private $contentSecurityPolicyManager; |
|
| 85 | - /** @var CsrfTokenManager */ |
|
| 86 | - private $csrfTokenManager; |
|
| 87 | - /** @var ContentSecurityPolicyNonceManager */ |
|
| 88 | - private $cspNonceManager; |
|
| 89 | - /** @var IAppManager */ |
|
| 90 | - private $appManager; |
|
| 91 | - /** @var IL10N */ |
|
| 92 | - private $l10n; |
|
| 67 | + /** @var INavigationManager */ |
|
| 68 | + private $navigationManager; |
|
| 69 | + /** @var IRequest */ |
|
| 70 | + private $request; |
|
| 71 | + /** @var ControllerMethodReflector */ |
|
| 72 | + private $reflector; |
|
| 73 | + /** @var string */ |
|
| 74 | + private $appName; |
|
| 75 | + /** @var IURLGenerator */ |
|
| 76 | + private $urlGenerator; |
|
| 77 | + /** @var ILogger */ |
|
| 78 | + private $logger; |
|
| 79 | + /** @var bool */ |
|
| 80 | + private $isLoggedIn; |
|
| 81 | + /** @var bool */ |
|
| 82 | + private $isAdminUser; |
|
| 83 | + /** @var ContentSecurityPolicyManager */ |
|
| 84 | + private $contentSecurityPolicyManager; |
|
| 85 | + /** @var CsrfTokenManager */ |
|
| 86 | + private $csrfTokenManager; |
|
| 87 | + /** @var ContentSecurityPolicyNonceManager */ |
|
| 88 | + private $cspNonceManager; |
|
| 89 | + /** @var IAppManager */ |
|
| 90 | + private $appManager; |
|
| 91 | + /** @var IL10N */ |
|
| 92 | + private $l10n; |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @param IRequest $request |
|
| 96 | - * @param ControllerMethodReflector $reflector |
|
| 97 | - * @param INavigationManager $navigationManager |
|
| 98 | - * @param IURLGenerator $urlGenerator |
|
| 99 | - * @param ILogger $logger |
|
| 100 | - * @param string $appName |
|
| 101 | - * @param bool $isLoggedIn |
|
| 102 | - * @param bool $isAdminUser |
|
| 103 | - * @param ContentSecurityPolicyManager $contentSecurityPolicyManager |
|
| 104 | - * @param CSRFTokenManager $csrfTokenManager |
|
| 105 | - * @param ContentSecurityPolicyNonceManager $cspNonceManager |
|
| 106 | - * @param IAppManager $appManager |
|
| 107 | - * @param IL10N $l10n |
|
| 108 | - */ |
|
| 109 | - public function __construct(IRequest $request, |
|
| 110 | - ControllerMethodReflector $reflector, |
|
| 111 | - INavigationManager $navigationManager, |
|
| 112 | - IURLGenerator $urlGenerator, |
|
| 113 | - ILogger $logger, |
|
| 114 | - $appName, |
|
| 115 | - $isLoggedIn, |
|
| 116 | - $isAdminUser, |
|
| 117 | - ContentSecurityPolicyManager $contentSecurityPolicyManager, |
|
| 118 | - CsrfTokenManager $csrfTokenManager, |
|
| 119 | - ContentSecurityPolicyNonceManager $cspNonceManager, |
|
| 120 | - IAppManager $appManager, |
|
| 121 | - IL10N $l10n |
|
| 122 | - ) { |
|
| 123 | - $this->navigationManager = $navigationManager; |
|
| 124 | - $this->request = $request; |
|
| 125 | - $this->reflector = $reflector; |
|
| 126 | - $this->appName = $appName; |
|
| 127 | - $this->urlGenerator = $urlGenerator; |
|
| 128 | - $this->logger = $logger; |
|
| 129 | - $this->isLoggedIn = $isLoggedIn; |
|
| 130 | - $this->isAdminUser = $isAdminUser; |
|
| 131 | - $this->contentSecurityPolicyManager = $contentSecurityPolicyManager; |
|
| 132 | - $this->csrfTokenManager = $csrfTokenManager; |
|
| 133 | - $this->cspNonceManager = $cspNonceManager; |
|
| 134 | - $this->appManager = $appManager; |
|
| 135 | - $this->l10n = $l10n; |
|
| 136 | - } |
|
| 94 | + /** |
|
| 95 | + * @param IRequest $request |
|
| 96 | + * @param ControllerMethodReflector $reflector |
|
| 97 | + * @param INavigationManager $navigationManager |
|
| 98 | + * @param IURLGenerator $urlGenerator |
|
| 99 | + * @param ILogger $logger |
|
| 100 | + * @param string $appName |
|
| 101 | + * @param bool $isLoggedIn |
|
| 102 | + * @param bool $isAdminUser |
|
| 103 | + * @param ContentSecurityPolicyManager $contentSecurityPolicyManager |
|
| 104 | + * @param CSRFTokenManager $csrfTokenManager |
|
| 105 | + * @param ContentSecurityPolicyNonceManager $cspNonceManager |
|
| 106 | + * @param IAppManager $appManager |
|
| 107 | + * @param IL10N $l10n |
|
| 108 | + */ |
|
| 109 | + public function __construct(IRequest $request, |
|
| 110 | + ControllerMethodReflector $reflector, |
|
| 111 | + INavigationManager $navigationManager, |
|
| 112 | + IURLGenerator $urlGenerator, |
|
| 113 | + ILogger $logger, |
|
| 114 | + $appName, |
|
| 115 | + $isLoggedIn, |
|
| 116 | + $isAdminUser, |
|
| 117 | + ContentSecurityPolicyManager $contentSecurityPolicyManager, |
|
| 118 | + CsrfTokenManager $csrfTokenManager, |
|
| 119 | + ContentSecurityPolicyNonceManager $cspNonceManager, |
|
| 120 | + IAppManager $appManager, |
|
| 121 | + IL10N $l10n |
|
| 122 | + ) { |
|
| 123 | + $this->navigationManager = $navigationManager; |
|
| 124 | + $this->request = $request; |
|
| 125 | + $this->reflector = $reflector; |
|
| 126 | + $this->appName = $appName; |
|
| 127 | + $this->urlGenerator = $urlGenerator; |
|
| 128 | + $this->logger = $logger; |
|
| 129 | + $this->isLoggedIn = $isLoggedIn; |
|
| 130 | + $this->isAdminUser = $isAdminUser; |
|
| 131 | + $this->contentSecurityPolicyManager = $contentSecurityPolicyManager; |
|
| 132 | + $this->csrfTokenManager = $csrfTokenManager; |
|
| 133 | + $this->cspNonceManager = $cspNonceManager; |
|
| 134 | + $this->appManager = $appManager; |
|
| 135 | + $this->l10n = $l10n; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - /** |
|
| 139 | - * This runs all the security checks before a method call. The |
|
| 140 | - * security checks are determined by inspecting the controller method |
|
| 141 | - * annotations |
|
| 142 | - * @param Controller $controller the controller |
|
| 143 | - * @param string $methodName the name of the method |
|
| 144 | - * @throws SecurityException when a security check fails |
|
| 145 | - */ |
|
| 146 | - public function beforeController($controller, $methodName) { |
|
| 138 | + /** |
|
| 139 | + * This runs all the security checks before a method call. The |
|
| 140 | + * security checks are determined by inspecting the controller method |
|
| 141 | + * annotations |
|
| 142 | + * @param Controller $controller the controller |
|
| 143 | + * @param string $methodName the name of the method |
|
| 144 | + * @throws SecurityException when a security check fails |
|
| 145 | + */ |
|
| 146 | + public function beforeController($controller, $methodName) { |
|
| 147 | 147 | |
| 148 | - // this will set the current navigation entry of the app, use this only |
|
| 149 | - // for normal HTML requests and not for AJAX requests |
|
| 150 | - $this->navigationManager->setActiveEntry($this->appName); |
|
| 148 | + // this will set the current navigation entry of the app, use this only |
|
| 149 | + // for normal HTML requests and not for AJAX requests |
|
| 150 | + $this->navigationManager->setActiveEntry($this->appName); |
|
| 151 | 151 | |
| 152 | - // security checks |
|
| 153 | - $isPublicPage = $this->reflector->hasAnnotation('PublicPage'); |
|
| 154 | - if(!$isPublicPage) { |
|
| 155 | - if(!$this->isLoggedIn) { |
|
| 156 | - throw new NotLoggedInException(); |
|
| 157 | - } |
|
| 152 | + // security checks |
|
| 153 | + $isPublicPage = $this->reflector->hasAnnotation('PublicPage'); |
|
| 154 | + if(!$isPublicPage) { |
|
| 155 | + if(!$this->isLoggedIn) { |
|
| 156 | + throw new NotLoggedInException(); |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - if(!$this->reflector->hasAnnotation('NoAdminRequired')) { |
|
| 160 | - if(!$this->isAdminUser) { |
|
| 161 | - throw new NotAdminException($this->l10n->t('Logged in user must be an admin')); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - } |
|
| 159 | + if(!$this->reflector->hasAnnotation('NoAdminRequired')) { |
|
| 160 | + if(!$this->isAdminUser) { |
|
| 161 | + throw new NotAdminException($this->l10n->t('Logged in user must be an admin')); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - // Check for strict cookie requirement |
|
| 167 | - if($this->reflector->hasAnnotation('StrictCookieRequired') || !$this->reflector->hasAnnotation('NoCSRFRequired')) { |
|
| 168 | - if(!$this->request->passesStrictCookieCheck()) { |
|
| 169 | - throw new StrictCookieMissingException(); |
|
| 170 | - } |
|
| 171 | - } |
|
| 172 | - // CSRF check - also registers the CSRF token since the session may be closed later |
|
| 173 | - Util::callRegister(); |
|
| 174 | - if(!$this->reflector->hasAnnotation('NoCSRFRequired')) { |
|
| 175 | - /* |
|
| 166 | + // Check for strict cookie requirement |
|
| 167 | + if($this->reflector->hasAnnotation('StrictCookieRequired') || !$this->reflector->hasAnnotation('NoCSRFRequired')) { |
|
| 168 | + if(!$this->request->passesStrictCookieCheck()) { |
|
| 169 | + throw new StrictCookieMissingException(); |
|
| 170 | + } |
|
| 171 | + } |
|
| 172 | + // CSRF check - also registers the CSRF token since the session may be closed later |
|
| 173 | + Util::callRegister(); |
|
| 174 | + if(!$this->reflector->hasAnnotation('NoCSRFRequired')) { |
|
| 175 | + /* |
|
| 176 | 176 | * Only allow the CSRF check to fail on OCS Requests. This kind of |
| 177 | 177 | * hacks around that we have no full token auth in place yet and we |
| 178 | 178 | * do want to offer CSRF checks for web requests. |
@@ -180,98 +180,98 @@ discard block |
||
| 180 | 180 | * Additionally we allow Bearer authenticated requests to pass on OCS routes. |
| 181 | 181 | * This allows oauth apps (e.g. moodle) to use the OCS endpoints |
| 182 | 182 | */ |
| 183 | - if(!$this->request->passesCSRFCheck() && !( |
|
| 184 | - $controller instanceof OCSController && ( |
|
| 185 | - $this->request->getHeader('OCS-APIREQUEST') === 'true' || |
|
| 186 | - strpos($this->request->getHeader('Authorization'), 'Bearer ') === 0 |
|
| 187 | - ) |
|
| 188 | - )) { |
|
| 189 | - throw new CrossSiteRequestForgeryException(); |
|
| 190 | - } |
|
| 191 | - } |
|
| 183 | + if(!$this->request->passesCSRFCheck() && !( |
|
| 184 | + $controller instanceof OCSController && ( |
|
| 185 | + $this->request->getHeader('OCS-APIREQUEST') === 'true' || |
|
| 186 | + strpos($this->request->getHeader('Authorization'), 'Bearer ') === 0 |
|
| 187 | + ) |
|
| 188 | + )) { |
|
| 189 | + throw new CrossSiteRequestForgeryException(); |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * FIXME: Use DI once available |
|
| 195 | - * Checks if app is enabled (also includes a check whether user is allowed to access the resource) |
|
| 196 | - * The getAppPath() check is here since components such as settings also use the AppFramework and |
|
| 197 | - * therefore won't pass this check. |
|
| 198 | - */ |
|
| 199 | - if(\OC_App::getAppPath($this->appName) !== false && !$this->appManager->isEnabledForUser($this->appName)) { |
|
| 200 | - throw new AppNotEnabledException(); |
|
| 201 | - } |
|
| 193 | + /** |
|
| 194 | + * FIXME: Use DI once available |
|
| 195 | + * Checks if app is enabled (also includes a check whether user is allowed to access the resource) |
|
| 196 | + * The getAppPath() check is here since components such as settings also use the AppFramework and |
|
| 197 | + * therefore won't pass this check. |
|
| 198 | + */ |
|
| 199 | + if(\OC_App::getAppPath($this->appName) !== false && !$this->appManager->isEnabledForUser($this->appName)) { |
|
| 200 | + throw new AppNotEnabledException(); |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - } |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - /** |
|
| 206 | - * Performs the default CSP modifications that may be injected by other |
|
| 207 | - * applications |
|
| 208 | - * |
|
| 209 | - * @param Controller $controller |
|
| 210 | - * @param string $methodName |
|
| 211 | - * @param Response $response |
|
| 212 | - * @return Response |
|
| 213 | - */ |
|
| 214 | - public function afterController($controller, $methodName, Response $response) { |
|
| 215 | - $policy = !is_null($response->getContentSecurityPolicy()) ? $response->getContentSecurityPolicy() : new ContentSecurityPolicy(); |
|
| 205 | + /** |
|
| 206 | + * Performs the default CSP modifications that may be injected by other |
|
| 207 | + * applications |
|
| 208 | + * |
|
| 209 | + * @param Controller $controller |
|
| 210 | + * @param string $methodName |
|
| 211 | + * @param Response $response |
|
| 212 | + * @return Response |
|
| 213 | + */ |
|
| 214 | + public function afterController($controller, $methodName, Response $response) { |
|
| 215 | + $policy = !is_null($response->getContentSecurityPolicy()) ? $response->getContentSecurityPolicy() : new ContentSecurityPolicy(); |
|
| 216 | 216 | |
| 217 | - if (get_class($policy) === EmptyContentSecurityPolicy::class) { |
|
| 218 | - return $response; |
|
| 219 | - } |
|
| 217 | + if (get_class($policy) === EmptyContentSecurityPolicy::class) { |
|
| 218 | + return $response; |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - $defaultPolicy = $this->contentSecurityPolicyManager->getDefaultPolicy(); |
|
| 222 | - $defaultPolicy = $this->contentSecurityPolicyManager->mergePolicies($defaultPolicy, $policy); |
|
| 221 | + $defaultPolicy = $this->contentSecurityPolicyManager->getDefaultPolicy(); |
|
| 222 | + $defaultPolicy = $this->contentSecurityPolicyManager->mergePolicies($defaultPolicy, $policy); |
|
| 223 | 223 | |
| 224 | - if($this->cspNonceManager->browserSupportsCspV3()) { |
|
| 225 | - $defaultPolicy->useJsNonce($this->csrfTokenManager->getToken()->getEncryptedValue()); |
|
| 226 | - } |
|
| 224 | + if($this->cspNonceManager->browserSupportsCspV3()) { |
|
| 225 | + $defaultPolicy->useJsNonce($this->csrfTokenManager->getToken()->getEncryptedValue()); |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - $response->setContentSecurityPolicy($defaultPolicy); |
|
| 228 | + $response->setContentSecurityPolicy($defaultPolicy); |
|
| 229 | 229 | |
| 230 | - return $response; |
|
| 231 | - } |
|
| 230 | + return $response; |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - /** |
|
| 234 | - * If an SecurityException is being caught, ajax requests return a JSON error |
|
| 235 | - * response and non ajax requests redirect to the index |
|
| 236 | - * @param Controller $controller the controller that is being called |
|
| 237 | - * @param string $methodName the name of the method that will be called on |
|
| 238 | - * the controller |
|
| 239 | - * @param \Exception $exception the thrown exception |
|
| 240 | - * @throws \Exception the passed in exception if it can't handle it |
|
| 241 | - * @return Response a Response object or null in case that the exception could not be handled |
|
| 242 | - */ |
|
| 243 | - public function afterException($controller, $methodName, \Exception $exception) { |
|
| 244 | - if($exception instanceof SecurityException) { |
|
| 245 | - if($exception instanceof StrictCookieMissingException) { |
|
| 246 | - return new RedirectResponse(\OC::$WEBROOT); |
|
| 247 | - } |
|
| 248 | - if (stripos($this->request->getHeader('Accept'),'html') === false) { |
|
| 249 | - $response = new JSONResponse( |
|
| 250 | - array('message' => $exception->getMessage()), |
|
| 251 | - $exception->getCode() |
|
| 252 | - ); |
|
| 253 | - } else { |
|
| 254 | - if($exception instanceof NotLoggedInException) { |
|
| 255 | - $params = []; |
|
| 256 | - if (isset($this->request->server['REQUEST_URI'])) { |
|
| 257 | - $params['redirect_url'] = $this->request->server['REQUEST_URI']; |
|
| 258 | - } |
|
| 259 | - $url = $this->urlGenerator->linkToRoute('core.login.showLoginForm', $params); |
|
| 260 | - $response = new RedirectResponse($url); |
|
| 261 | - } else { |
|
| 262 | - $response = new TemplateResponse('core', '403', ['file' => $exception->getMessage()], 'guest'); |
|
| 263 | - $response->setStatus($exception->getCode()); |
|
| 264 | - } |
|
| 265 | - } |
|
| 233 | + /** |
|
| 234 | + * If an SecurityException is being caught, ajax requests return a JSON error |
|
| 235 | + * response and non ajax requests redirect to the index |
|
| 236 | + * @param Controller $controller the controller that is being called |
|
| 237 | + * @param string $methodName the name of the method that will be called on |
|
| 238 | + * the controller |
|
| 239 | + * @param \Exception $exception the thrown exception |
|
| 240 | + * @throws \Exception the passed in exception if it can't handle it |
|
| 241 | + * @return Response a Response object or null in case that the exception could not be handled |
|
| 242 | + */ |
|
| 243 | + public function afterException($controller, $methodName, \Exception $exception) { |
|
| 244 | + if($exception instanceof SecurityException) { |
|
| 245 | + if($exception instanceof StrictCookieMissingException) { |
|
| 246 | + return new RedirectResponse(\OC::$WEBROOT); |
|
| 247 | + } |
|
| 248 | + if (stripos($this->request->getHeader('Accept'),'html') === false) { |
|
| 249 | + $response = new JSONResponse( |
|
| 250 | + array('message' => $exception->getMessage()), |
|
| 251 | + $exception->getCode() |
|
| 252 | + ); |
|
| 253 | + } else { |
|
| 254 | + if($exception instanceof NotLoggedInException) { |
|
| 255 | + $params = []; |
|
| 256 | + if (isset($this->request->server['REQUEST_URI'])) { |
|
| 257 | + $params['redirect_url'] = $this->request->server['REQUEST_URI']; |
|
| 258 | + } |
|
| 259 | + $url = $this->urlGenerator->linkToRoute('core.login.showLoginForm', $params); |
|
| 260 | + $response = new RedirectResponse($url); |
|
| 261 | + } else { |
|
| 262 | + $response = new TemplateResponse('core', '403', ['file' => $exception->getMessage()], 'guest'); |
|
| 263 | + $response->setStatus($exception->getCode()); |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - $this->logger->logException($exception, [ |
|
| 268 | - 'level' => \OCP\Util::DEBUG, |
|
| 269 | - 'app' => 'core', |
|
| 270 | - ]); |
|
| 271 | - return $response; |
|
| 272 | - } |
|
| 267 | + $this->logger->logException($exception, [ |
|
| 268 | + 'level' => \OCP\Util::DEBUG, |
|
| 269 | + 'app' => 'core', |
|
| 270 | + ]); |
|
| 271 | + return $response; |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - throw $exception; |
|
| 275 | - } |
|
| 274 | + throw $exception; |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | 277 | } |
@@ -151,27 +151,27 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | // security checks |
| 153 | 153 | $isPublicPage = $this->reflector->hasAnnotation('PublicPage'); |
| 154 | - if(!$isPublicPage) { |
|
| 155 | - if(!$this->isLoggedIn) { |
|
| 154 | + if (!$isPublicPage) { |
|
| 155 | + if (!$this->isLoggedIn) { |
|
| 156 | 156 | throw new NotLoggedInException(); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if(!$this->reflector->hasAnnotation('NoAdminRequired')) { |
|
| 160 | - if(!$this->isAdminUser) { |
|
| 159 | + if (!$this->reflector->hasAnnotation('NoAdminRequired')) { |
|
| 160 | + if (!$this->isAdminUser) { |
|
| 161 | 161 | throw new NotAdminException($this->l10n->t('Logged in user must be an admin')); |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // Check for strict cookie requirement |
| 167 | - if($this->reflector->hasAnnotation('StrictCookieRequired') || !$this->reflector->hasAnnotation('NoCSRFRequired')) { |
|
| 168 | - if(!$this->request->passesStrictCookieCheck()) { |
|
| 167 | + if ($this->reflector->hasAnnotation('StrictCookieRequired') || !$this->reflector->hasAnnotation('NoCSRFRequired')) { |
|
| 168 | + if (!$this->request->passesStrictCookieCheck()) { |
|
| 169 | 169 | throw new StrictCookieMissingException(); |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | // CSRF check - also registers the CSRF token since the session may be closed later |
| 173 | 173 | Util::callRegister(); |
| 174 | - if(!$this->reflector->hasAnnotation('NoCSRFRequired')) { |
|
| 174 | + if (!$this->reflector->hasAnnotation('NoCSRFRequired')) { |
|
| 175 | 175 | /* |
| 176 | 176 | * Only allow the CSRF check to fail on OCS Requests. This kind of |
| 177 | 177 | * hacks around that we have no full token auth in place yet and we |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * Additionally we allow Bearer authenticated requests to pass on OCS routes. |
| 181 | 181 | * This allows oauth apps (e.g. moodle) to use the OCS endpoints |
| 182 | 182 | */ |
| 183 | - if(!$this->request->passesCSRFCheck() && !( |
|
| 183 | + if (!$this->request->passesCSRFCheck() && !( |
|
| 184 | 184 | $controller instanceof OCSController && ( |
| 185 | 185 | $this->request->getHeader('OCS-APIREQUEST') === 'true' || |
| 186 | 186 | strpos($this->request->getHeader('Authorization'), 'Bearer ') === 0 |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * The getAppPath() check is here since components such as settings also use the AppFramework and |
| 197 | 197 | * therefore won't pass this check. |
| 198 | 198 | */ |
| 199 | - if(\OC_App::getAppPath($this->appName) !== false && !$this->appManager->isEnabledForUser($this->appName)) { |
|
| 199 | + if (\OC_App::getAppPath($this->appName) !== false && !$this->appManager->isEnabledForUser($this->appName)) { |
|
| 200 | 200 | throw new AppNotEnabledException(); |
| 201 | 201 | } |
| 202 | 202 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | $defaultPolicy = $this->contentSecurityPolicyManager->getDefaultPolicy(); |
| 222 | 222 | $defaultPolicy = $this->contentSecurityPolicyManager->mergePolicies($defaultPolicy, $policy); |
| 223 | 223 | |
| 224 | - if($this->cspNonceManager->browserSupportsCspV3()) { |
|
| 224 | + if ($this->cspNonceManager->browserSupportsCspV3()) { |
|
| 225 | 225 | $defaultPolicy->useJsNonce($this->csrfTokenManager->getToken()->getEncryptedValue()); |
| 226 | 226 | } |
| 227 | 227 | |
@@ -241,17 +241,17 @@ discard block |
||
| 241 | 241 | * @return Response a Response object or null in case that the exception could not be handled |
| 242 | 242 | */ |
| 243 | 243 | public function afterException($controller, $methodName, \Exception $exception) { |
| 244 | - if($exception instanceof SecurityException) { |
|
| 245 | - if($exception instanceof StrictCookieMissingException) { |
|
| 244 | + if ($exception instanceof SecurityException) { |
|
| 245 | + if ($exception instanceof StrictCookieMissingException) { |
|
| 246 | 246 | return new RedirectResponse(\OC::$WEBROOT); |
| 247 | 247 | } |
| 248 | - if (stripos($this->request->getHeader('Accept'),'html') === false) { |
|
| 248 | + if (stripos($this->request->getHeader('Accept'), 'html') === false) { |
|
| 249 | 249 | $response = new JSONResponse( |
| 250 | 250 | array('message' => $exception->getMessage()), |
| 251 | 251 | $exception->getCode() |
| 252 | 252 | ); |
| 253 | 253 | } else { |
| 254 | - if($exception instanceof NotLoggedInException) { |
|
| 254 | + if ($exception instanceof NotLoggedInException) { |
|
| 255 | 255 | $params = []; |
| 256 | 256 | if (isset($this->request->server['REQUEST_URI'])) { |
| 257 | 257 | $params['redirect_url'] = $this->request->server['REQUEST_URI']; |
@@ -67,384 +67,384 @@ |
||
| 67 | 67 | |
| 68 | 68 | class DIContainer extends SimpleContainer implements IAppContainer { |
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * @var array |
|
| 72 | - */ |
|
| 73 | - private $middleWares = array(); |
|
| 74 | - |
|
| 75 | - /** @var ServerContainer */ |
|
| 76 | - private $server; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * Put your class dependencies in here |
|
| 80 | - * @param string $appName the name of the app |
|
| 81 | - * @param array $urlParams |
|
| 82 | - * @param ServerContainer|null $server |
|
| 83 | - */ |
|
| 84 | - public function __construct($appName, $urlParams = array(), ServerContainer $server = null){ |
|
| 85 | - parent::__construct(); |
|
| 86 | - $this['AppName'] = $appName; |
|
| 87 | - $this['urlParams'] = $urlParams; |
|
| 88 | - |
|
| 89 | - /** @var \OC\ServerContainer $server */ |
|
| 90 | - if ($server === null) { |
|
| 91 | - $server = \OC::$server; |
|
| 92 | - } |
|
| 93 | - $this->server = $server; |
|
| 94 | - $this->server->registerAppContainer($appName, $this); |
|
| 95 | - |
|
| 96 | - // aliases |
|
| 97 | - $this->registerAlias('appName', 'AppName'); |
|
| 98 | - $this->registerAlias('webRoot', 'WebRoot'); |
|
| 99 | - $this->registerAlias('userId', 'UserId'); |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * Core services |
|
| 103 | - */ |
|
| 104 | - $this->registerService(IOutput::class, function($c){ |
|
| 105 | - return new Output($this->getServer()->getWebRoot()); |
|
| 106 | - }); |
|
| 107 | - |
|
| 108 | - $this->registerService(Folder::class, function() { |
|
| 109 | - return $this->getServer()->getUserFolder(); |
|
| 110 | - }); |
|
| 111 | - |
|
| 112 | - $this->registerService(IAppData::class, function (SimpleContainer $c) { |
|
| 113 | - return $this->getServer()->getAppDataDir($c->query('AppName')); |
|
| 114 | - }); |
|
| 115 | - |
|
| 116 | - $this->registerService(IL10N::class, function($c) { |
|
| 117 | - return $this->getServer()->getL10N($c->query('AppName')); |
|
| 118 | - }); |
|
| 119 | - |
|
| 120 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
| 121 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
| 122 | - |
|
| 123 | - $this->registerService(IRequest::class, function() { |
|
| 124 | - return $this->getServer()->query(IRequest::class); |
|
| 125 | - }); |
|
| 126 | - $this->registerAlias('Request', IRequest::class); |
|
| 127 | - |
|
| 128 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
| 129 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
| 130 | - |
|
| 131 | - $this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class); |
|
| 132 | - |
|
| 133 | - $this->registerService(IServerContainer::class, function ($c) { |
|
| 134 | - return $this->getServer(); |
|
| 135 | - }); |
|
| 136 | - $this->registerAlias('ServerContainer', IServerContainer::class); |
|
| 137 | - |
|
| 138 | - $this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) { |
|
| 139 | - return $c->query(Manager::class); |
|
| 140 | - }); |
|
| 141 | - |
|
| 142 | - $this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) { |
|
| 143 | - return $c; |
|
| 144 | - }); |
|
| 145 | - |
|
| 146 | - // commonly used attributes |
|
| 147 | - $this->registerService('UserId', function ($c) { |
|
| 148 | - return $c->query(IUserSession::class)->getSession()->get('user_id'); |
|
| 149 | - }); |
|
| 150 | - |
|
| 151 | - $this->registerService('WebRoot', function ($c) { |
|
| 152 | - return $c->query('ServerContainer')->getWebRoot(); |
|
| 153 | - }); |
|
| 154 | - |
|
| 155 | - $this->registerService('OC_Defaults', function ($c) { |
|
| 156 | - return $c->getServer()->getThemingDefaults(); |
|
| 157 | - }); |
|
| 158 | - |
|
| 159 | - $this->registerService(IManager::class, function ($c) { |
|
| 160 | - return $this->getServer()->getEncryptionManager(); |
|
| 161 | - }); |
|
| 162 | - |
|
| 163 | - $this->registerService(IConfig::class, function ($c) { |
|
| 164 | - return $c->query(OC\GlobalScale\Config::class); |
|
| 165 | - }); |
|
| 166 | - |
|
| 167 | - $this->registerService(IValidator::class, function($c) { |
|
| 168 | - return $c->query(Validator::class); |
|
| 169 | - }); |
|
| 170 | - |
|
| 171 | - $this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) { |
|
| 172 | - return new \OC\Security\IdentityProof\Manager( |
|
| 173 | - $this->getServer()->query(\OC\Files\AppData\Factory::class), |
|
| 174 | - $this->getServer()->getCrypto(), |
|
| 175 | - $this->getServer()->getConfig() |
|
| 176 | - ); |
|
| 177 | - }); |
|
| 178 | - |
|
| 179 | - $this->registerService('Protocol', function($c){ |
|
| 180 | - /** @var \OC\Server $server */ |
|
| 181 | - $server = $c->query('ServerContainer'); |
|
| 182 | - $protocol = $server->getRequest()->getHttpProtocol(); |
|
| 183 | - return new Http($_SERVER, $protocol); |
|
| 184 | - }); |
|
| 185 | - |
|
| 186 | - $this->registerService('Dispatcher', function($c) { |
|
| 187 | - return new Dispatcher( |
|
| 188 | - $c['Protocol'], |
|
| 189 | - $c['MiddlewareDispatcher'], |
|
| 190 | - $c['ControllerMethodReflector'], |
|
| 191 | - $c['Request'] |
|
| 192 | - ); |
|
| 193 | - }); |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * App Framework default arguments |
|
| 197 | - */ |
|
| 198 | - $this->registerParameter('corsMethods', 'PUT, POST, GET, DELETE, PATCH'); |
|
| 199 | - $this->registerParameter('corsAllowedHeaders', 'Authorization, Content-Type, Accept'); |
|
| 200 | - $this->registerParameter('corsMaxAge', 1728000); |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * Middleware |
|
| 204 | - */ |
|
| 205 | - $app = $this; |
|
| 206 | - $this->registerService('SecurityMiddleware', function($c) use ($app){ |
|
| 207 | - /** @var \OC\Server $server */ |
|
| 208 | - $server = $app->getServer(); |
|
| 209 | - |
|
| 210 | - return new SecurityMiddleware( |
|
| 211 | - $c['Request'], |
|
| 212 | - $c['ControllerMethodReflector'], |
|
| 213 | - $server->getNavigationManager(), |
|
| 214 | - $server->getURLGenerator(), |
|
| 215 | - $server->getLogger(), |
|
| 216 | - $c['AppName'], |
|
| 217 | - $server->getUserSession()->isLoggedIn(), |
|
| 218 | - $server->getGroupManager()->isAdmin($this->getUserId()), |
|
| 219 | - $server->getContentSecurityPolicyManager(), |
|
| 220 | - $server->getCsrfTokenManager(), |
|
| 221 | - $server->getContentSecurityPolicyNonceManager(), |
|
| 222 | - $server->getAppManager(), |
|
| 223 | - $server->getL10N('lib') |
|
| 224 | - ); |
|
| 225 | - }); |
|
| 226 | - |
|
| 227 | - $this->registerService(OC\AppFramework\Middleware\Security\PasswordConfirmationMiddleware::class, function ($c) use ($app) { |
|
| 228 | - /** @var \OC\Server $server */ |
|
| 229 | - $server = $app->getServer(); |
|
| 230 | - |
|
| 231 | - return new OC\AppFramework\Middleware\Security\PasswordConfirmationMiddleware( |
|
| 232 | - $c['ControllerMethodReflector'], |
|
| 233 | - $server->getSession(), |
|
| 234 | - $server->getUserSession(), |
|
| 235 | - $server->query(ITimeFactory::class) |
|
| 236 | - ); |
|
| 237 | - }); |
|
| 238 | - |
|
| 239 | - $this->registerService('BruteForceMiddleware', function($c) use ($app) { |
|
| 240 | - /** @var \OC\Server $server */ |
|
| 241 | - $server = $app->getServer(); |
|
| 242 | - |
|
| 243 | - return new OC\AppFramework\Middleware\Security\BruteForceMiddleware( |
|
| 244 | - $c['ControllerMethodReflector'], |
|
| 245 | - $server->getBruteForceThrottler(), |
|
| 246 | - $server->getRequest() |
|
| 247 | - ); |
|
| 248 | - }); |
|
| 249 | - |
|
| 250 | - $this->registerService('RateLimitingMiddleware', function($c) use ($app) { |
|
| 251 | - /** @var \OC\Server $server */ |
|
| 252 | - $server = $app->getServer(); |
|
| 253 | - |
|
| 254 | - return new RateLimitingMiddleware( |
|
| 255 | - $server->getRequest(), |
|
| 256 | - $server->getUserSession(), |
|
| 257 | - $c['ControllerMethodReflector'], |
|
| 258 | - $c->query(OC\Security\RateLimiting\Limiter::class) |
|
| 259 | - ); |
|
| 260 | - }); |
|
| 261 | - |
|
| 262 | - $this->registerService('CORSMiddleware', function($c) { |
|
| 263 | - return new CORSMiddleware( |
|
| 264 | - $c['Request'], |
|
| 265 | - $c['ControllerMethodReflector'], |
|
| 266 | - $c->query(IUserSession::class), |
|
| 267 | - $c->getServer()->getBruteForceThrottler() |
|
| 268 | - ); |
|
| 269 | - }); |
|
| 270 | - |
|
| 271 | - $this->registerService('SessionMiddleware', function($c) use ($app) { |
|
| 272 | - return new SessionMiddleware( |
|
| 273 | - $c['Request'], |
|
| 274 | - $c['ControllerMethodReflector'], |
|
| 275 | - $app->getServer()->getSession() |
|
| 276 | - ); |
|
| 277 | - }); |
|
| 278 | - |
|
| 279 | - $this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) { |
|
| 280 | - $twoFactorManager = $c->getServer()->getTwoFactorAuthManager(); |
|
| 281 | - $userSession = $app->getServer()->getUserSession(); |
|
| 282 | - $session = $app->getServer()->getSession(); |
|
| 283 | - $urlGenerator = $app->getServer()->getURLGenerator(); |
|
| 284 | - $reflector = $c['ControllerMethodReflector']; |
|
| 285 | - $request = $app->getServer()->getRequest(); |
|
| 286 | - return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request); |
|
| 287 | - }); |
|
| 288 | - |
|
| 289 | - $this->registerService('OCSMiddleware', function (SimpleContainer $c) { |
|
| 290 | - return new OCSMiddleware( |
|
| 291 | - $c['Request'] |
|
| 292 | - ); |
|
| 293 | - }); |
|
| 294 | - |
|
| 295 | - $this->registerService(OC\AppFramework\Middleware\Security\SameSiteCookieMiddleware::class, function (SimpleContainer $c) { |
|
| 296 | - return new OC\AppFramework\Middleware\Security\SameSiteCookieMiddleware( |
|
| 297 | - $c['Request'], |
|
| 298 | - $c['ControllerMethodReflector'] |
|
| 299 | - ); |
|
| 300 | - }); |
|
| 301 | - |
|
| 302 | - $middleWares = &$this->middleWares; |
|
| 303 | - $this->registerService('MiddlewareDispatcher', function($c) use (&$middleWares) { |
|
| 304 | - $dispatcher = new MiddlewareDispatcher(); |
|
| 305 | - $dispatcher->registerMiddleware($c[OC\AppFramework\Middleware\Security\SameSiteCookieMiddleware::class]); |
|
| 306 | - $dispatcher->registerMiddleware($c['CORSMiddleware']); |
|
| 307 | - $dispatcher->registerMiddleware($c['OCSMiddleware']); |
|
| 308 | - $dispatcher->registerMiddleware($c['SecurityMiddleware']); |
|
| 309 | - $dispatcher->registerMiddleware($c[OC\AppFramework\Middleware\Security\PasswordConfirmationMiddleware::class]); |
|
| 310 | - $dispatcher->registerMiddleware($c['TwoFactorMiddleware']); |
|
| 311 | - $dispatcher->registerMiddleware($c['BruteForceMiddleware']); |
|
| 312 | - $dispatcher->registerMiddleware($c['RateLimitingMiddleware']); |
|
| 313 | - |
|
| 314 | - foreach($middleWares as $middleWare) { |
|
| 315 | - $dispatcher->registerMiddleware($c[$middleWare]); |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - $dispatcher->registerMiddleware($c['SessionMiddleware']); |
|
| 319 | - return $dispatcher; |
|
| 320 | - }); |
|
| 321 | - |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - /** |
|
| 325 | - * @return \OCP\IServerContainer |
|
| 326 | - */ |
|
| 327 | - public function getServer() |
|
| 328 | - { |
|
| 329 | - return $this->server; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - /** |
|
| 333 | - * @param string $middleWare |
|
| 334 | - * @return boolean|null |
|
| 335 | - */ |
|
| 336 | - public function registerMiddleWare($middleWare) { |
|
| 337 | - $this->middleWares[] = $middleWare; |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * used to return the appname of the set application |
|
| 342 | - * @return string the name of your application |
|
| 343 | - */ |
|
| 344 | - public function getAppName() { |
|
| 345 | - return $this->query('AppName'); |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - /** |
|
| 349 | - * @deprecated use IUserSession->isLoggedIn() |
|
| 350 | - * @return boolean |
|
| 351 | - */ |
|
| 352 | - public function isLoggedIn() { |
|
| 353 | - return \OC::$server->getUserSession()->isLoggedIn(); |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * @deprecated use IGroupManager->isAdmin($userId) |
|
| 358 | - * @return boolean |
|
| 359 | - */ |
|
| 360 | - public function isAdminUser() { |
|
| 361 | - $uid = $this->getUserId(); |
|
| 362 | - return \OC_User::isAdminUser($uid); |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - private function getUserId() { |
|
| 366 | - return $this->getServer()->getSession()->get('user_id'); |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * @deprecated use the ILogger instead |
|
| 371 | - * @param string $message |
|
| 372 | - * @param string $level |
|
| 373 | - * @return mixed |
|
| 374 | - */ |
|
| 375 | - public function log($message, $level) { |
|
| 376 | - switch($level){ |
|
| 377 | - case 'debug': |
|
| 378 | - $level = \OCP\Util::DEBUG; |
|
| 379 | - break; |
|
| 380 | - case 'info': |
|
| 381 | - $level = \OCP\Util::INFO; |
|
| 382 | - break; |
|
| 383 | - case 'warn': |
|
| 384 | - $level = \OCP\Util::WARN; |
|
| 385 | - break; |
|
| 386 | - case 'fatal': |
|
| 387 | - $level = \OCP\Util::FATAL; |
|
| 388 | - break; |
|
| 389 | - default: |
|
| 390 | - $level = \OCP\Util::ERROR; |
|
| 391 | - break; |
|
| 392 | - } |
|
| 393 | - \OCP\Util::writeLog($this->getAppName(), $message, $level); |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - /** |
|
| 397 | - * Register a capability |
|
| 398 | - * |
|
| 399 | - * @param string $serviceName e.g. 'OCA\Files\Capabilities' |
|
| 400 | - */ |
|
| 401 | - public function registerCapability($serviceName) { |
|
| 402 | - $this->query('OC\CapabilitiesManager')->registerCapability(function() use ($serviceName) { |
|
| 403 | - return $this->query($serviceName); |
|
| 404 | - }); |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - /** |
|
| 408 | - * @param string $name |
|
| 409 | - * @return mixed |
|
| 410 | - * @throws QueryException if the query could not be resolved |
|
| 411 | - */ |
|
| 412 | - public function query($name) { |
|
| 413 | - try { |
|
| 414 | - return $this->queryNoFallback($name); |
|
| 415 | - } catch (QueryException $firstException) { |
|
| 416 | - try { |
|
| 417 | - return $this->getServer()->query($name); |
|
| 418 | - } catch (QueryException $secondException) { |
|
| 419 | - if ($firstException->getCode() === 1) { |
|
| 420 | - throw $secondException; |
|
| 421 | - } |
|
| 422 | - throw $firstException; |
|
| 423 | - } |
|
| 424 | - } |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - /** |
|
| 428 | - * @param string $name |
|
| 429 | - * @return mixed |
|
| 430 | - * @throws QueryException if the query could not be resolved |
|
| 431 | - */ |
|
| 432 | - public function queryNoFallback($name) { |
|
| 433 | - $name = $this->sanitizeName($name); |
|
| 434 | - |
|
| 435 | - if ($this->offsetExists($name)) { |
|
| 436 | - return parent::query($name); |
|
| 437 | - } else { |
|
| 438 | - if ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) { |
|
| 439 | - return parent::query($name); |
|
| 440 | - } else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) { |
|
| 441 | - return parent::query($name); |
|
| 442 | - } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) { |
|
| 443 | - return parent::query($name); |
|
| 444 | - } |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - throw new QueryException('Could not resolve ' . $name . '!' . |
|
| 448 | - ' Class can not be instantiated', 1); |
|
| 449 | - } |
|
| 70 | + /** |
|
| 71 | + * @var array |
|
| 72 | + */ |
|
| 73 | + private $middleWares = array(); |
|
| 74 | + |
|
| 75 | + /** @var ServerContainer */ |
|
| 76 | + private $server; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * Put your class dependencies in here |
|
| 80 | + * @param string $appName the name of the app |
|
| 81 | + * @param array $urlParams |
|
| 82 | + * @param ServerContainer|null $server |
|
| 83 | + */ |
|
| 84 | + public function __construct($appName, $urlParams = array(), ServerContainer $server = null){ |
|
| 85 | + parent::__construct(); |
|
| 86 | + $this['AppName'] = $appName; |
|
| 87 | + $this['urlParams'] = $urlParams; |
|
| 88 | + |
|
| 89 | + /** @var \OC\ServerContainer $server */ |
|
| 90 | + if ($server === null) { |
|
| 91 | + $server = \OC::$server; |
|
| 92 | + } |
|
| 93 | + $this->server = $server; |
|
| 94 | + $this->server->registerAppContainer($appName, $this); |
|
| 95 | + |
|
| 96 | + // aliases |
|
| 97 | + $this->registerAlias('appName', 'AppName'); |
|
| 98 | + $this->registerAlias('webRoot', 'WebRoot'); |
|
| 99 | + $this->registerAlias('userId', 'UserId'); |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Core services |
|
| 103 | + */ |
|
| 104 | + $this->registerService(IOutput::class, function($c){ |
|
| 105 | + return new Output($this->getServer()->getWebRoot()); |
|
| 106 | + }); |
|
| 107 | + |
|
| 108 | + $this->registerService(Folder::class, function() { |
|
| 109 | + return $this->getServer()->getUserFolder(); |
|
| 110 | + }); |
|
| 111 | + |
|
| 112 | + $this->registerService(IAppData::class, function (SimpleContainer $c) { |
|
| 113 | + return $this->getServer()->getAppDataDir($c->query('AppName')); |
|
| 114 | + }); |
|
| 115 | + |
|
| 116 | + $this->registerService(IL10N::class, function($c) { |
|
| 117 | + return $this->getServer()->getL10N($c->query('AppName')); |
|
| 118 | + }); |
|
| 119 | + |
|
| 120 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
| 121 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
| 122 | + |
|
| 123 | + $this->registerService(IRequest::class, function() { |
|
| 124 | + return $this->getServer()->query(IRequest::class); |
|
| 125 | + }); |
|
| 126 | + $this->registerAlias('Request', IRequest::class); |
|
| 127 | + |
|
| 128 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
| 129 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
| 130 | + |
|
| 131 | + $this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class); |
|
| 132 | + |
|
| 133 | + $this->registerService(IServerContainer::class, function ($c) { |
|
| 134 | + return $this->getServer(); |
|
| 135 | + }); |
|
| 136 | + $this->registerAlias('ServerContainer', IServerContainer::class); |
|
| 137 | + |
|
| 138 | + $this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) { |
|
| 139 | + return $c->query(Manager::class); |
|
| 140 | + }); |
|
| 141 | + |
|
| 142 | + $this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) { |
|
| 143 | + return $c; |
|
| 144 | + }); |
|
| 145 | + |
|
| 146 | + // commonly used attributes |
|
| 147 | + $this->registerService('UserId', function ($c) { |
|
| 148 | + return $c->query(IUserSession::class)->getSession()->get('user_id'); |
|
| 149 | + }); |
|
| 150 | + |
|
| 151 | + $this->registerService('WebRoot', function ($c) { |
|
| 152 | + return $c->query('ServerContainer')->getWebRoot(); |
|
| 153 | + }); |
|
| 154 | + |
|
| 155 | + $this->registerService('OC_Defaults', function ($c) { |
|
| 156 | + return $c->getServer()->getThemingDefaults(); |
|
| 157 | + }); |
|
| 158 | + |
|
| 159 | + $this->registerService(IManager::class, function ($c) { |
|
| 160 | + return $this->getServer()->getEncryptionManager(); |
|
| 161 | + }); |
|
| 162 | + |
|
| 163 | + $this->registerService(IConfig::class, function ($c) { |
|
| 164 | + return $c->query(OC\GlobalScale\Config::class); |
|
| 165 | + }); |
|
| 166 | + |
|
| 167 | + $this->registerService(IValidator::class, function($c) { |
|
| 168 | + return $c->query(Validator::class); |
|
| 169 | + }); |
|
| 170 | + |
|
| 171 | + $this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) { |
|
| 172 | + return new \OC\Security\IdentityProof\Manager( |
|
| 173 | + $this->getServer()->query(\OC\Files\AppData\Factory::class), |
|
| 174 | + $this->getServer()->getCrypto(), |
|
| 175 | + $this->getServer()->getConfig() |
|
| 176 | + ); |
|
| 177 | + }); |
|
| 178 | + |
|
| 179 | + $this->registerService('Protocol', function($c){ |
|
| 180 | + /** @var \OC\Server $server */ |
|
| 181 | + $server = $c->query('ServerContainer'); |
|
| 182 | + $protocol = $server->getRequest()->getHttpProtocol(); |
|
| 183 | + return new Http($_SERVER, $protocol); |
|
| 184 | + }); |
|
| 185 | + |
|
| 186 | + $this->registerService('Dispatcher', function($c) { |
|
| 187 | + return new Dispatcher( |
|
| 188 | + $c['Protocol'], |
|
| 189 | + $c['MiddlewareDispatcher'], |
|
| 190 | + $c['ControllerMethodReflector'], |
|
| 191 | + $c['Request'] |
|
| 192 | + ); |
|
| 193 | + }); |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * App Framework default arguments |
|
| 197 | + */ |
|
| 198 | + $this->registerParameter('corsMethods', 'PUT, POST, GET, DELETE, PATCH'); |
|
| 199 | + $this->registerParameter('corsAllowedHeaders', 'Authorization, Content-Type, Accept'); |
|
| 200 | + $this->registerParameter('corsMaxAge', 1728000); |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * Middleware |
|
| 204 | + */ |
|
| 205 | + $app = $this; |
|
| 206 | + $this->registerService('SecurityMiddleware', function($c) use ($app){ |
|
| 207 | + /** @var \OC\Server $server */ |
|
| 208 | + $server = $app->getServer(); |
|
| 209 | + |
|
| 210 | + return new SecurityMiddleware( |
|
| 211 | + $c['Request'], |
|
| 212 | + $c['ControllerMethodReflector'], |
|
| 213 | + $server->getNavigationManager(), |
|
| 214 | + $server->getURLGenerator(), |
|
| 215 | + $server->getLogger(), |
|
| 216 | + $c['AppName'], |
|
| 217 | + $server->getUserSession()->isLoggedIn(), |
|
| 218 | + $server->getGroupManager()->isAdmin($this->getUserId()), |
|
| 219 | + $server->getContentSecurityPolicyManager(), |
|
| 220 | + $server->getCsrfTokenManager(), |
|
| 221 | + $server->getContentSecurityPolicyNonceManager(), |
|
| 222 | + $server->getAppManager(), |
|
| 223 | + $server->getL10N('lib') |
|
| 224 | + ); |
|
| 225 | + }); |
|
| 226 | + |
|
| 227 | + $this->registerService(OC\AppFramework\Middleware\Security\PasswordConfirmationMiddleware::class, function ($c) use ($app) { |
|
| 228 | + /** @var \OC\Server $server */ |
|
| 229 | + $server = $app->getServer(); |
|
| 230 | + |
|
| 231 | + return new OC\AppFramework\Middleware\Security\PasswordConfirmationMiddleware( |
|
| 232 | + $c['ControllerMethodReflector'], |
|
| 233 | + $server->getSession(), |
|
| 234 | + $server->getUserSession(), |
|
| 235 | + $server->query(ITimeFactory::class) |
|
| 236 | + ); |
|
| 237 | + }); |
|
| 238 | + |
|
| 239 | + $this->registerService('BruteForceMiddleware', function($c) use ($app) { |
|
| 240 | + /** @var \OC\Server $server */ |
|
| 241 | + $server = $app->getServer(); |
|
| 242 | + |
|
| 243 | + return new OC\AppFramework\Middleware\Security\BruteForceMiddleware( |
|
| 244 | + $c['ControllerMethodReflector'], |
|
| 245 | + $server->getBruteForceThrottler(), |
|
| 246 | + $server->getRequest() |
|
| 247 | + ); |
|
| 248 | + }); |
|
| 249 | + |
|
| 250 | + $this->registerService('RateLimitingMiddleware', function($c) use ($app) { |
|
| 251 | + /** @var \OC\Server $server */ |
|
| 252 | + $server = $app->getServer(); |
|
| 253 | + |
|
| 254 | + return new RateLimitingMiddleware( |
|
| 255 | + $server->getRequest(), |
|
| 256 | + $server->getUserSession(), |
|
| 257 | + $c['ControllerMethodReflector'], |
|
| 258 | + $c->query(OC\Security\RateLimiting\Limiter::class) |
|
| 259 | + ); |
|
| 260 | + }); |
|
| 261 | + |
|
| 262 | + $this->registerService('CORSMiddleware', function($c) { |
|
| 263 | + return new CORSMiddleware( |
|
| 264 | + $c['Request'], |
|
| 265 | + $c['ControllerMethodReflector'], |
|
| 266 | + $c->query(IUserSession::class), |
|
| 267 | + $c->getServer()->getBruteForceThrottler() |
|
| 268 | + ); |
|
| 269 | + }); |
|
| 270 | + |
|
| 271 | + $this->registerService('SessionMiddleware', function($c) use ($app) { |
|
| 272 | + return new SessionMiddleware( |
|
| 273 | + $c['Request'], |
|
| 274 | + $c['ControllerMethodReflector'], |
|
| 275 | + $app->getServer()->getSession() |
|
| 276 | + ); |
|
| 277 | + }); |
|
| 278 | + |
|
| 279 | + $this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) { |
|
| 280 | + $twoFactorManager = $c->getServer()->getTwoFactorAuthManager(); |
|
| 281 | + $userSession = $app->getServer()->getUserSession(); |
|
| 282 | + $session = $app->getServer()->getSession(); |
|
| 283 | + $urlGenerator = $app->getServer()->getURLGenerator(); |
|
| 284 | + $reflector = $c['ControllerMethodReflector']; |
|
| 285 | + $request = $app->getServer()->getRequest(); |
|
| 286 | + return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request); |
|
| 287 | + }); |
|
| 288 | + |
|
| 289 | + $this->registerService('OCSMiddleware', function (SimpleContainer $c) { |
|
| 290 | + return new OCSMiddleware( |
|
| 291 | + $c['Request'] |
|
| 292 | + ); |
|
| 293 | + }); |
|
| 294 | + |
|
| 295 | + $this->registerService(OC\AppFramework\Middleware\Security\SameSiteCookieMiddleware::class, function (SimpleContainer $c) { |
|
| 296 | + return new OC\AppFramework\Middleware\Security\SameSiteCookieMiddleware( |
|
| 297 | + $c['Request'], |
|
| 298 | + $c['ControllerMethodReflector'] |
|
| 299 | + ); |
|
| 300 | + }); |
|
| 301 | + |
|
| 302 | + $middleWares = &$this->middleWares; |
|
| 303 | + $this->registerService('MiddlewareDispatcher', function($c) use (&$middleWares) { |
|
| 304 | + $dispatcher = new MiddlewareDispatcher(); |
|
| 305 | + $dispatcher->registerMiddleware($c[OC\AppFramework\Middleware\Security\SameSiteCookieMiddleware::class]); |
|
| 306 | + $dispatcher->registerMiddleware($c['CORSMiddleware']); |
|
| 307 | + $dispatcher->registerMiddleware($c['OCSMiddleware']); |
|
| 308 | + $dispatcher->registerMiddleware($c['SecurityMiddleware']); |
|
| 309 | + $dispatcher->registerMiddleware($c[OC\AppFramework\Middleware\Security\PasswordConfirmationMiddleware::class]); |
|
| 310 | + $dispatcher->registerMiddleware($c['TwoFactorMiddleware']); |
|
| 311 | + $dispatcher->registerMiddleware($c['BruteForceMiddleware']); |
|
| 312 | + $dispatcher->registerMiddleware($c['RateLimitingMiddleware']); |
|
| 313 | + |
|
| 314 | + foreach($middleWares as $middleWare) { |
|
| 315 | + $dispatcher->registerMiddleware($c[$middleWare]); |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + $dispatcher->registerMiddleware($c['SessionMiddleware']); |
|
| 319 | + return $dispatcher; |
|
| 320 | + }); |
|
| 321 | + |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + /** |
|
| 325 | + * @return \OCP\IServerContainer |
|
| 326 | + */ |
|
| 327 | + public function getServer() |
|
| 328 | + { |
|
| 329 | + return $this->server; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + /** |
|
| 333 | + * @param string $middleWare |
|
| 334 | + * @return boolean|null |
|
| 335 | + */ |
|
| 336 | + public function registerMiddleWare($middleWare) { |
|
| 337 | + $this->middleWares[] = $middleWare; |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * used to return the appname of the set application |
|
| 342 | + * @return string the name of your application |
|
| 343 | + */ |
|
| 344 | + public function getAppName() { |
|
| 345 | + return $this->query('AppName'); |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + /** |
|
| 349 | + * @deprecated use IUserSession->isLoggedIn() |
|
| 350 | + * @return boolean |
|
| 351 | + */ |
|
| 352 | + public function isLoggedIn() { |
|
| 353 | + return \OC::$server->getUserSession()->isLoggedIn(); |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * @deprecated use IGroupManager->isAdmin($userId) |
|
| 358 | + * @return boolean |
|
| 359 | + */ |
|
| 360 | + public function isAdminUser() { |
|
| 361 | + $uid = $this->getUserId(); |
|
| 362 | + return \OC_User::isAdminUser($uid); |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + private function getUserId() { |
|
| 366 | + return $this->getServer()->getSession()->get('user_id'); |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * @deprecated use the ILogger instead |
|
| 371 | + * @param string $message |
|
| 372 | + * @param string $level |
|
| 373 | + * @return mixed |
|
| 374 | + */ |
|
| 375 | + public function log($message, $level) { |
|
| 376 | + switch($level){ |
|
| 377 | + case 'debug': |
|
| 378 | + $level = \OCP\Util::DEBUG; |
|
| 379 | + break; |
|
| 380 | + case 'info': |
|
| 381 | + $level = \OCP\Util::INFO; |
|
| 382 | + break; |
|
| 383 | + case 'warn': |
|
| 384 | + $level = \OCP\Util::WARN; |
|
| 385 | + break; |
|
| 386 | + case 'fatal': |
|
| 387 | + $level = \OCP\Util::FATAL; |
|
| 388 | + break; |
|
| 389 | + default: |
|
| 390 | + $level = \OCP\Util::ERROR; |
|
| 391 | + break; |
|
| 392 | + } |
|
| 393 | + \OCP\Util::writeLog($this->getAppName(), $message, $level); |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + /** |
|
| 397 | + * Register a capability |
|
| 398 | + * |
|
| 399 | + * @param string $serviceName e.g. 'OCA\Files\Capabilities' |
|
| 400 | + */ |
|
| 401 | + public function registerCapability($serviceName) { |
|
| 402 | + $this->query('OC\CapabilitiesManager')->registerCapability(function() use ($serviceName) { |
|
| 403 | + return $this->query($serviceName); |
|
| 404 | + }); |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + /** |
|
| 408 | + * @param string $name |
|
| 409 | + * @return mixed |
|
| 410 | + * @throws QueryException if the query could not be resolved |
|
| 411 | + */ |
|
| 412 | + public function query($name) { |
|
| 413 | + try { |
|
| 414 | + return $this->queryNoFallback($name); |
|
| 415 | + } catch (QueryException $firstException) { |
|
| 416 | + try { |
|
| 417 | + return $this->getServer()->query($name); |
|
| 418 | + } catch (QueryException $secondException) { |
|
| 419 | + if ($firstException->getCode() === 1) { |
|
| 420 | + throw $secondException; |
|
| 421 | + } |
|
| 422 | + throw $firstException; |
|
| 423 | + } |
|
| 424 | + } |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + /** |
|
| 428 | + * @param string $name |
|
| 429 | + * @return mixed |
|
| 430 | + * @throws QueryException if the query could not be resolved |
|
| 431 | + */ |
|
| 432 | + public function queryNoFallback($name) { |
|
| 433 | + $name = $this->sanitizeName($name); |
|
| 434 | + |
|
| 435 | + if ($this->offsetExists($name)) { |
|
| 436 | + return parent::query($name); |
|
| 437 | + } else { |
|
| 438 | + if ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) { |
|
| 439 | + return parent::query($name); |
|
| 440 | + } else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) { |
|
| 441 | + return parent::query($name); |
|
| 442 | + } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) { |
|
| 443 | + return parent::query($name); |
|
| 444 | + } |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + throw new QueryException('Could not resolve ' . $name . '!' . |
|
| 448 | + ' Class can not be instantiated', 1); |
|
| 449 | + } |
|
| 450 | 450 | } |
@@ -39,56 +39,56 @@ |
||
| 39 | 39 | * @package OC\Settings\Middleware |
| 40 | 40 | */ |
| 41 | 41 | class SubadminMiddleware extends Middleware { |
| 42 | - /** @var bool */ |
|
| 43 | - protected $isSubAdmin; |
|
| 44 | - /** @var ControllerMethodReflector */ |
|
| 45 | - protected $reflector; |
|
| 46 | - /** @var IL10N */ |
|
| 47 | - private $l10n; |
|
| 42 | + /** @var bool */ |
|
| 43 | + protected $isSubAdmin; |
|
| 44 | + /** @var ControllerMethodReflector */ |
|
| 45 | + protected $reflector; |
|
| 46 | + /** @var IL10N */ |
|
| 47 | + private $l10n; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @param ControllerMethodReflector $reflector |
|
| 51 | - * @param bool $isSubAdmin |
|
| 52 | - * @param IL10N $l10n |
|
| 53 | - */ |
|
| 54 | - public function __construct(ControllerMethodReflector $reflector, |
|
| 55 | - $isSubAdmin, |
|
| 56 | - IL10N $l10n) { |
|
| 57 | - $this->reflector = $reflector; |
|
| 58 | - $this->isSubAdmin = $isSubAdmin; |
|
| 59 | - $this->l10n = $l10n; |
|
| 60 | - } |
|
| 49 | + /** |
|
| 50 | + * @param ControllerMethodReflector $reflector |
|
| 51 | + * @param bool $isSubAdmin |
|
| 52 | + * @param IL10N $l10n |
|
| 53 | + */ |
|
| 54 | + public function __construct(ControllerMethodReflector $reflector, |
|
| 55 | + $isSubAdmin, |
|
| 56 | + IL10N $l10n) { |
|
| 57 | + $this->reflector = $reflector; |
|
| 58 | + $this->isSubAdmin = $isSubAdmin; |
|
| 59 | + $this->l10n = $l10n; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Check if sharing is enabled before the controllers is executed |
|
| 64 | - * @param Controller $controller |
|
| 65 | - * @param string $methodName |
|
| 66 | - * @throws \Exception |
|
| 67 | - */ |
|
| 68 | - public function beforeController($controller, $methodName) { |
|
| 69 | - if(!$this->reflector->hasAnnotation('NoSubadminRequired')) { |
|
| 70 | - if(!$this->isSubAdmin) { |
|
| 71 | - throw new NotAdminException($this->l10n->t('Logged in user must be a subadmin')); |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - } |
|
| 62 | + /** |
|
| 63 | + * Check if sharing is enabled before the controllers is executed |
|
| 64 | + * @param Controller $controller |
|
| 65 | + * @param string $methodName |
|
| 66 | + * @throws \Exception |
|
| 67 | + */ |
|
| 68 | + public function beforeController($controller, $methodName) { |
|
| 69 | + if(!$this->reflector->hasAnnotation('NoSubadminRequired')) { |
|
| 70 | + if(!$this->isSubAdmin) { |
|
| 71 | + throw new NotAdminException($this->l10n->t('Logged in user must be a subadmin')); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Return 403 page in case of an exception |
|
| 78 | - * @param Controller $controller |
|
| 79 | - * @param string $methodName |
|
| 80 | - * @param \Exception $exception |
|
| 81 | - * @return TemplateResponse |
|
| 82 | - * @throws \Exception |
|
| 83 | - */ |
|
| 84 | - public function afterException($controller, $methodName, \Exception $exception) { |
|
| 85 | - if($exception instanceof NotAdminException) { |
|
| 86 | - $response = new TemplateResponse('core', '403', array(), 'guest'); |
|
| 87 | - $response->setStatus(Http::STATUS_FORBIDDEN); |
|
| 88 | - return $response; |
|
| 89 | - } |
|
| 76 | + /** |
|
| 77 | + * Return 403 page in case of an exception |
|
| 78 | + * @param Controller $controller |
|
| 79 | + * @param string $methodName |
|
| 80 | + * @param \Exception $exception |
|
| 81 | + * @return TemplateResponse |
|
| 82 | + * @throws \Exception |
|
| 83 | + */ |
|
| 84 | + public function afterException($controller, $methodName, \Exception $exception) { |
|
| 85 | + if($exception instanceof NotAdminException) { |
|
| 86 | + $response = new TemplateResponse('core', '403', array(), 'guest'); |
|
| 87 | + $response->setStatus(Http::STATUS_FORBIDDEN); |
|
| 88 | + return $response; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - throw $exception; |
|
| 92 | - } |
|
| 91 | + throw $exception; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | 94 | } |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | * @throws \Exception |
| 67 | 67 | */ |
| 68 | 68 | public function beforeController($controller, $methodName) { |
| 69 | - if(!$this->reflector->hasAnnotation('NoSubadminRequired')) { |
|
| 70 | - if(!$this->isSubAdmin) { |
|
| 69 | + if (!$this->reflector->hasAnnotation('NoSubadminRequired')) { |
|
| 70 | + if (!$this->isSubAdmin) { |
|
| 71 | 71 | throw new NotAdminException($this->l10n->t('Logged in user must be a subadmin')); |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @throws \Exception |
| 83 | 83 | */ |
| 84 | 84 | public function afterException($controller, $methodName, \Exception $exception) { |
| 85 | - if($exception instanceof NotAdminException) { |
|
| 85 | + if ($exception instanceof NotAdminException) { |
|
| 86 | 86 | $response = new TemplateResponse('core', '403', array(), 'guest'); |
| 87 | 87 | $response->setStatus(Http::STATUS_FORBIDDEN); |
| 88 | 88 | return $response; |