Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
feat: remove OpenAM logic (#101)
Browse files Browse the repository at this point in the history
* refactor: remove OpenAM logic and some SA fixes.

* refactor: remove unused config

* chore: bump `olcs-auth` to `v7.0`

---------

Co-authored-by: JoshuaLicense <JoshuaLicense@users.noreply.github.com>
  • Loading branch information
fibble and JoshuaLicense authored Mar 19, 2024
1 parent 624a082 commit 899237e
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"laminas/laminas-validator": "^2.25",
"laminas/laminas-view": "^2.11",
"lm-commons/lmc-rbac-mvc": "^3.3",
"olcs/olcs-auth": "^6.0.0",
"olcs/olcs-auth": "^7.0",
"olcs/olcs-common": "^6.0.0",
"olcs/olcs-logging": "^6.0.0",
"olcs/olcs-transfer": "^6.0.0",
Expand Down
17 changes: 9 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions config/autoload/config.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,6 @@

// Asset path, URI to olcs-static (CSS, JS, etc] *Environment specific*
'asset_path' => '/static/public',

'openam' => [
'url' => 'http://ssauth.%domain%:8080/secure/',
'realm' => 'selfserve',//@deprecated
'cookie' => [
'domain' => '%olcs_ss_cookie%',
]
],
'cookie-manager' => [
'delete-undefined-cookies' => true,
'user-preference-cookie-name' => 'cookie_policy',
Expand Down
1 change: 0 additions & 1 deletion module/Olcs/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,6 @@
],
'invokables' => [
'generatePeopleList' => \Olcs\View\Helper\GeneratePeopleList::class,
'tmCheckAnswersChangeLink' => \Olcs\View\Helper\TmCheckAnswersChangeLink::class,
]
],
'view_manager' => [
Expand Down
11 changes: 1 addition & 10 deletions module/Olcs/src/Controller/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class LoginController
public const ROUTE_AUTH_EXPIRED_PASSWORD = 'auth/expired-password';
public const ROUTE_AUTH_LOGIN_GET = 'auth/login/GET';
public const ROUTE_INDEX = 'index';
public const DVSA_OLCS_AUTH_CLIENT_OPENAM = 'Dvsa\Olcs\Auth\Client\OpenAm';
public const CHALLENGE_NEW_PASSWORD_REQUIRED = 'NEW_PASSWORD_REQUIRED';
public const DVSA_OLCS_AUTH_CLIENT_COGNITO = 'Dvsa\Olcs\Auth\Client\CognitoAdapter';

Expand Down Expand Up @@ -259,9 +258,7 @@ private function handleChallengeResult(array $messages): Response
case AuthChallengeContainer::CHALLENEGE_NEW_PASWORD_REQUIRED:
$this->applyAuthChallengeContainer($messages);
return $this->redirectHelper->toRoute(
self::ROUTE_AUTH_EXPIRED_PASSWORD,
$messages['challengeParameters'] // TODO: Remove passing this in once OpenAM removed
);
self::ROUTE_AUTH_EXPIRED_PASSWORD);
default:
// Unsupported challenge so redirect to login page
Logger::warn('Received unexpected challenge from AWS Cognito', $messages);
Expand All @@ -274,12 +271,6 @@ private function handleChallengeResult(array $messages): Response
*/
private function applyAuthChallengeContainer(array $messages): void
{
// OpenAM this key won't exist so we skip adding into session
// TODO: Remove this check once OpenAM is removed
if (!array_key_exists('USER_ID_FOR_SRP', $messages['challengeParameters'])) {
return;
}

$this->authChallengeContainer
->setChallengeName($messages['challengeName'])
->setChallengeSession($messages['challengeSession'])
Expand Down
2 changes: 1 addition & 1 deletion module/Olcs/src/Controller/Initializer/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Olcs\Controller\Initializer;

use Dvsa\Olcs\Auth\Controller\LoginController;
use Olcs\Controller\Auth\LoginController;
use Psr\Container\ContainerInterface;
use Laminas\Mvc\MvcEvent;
use Laminas\ServiceManager\Initializer\InitializerInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ protected function getContent(): string
if ($this->hasInformationChanged()) {
return 'markup-licence-surrender-information-changed-content-changed';
}
return '';
}

public function alterForm($form)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Laminas\Form\Form;
use Laminas\Http\Request;
use Laminas\Http\Response;
use Laminas\Mvc\Controller\Plugin\FlashMessenger;
use Laminas\Mvc\Plugin\FlashMessenger\FlashMessenger;
use Laminas\Router\RouteMatch;
use Laminas\View\Model\ViewModel;
use Olcs\DTO\Licence\OtherActiveLicenceListDTO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ abstract class AbstractUploadEvidenceController extends AbstractController

protected string $location = 'external';

protected $operatingCentreId;

/**
* Data from API
* @var array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ConditionsUndertakingsController extends Lva\AbstractController

protected $lva = 'licence';
protected string $location = 'external';
protected $lvaAdapter;

protected LicenceConditionsUndertakingsReviewService $licenceConditionsUndertakingsReviewSvc;
protected GuidanceHelperService $guidanceHelper;
Expand Down
5 changes: 4 additions & 1 deletion module/Olcs/src/Service/Cookie/CookieState.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@

class CookieState
{
protected bool $isValid;
protected ?Preferences $preferences;

/**
* Create instance
*
* @param bool $isValid
* @param Preferences|null $preferences
*
* @return CookieState
* @return void
*/
public function __construct($isValid, ?Preferences $preferences = null)
{
Expand Down
3 changes: 3 additions & 0 deletions module/Olcs/src/Service/Qa/TemplateVarsGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

class TemplateVarsGenerator
{
protected QuestionArrayProvider $questionArrayProvider;
protected GuidanceTemplateVarsAdder $guidanceTemplateVarsAdder;

/**
* Create service instance
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Olcs\View\Helper\SessionTimeoutWarning;

use Psr\Container\ContainerInterface;
use Laminas\ServiceManager\factory\FactoryInterface;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Laminas\View\Helper\HeadMeta;

class SessionTimeoutWarningFactory implements FactoryInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Permits\Controller\Config\DataSource;

use Dvsa\Olcs\Transfer\Query\Permits\ById as PermitApplicationDto;
use Dvsa\Olcs\Transfer\Query\IrhpApplication\ById as PermitApplicationDto;
use Olcs\Controller\Config\DataSource\AbstractDataSource;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class IrhpApplicationFeeController extends AbstractSelfserveController
use GenericReceipt;
use FlashMessengerTrait;

protected $lva;

private const FEE_BREAKDOWN_TABLES = [
RefData::IRHP_BILATERAL_PERMIT_TYPE_ID => 'irhp-fee-breakdown-bilateral',
RefData::IRHP_MULTILATERAL_PERMIT_TYPE_ID => 'irhp-fee-breakdown-multilateral',
Expand Down Expand Up @@ -275,4 +277,8 @@ public function retrieveData()
->get(IrhpApplicationFeeSummary::class)
->mapForDisplay($this->data);
}

protected function checkForRedirect($lvaId) {
return null;
}
}
6 changes: 6 additions & 0 deletions module/Permits/src/Permits/Controller/PermitsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class PermitsController extends AbstractSelfserveController

protected $currentMessages = [];

protected $lva;

/**
* @todo This is just a placeholder, this will be implemented properly using system parameters in OLCS-20848
*
Expand Down Expand Up @@ -189,4 +191,8 @@ private function referredFromGovUkPermits(MvcEvent $e): bool

return in_array($referer->getUri(), $this->govUkReferrers);
}

protected function checkForRedirect($lvaId) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public function __invoke_ReturnsAnInstanceOfDispatcherWithLoginController()
$serviceManager->method('get')->willReturnMap([
[SelfserveCommandAdapter::class, $this->createMock(SelfserveCommandAdapter::class)],
[AuthenticationServiceInterface::class , $this->createMock(AuthenticationServiceInterface::class)],
['Auth\CookieService', $this->createMock(CookieService::class)],
[CurrentUser::class, $this->createMock(CurrentUser::class)],
[FlashMessenger::class, $this->createMock(FlashMessenger::class)],
[FormHelperService::class, $this->createMock(FormHelperService::class)],
Expand Down
5 changes: 1 addition & 4 deletions test/Olcs/src/Controller/Auth/LoginControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@
use Common\Rbac\User;
use Common\Service\Helper\FormHelperService;
use Dvsa\Olcs\Auth\Container\AuthChallengeContainer;
use Interop\Container\Containerinterface;
use Laminas\Authentication\Result;
use Laminas\Form\Annotation\AnnotationBuilder;
use Laminas\Form\Form;
use Laminas\Http\Request;
use Laminas\Http\Response;
use Laminas\Http\Response as HttpResponse;
use Laminas\Mvc\Controller\PluginManager;
use Laminas\Mvc\Plugin\FlashMessenger\FlashMessenger;
use Laminas\Router\Http\RouteMatch;
use Laminas\Stdlib\Parameters;
use Laminas\View\Model\ViewModel;
use Mockery as m;
use Mockery\Adapter\Phpunit\MockeryTestCase;
use Mockery\MockInterface;
use Olcs\Auth\Adapter\SelfserveCommandAdapter;
use Olcs\Controller\Auth\LoginController;
use Olcs\Form\Model\Form\Auth\Login;
Expand Down Expand Up @@ -411,7 +408,7 @@ public function postAction_NewPasswordRequiredChallenge_RedirectsToExpiredPasswo
$this->authenticationAdapterMock->allows('setCredential')->andReturn($this->identity())->byDefault();

// Expect
$this->redirectHelperMock->expects()->toRoute(LoginController::ROUTE_AUTH_EXPIRED_PASSWORD, ['USER_ID_FOR_SRP' => 'username'])->andReturn($this->redirect());
$this->redirectHelperMock->expects()->toRoute(LoginController::ROUTE_AUTH_EXPIRED_PASSWORD)->andReturn($this->redirect());

// Execute
$this->sut->postAction($request, new RouteMatch([]), new Response());
Expand Down
2 changes: 1 addition & 1 deletion test/Olcs/src/Controller/Initializer/NavigationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace OlcsTest\Controller\Initializer;

use Common\Controller\AbstractOlcsController;
use Dvsa\Olcs\Auth\Controller\LoginController;
use Olcs\Controller\Auth\LoginController;
use Psr\Container\ContainerInterface;
use Laminas\Mvc\MvcEvent;
use Olcs\Controller\Initializer\Navigation as NavigationInitializer;
Expand Down

0 comments on commit 899237e

Please sign in to comment.