diff --git a/assets/typescript/Client/StatusClient.ts b/assets/typescript/Client/StatusClient.ts index a9babc3e..90d70ffc 100644 --- a/assets/typescript/Client/StatusClient.ts +++ b/assets/typescript/Client/StatusClient.ts @@ -5,14 +5,17 @@ export interface PendingRequest { } export class StatusClient { - constructor(private apiUrl: string) { - + constructor( + private apiUrl: string, + private correlationLoggingId: string, + ) { } /** * Request status form the API. */ public request(callback: (status: string) => void, errorCallback: (error: unknown) => void): PendingRequest { - return jQuery.get(this.apiUrl, callback).fail(errorCallback); + console.log(this.correlationLoggingId); + return jQuery.get(this.apiUrl + '?correlation-id=' + this.correlationLoggingId, callback).fail(errorCallback); } } diff --git a/assets/typescript/authentication.ts b/assets/typescript/authentication.ts index b38e13ed..e56e8751 100644 --- a/assets/typescript/authentication.ts +++ b/assets/typescript/authentication.ts @@ -8,12 +8,12 @@ import jQuery from 'jquery'; declare global { interface Window { - bootstrapAuthentication: (statusApiUrl: string, notificationApiUrl: string) => AuthenticationPageService; + bootstrapAuthentication: (statusApiUrl: string, notificationApiUrl: string, correlationLoggingId: string) => AuthenticationPageService; } } -window.bootstrapAuthentication = (statusApiUrl: string, notificationApiUrl: string) => { - const statusClient = new StatusClient(statusApiUrl); +window.bootstrapAuthentication = (statusApiUrl: string, notificationApiUrl: string, correlationLoggingId: string) => { + const statusClient = new StatusClient(statusApiUrl, correlationLoggingId); const notificationClient = new NotificationClient(notificationApiUrl); const pollingService = new StatusPollService(statusClient); diff --git a/assets/typescript/registration.ts b/assets/typescript/registration.ts index 98328d19..9588762c 100644 --- a/assets/typescript/registration.ts +++ b/assets/typescript/registration.ts @@ -7,12 +7,16 @@ import jQuery from 'jquery'; declare global { interface Window { - bootstrapRegistration: (statusApiUrl: string, notificationApiUrl: string) => RegistrationStateMachine; + bootstrapRegistration: ( + statusApiUrl: string, + notificationApiUrl: string, + correlationLoggingId: string + ) => RegistrationStateMachine; } } -window.bootstrapRegistration = (statusApiUrl: string, finalizedUrl: string) => { - const statusClient = new StatusClient(statusApiUrl); +window.bootstrapRegistration = (statusApiUrl: string, finalizedUrl: string, correlationLoggingId: string) => { + const statusClient = new StatusClient(statusApiUrl, correlationLoggingId); const pollingService = new StatusPollService(statusClient); const machine = new RegistrationStateMachine( pollingService, diff --git a/src/Controller/AuthenticationController.php b/src/Controller/AuthenticationController.php index 79bfd9f0..5eb2a5b8 100644 --- a/src/Controller/AuthenticationController.php +++ b/src/Controller/AuthenticationController.php @@ -29,6 +29,7 @@ use Surfnet\Tiqr\Exception\UserNotFoundException; use Surfnet\Tiqr\Exception\UserPermanentlyBlockedException; use Surfnet\Tiqr\Exception\UserTemporarilyBlockedException; +use Surfnet\Tiqr\Service\SessionCorrelationIdService; use Surfnet\Tiqr\Tiqr\AuthenticationRateLimitServiceInterface; use Surfnet\Tiqr\Tiqr\Exception\UserNotExistsException; use Surfnet\Tiqr\Tiqr\Response\AuthenticationResponse; @@ -53,6 +54,7 @@ public function __construct( private readonly TiqrServiceInterface $tiqrService, private readonly TiqrUserRepositoryInterface $userRepository, private readonly AuthenticationRateLimitServiceInterface $authenticationRateLimitService, + private readonly SessionCorrelationIdService $correlationIdService, private readonly LoggerInterface $logger ) { } @@ -145,8 +147,8 @@ public function __invoke(Request $request): Response $logger->info('Return authentication page with QR code'); return $this->render('default/authentication.html.twig', [ - // TODO: Add something identifying the authentication session to the authenticateUrl - 'authenticateUrl' => $this->tiqrService->authenticationUrl() + 'authenticateUrl' => $this->tiqrService->authenticationUrl(), + 'correlationLoggingId' => $this->correlationIdService->generateCorrelationId(), ]); } diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index 67f0a3ba..69f7b1ad 100644 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -25,6 +25,7 @@ use Surfnet\GsspBundle\Service\StateHandlerInterface; use Surfnet\Tiqr\Attribute\RequiresActiveSession; use Surfnet\Tiqr\Exception\NoActiveAuthenrequestException; +use Surfnet\Tiqr\Service\SessionCorrelationIdService; use Surfnet\Tiqr\Tiqr\Legacy\TiqrService; use Surfnet\Tiqr\Tiqr\TiqrServiceInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -38,6 +39,7 @@ public function __construct( private readonly RegistrationService $registrationService, private readonly StateHandlerInterface $stateHandler, private readonly TiqrServiceInterface $tiqrService, + private readonly SessionCorrelationIdService $correlationIdService, private readonly LoggerInterface $logger ) { } @@ -81,6 +83,7 @@ public function registration(Request $request): Response 'default/registration.html.twig', [ 'metadataUrl' => sprintf("tiqrenroll://%s", $metadataUrl), + 'correlationLoggingId' => $this->correlationIdService->generateCorrelationId(), 'enrollmentKey' => $key ] ); diff --git a/templates/default/authentication.html.twig b/templates/default/authentication.html.twig index 0cd8feac..04a64d68 100644 --- a/templates/default/authentication.html.twig +++ b/templates/default/authentication.html.twig @@ -16,7 +16,8 @@ */ var authenticationPageService = window.bootstrapAuthentication( "{{ path('app_identity_authentication_status') | escape('js') }}", - "{{ path('app_identity_authentication_notification') | escape('js') }}" + "{{ path('app_identity_authentication_notification') | escape('js') }}", + "{{ correlationLoggingId }}" ); {% endblock %} diff --git a/templates/default/registration.html.twig b/templates/default/registration.html.twig index 4bef79de..f04d8320 100644 --- a/templates/default/registration.html.twig +++ b/templates/default/registration.html.twig @@ -13,7 +13,8 @@ {% endblock %}