Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support EXT:staticfilecache #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Classes/EventListener/DisableStaticFileCacheEventListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);

namespace Lemming\Httpbasicauth\EventListener;

use Lemming\Httpbasicauth\Middleware\BasicAuth;
use SFC\Staticfilecache\Event\CacheRuleEvent;

class DisableStaticFileCacheEventListener
{
public function __invoke(CacheRuleEvent $event): void
{
if ($event->getRequest()->getAttribute(BasicAuth::IS_ENABLED, false)) {
$event->setSkipProcessing(true);
$event->addExplanation(__CLASS__, 'Basic Authentication is enabled for current site');
}
}
}
4 changes: 4 additions & 0 deletions Classes/Middleware/BasicAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

class BasicAuth implements MiddlewareInterface
{
public const IS_ENABLED = 'BasicAuthenticationIsEnabled';

/**
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
Expand All @@ -34,6 +36,8 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
return $handler->handle($request);
}

$request = $request->withAttribute(self::IS_ENABLED, true);

if ($site->getAttribute('basicauth_allow_devipmask')) {
$clientIPMatchesDevelopmentSystem = GeneralUtility::cmpIP(GeneralUtility::getIndpEnv('REMOTE_ADDR'),
$GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']);
Expand Down
14 changes: 14 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: false

Lemming\Httpbasicauth\:
resource: '../Classes/*'

Lemming\Httpbasicauth\EventListener\DisableStaticFileCacheEventListener:
tags:
- name: event.listener
identifier: 'HTTPBasicAuthDisableStaticFileCacheEventListener'
event: SFC\Staticfilecache\Event\CacheRuleEvent