Skip to content

Commit

Permalink
Allow registration and authentication without notificationAddress or …
Browse files Browse the repository at this point in the history
…notificationType being present
  • Loading branch information
pmeulen committed Aug 5, 2024
1 parent f8b9aac commit b4b01ab
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dev/Command/AuthenticationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'sessionKey' => $session,
'userId' => $userId,
'response' => $response,
'notificationType' => $input->getOption('notificationType'),
'notificationAddress' => $input->getOption('notificationAddress'),
'notificationType' => $input->getOption('notificationType', ''),
'notificationAddress' => $input->getOption('notificationAddress', ''),
];

$output->writeln([
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/TiqrAppApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public function tiqr(UserAgentMatcherInterface $userAgentMatcher, Request $reque
return new Response('Missing "operation" parameter in POST', Response::HTTP_BAD_REQUEST);
}

$notificationType = $request->get('notificationType');
$notificationAddress = $request->get('notificationAddress');
$notificationType = $request->get('notificationType', '');
$notificationAddress = $request->get('notificationAddress', '');
if ($operation === 'register') {
$this->logger->notice(
'Got POST with registration response',
Expand Down
12 changes: 12 additions & 0 deletions src/Features/Context/TiqrContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ public function userRegisterTheService(
'notificationType' => $notificationType,
'notificationAddress' => $notificationAddress,
];
if ($notificationType == 'NULL') {
unset($registrationBody['notificationType']);
}
if ($notificationAddress == 'NULL') {
unset($registrationBody['notificationAddress']);
}

$client = $this->minkContext->getSession()->getDriver()->getClient();
$client->request(
Expand Down Expand Up @@ -221,6 +227,12 @@ public function appAuthenticates(
'notificationType' => $notificationType,
'notificationAddress' => $notificationAddress,
];
if ($notificationType == 'NULL') {
unset($authenticationBody['notificationType']);
}
if ($notificationAddress == 'NULL') {
unset($authenticationBody['notificationAddress']);
}
// Internal request does not like an absolute path.
$authenticationUrl = str_replace('https://tiqr.dev.openconext.local', '', (string) $authenticationUrl);

Expand Down
5 changes: 5 additions & 0 deletions src/Features/tiqrAuthentication.feature
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,8 @@ Feature: User
# Try it with the actual correct password
And the app authenticates to the service
Then we have the authentication error 'ACCOUNT_BLOCKED'

Scenario: The app authenticats whithout updating notification address
Given the authentication QR code is scanned
When the app authenticates to the service with notification type "NULL" address: "NULL"
Then we have a authenticated user
5 changes: 5 additions & 0 deletions src/Features/tiqrRegistration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ Feature: User
And the mobile tiqr app identifies itself with the user agent "Bad UA"
When the user registers the service
Then tiqr errors with a message telling the user agent was wrong

Scenario: Registration without notification type and address is allowed
Given the registration QR code is scanned
When the user registers the service with notification type "NULL" address: "NULL"
Then we have a registered user

0 comments on commit b4b01ab

Please sign in to comment.