Skip to content

Commit

Permalink
Prevent remote vetting of expired tokens
Browse files Browse the repository at this point in the history
Only non expired tokens could be remote vetted. This wasn't fixed
earlier because it came in handy during development.
  • Loading branch information
pablothedude committed Mar 23, 2020
1 parent 39b3457 commit 68e2cad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/config/remote_vetting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ services:
arguments:
- '@Surfnet\StepupSelfService\SelfServiceBundle\Service\RemoteVettingService'
- '@Surfnet\StepupSelfService\SelfServiceBundle\Service\RemoteVetting\SamlCalloutHelper'
- '@surfnet_stepup.registration_expiration_helper'
- '@logger'

Surfnet\StepupSelfService\SelfServiceBundle\Mock\RemoteVetting\MockConfiguration:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Psr\Log\LoggerInterface;
use SAML2\Response\Exception\PreconditionNotMetException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Surfnet\StepupBundle\DateTime\RegistrationExpirationHelper;
use Surfnet\StepupSelfService\SelfServiceBundle\Command\RemoteVetCommand;
use Surfnet\StepupSelfService\SelfServiceBundle\Command\RemoteVetValidationCommand;
use Surfnet\StepupSelfService\SelfServiceBundle\Exception\InvalidRemoteVettingContextException;
Expand Down Expand Up @@ -58,14 +59,20 @@ class RemoteVettingController extends Controller
* @var LoggerInterface
*/
private $logger;
/**
* @var RegistrationExpirationHelper
*/
private $expirationHelper;

public function __construct(
RemoteVettingService $remoteVettingService,
SamlCalloutHelper $samlCalloutHelper,
RegistrationExpirationHelper $expirationHelper,
LoggerInterface $logger
) {
$this->remoteVettingService = $remoteVettingService;
$this->samlCalloutHelper = $samlCalloutHelper;
$this->expirationHelper = $expirationHelper;
$this->logger = $logger;
}

Expand Down Expand Up @@ -93,14 +100,12 @@ public function remoteVetAction(Request $request, $secondFactorId, $identityProv
}

$secondFactor = $service->findOneVerified($secondFactorId);
if ($secondFactor === null) {
if ($secondFactor === null || $this->expirationHelper->hasExpired($secondFactor->registrationRequestedAt)) {
throw new NotFoundHttpException(
sprintf("No %s second factor with id '%s' exists.", 'verified', $secondFactorId)
);
}

// todo: validate expired

$command = new RemoteVetCommand();
$command->identity = $identity;
$command->secondFactor = $secondFactor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
{% endif %}
<td>
<div class="btn-group pull-right" role="group">
{% if state == 'verified' %}
{% if state == 'verified' and not expirationHelper.hasExpired(secondFactor.registrationRequestedAt) %}
<a class="btn btn-mini btn-default"
href="{{ path('ss_second_factor_remote_vetting_types', {'secondFactorId': secondFactor.id}) }}">
{{ 'ss.second_factor.revoke.button.remote_vet'|trans }}
Expand Down

0 comments on commit 68e2cad

Please sign in to comment.