Skip to content

Commit

Permalink
Merge pull request #35 from ibexa/temp_1.3_to_4.1
Browse files Browse the repository at this point in the history
Merge branch '1.3' of ezsystems/ezplatform-rest into 4.1
  • Loading branch information
ViniTou authored Jun 2, 2022
2 parents e56816f + 5b6c483 commit 9937f76
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ jobs:
run: composer test
integration-tests:
name: "REST integration tests"
uses: ./.github/workflows/integration-tests-callable.yaml@4.1
uses: ./.github/workflows/integration-tests-callable.yaml
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true
}
},
"process-timeout": 600
},
"scripts": {
"fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots",
Expand Down
4 changes: 0 additions & 4 deletions src/bundle/Resources/config/default_settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,3 @@ parameters:
createToken:
mediaType: 'JWT'
href: 'router.generate("ibexa.rest.create_token")'

# Boundary times in microseconds which the authentication check will be delayed by.
ibexa.rest.authentication_min_delay_time: 30000
ibexa.rest.authentication_max_delay_time: 500000
2 changes: 0 additions & 2 deletions src/bundle/Resources/config/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ services:
- "@event_dispatcher"
- '@ibexa.config.resolver'
- "@?logger"
- "%ibexa.rest.authentication_min_delay_time%"
- "%ibexa.rest.authentication_max_delay_time%"
abstract: true

Ibexa\Rest\Server\Security\RestLogoutHandler:
Expand Down
22 changes: 1 addition & 21 deletions src/lib/Server/Security/RestAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
*/
class RestAuthenticator implements AuthenticatorInterface
{
private const DEFAULT_MIN_SLEEP_VALUE = 30000;

private const DEFAULT_MAX_SLEEP_VALUE = 500000;

/**
* @var \Psr\Log\LoggerInterface
*/
Expand Down Expand Up @@ -73,34 +69,20 @@ class RestAuthenticator implements AuthenticatorInterface
*/
private $logoutHandlers = [];

/**
* @var int|null
*/
private $minSleepTime;

/**
* @var int|null
*/
private $maxSleepTime;

public function __construct(
TokenStorageInterface $tokenStorage,
AuthenticationManagerInterface $authenticationManager,
$providerKey,
EventDispatcherInterface $dispatcher,
ConfigResolverInterface $configResolver,
LoggerInterface $logger = null,
$minSleepTime = self::DEFAULT_MIN_SLEEP_VALUE,
$maxSleepTime = self::DEFAULT_MAX_SLEEP_VALUE
LoggerInterface $logger = null
) {
$this->tokenStorage = $tokenStorage;
$this->authenticationManager = $authenticationManager;
$this->providerKey = $providerKey;
$this->dispatcher = $dispatcher;
$this->configResolver = $configResolver;
$this->logger = $logger;
$this->minSleepTime = !is_int($minSleepTime) ? self::DEFAULT_MIN_SLEEP_VALUE : $minSleepTime;
$this->maxSleepTime = !is_int($maxSleepTime) ? self::DEFAULT_MAX_SLEEP_VALUE : $maxSleepTime;
}

/**
Expand All @@ -115,8 +97,6 @@ public function __invoke(RequestEvent $event)

public function authenticate(Request $request)
{
usleep(random_int($this->minSleepTime, $this->maxSleepTime));

// If a token already exists and username is the same as the one we request authentication for,
// then return it and mark it as coming from session.
$previousToken = $this->tokenStorage->getToken();
Expand Down

0 comments on commit 9937f76

Please sign in to comment.