Skip to content

Commit

Permalink
Add event codes for tracking one login creation/migration events (#2541)
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperaj authored Mar 11, 2024
1 parent 1314127 commit d6e9489
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
10 changes: 10 additions & 0 deletions service-api/app/src/App/src/Service/Log/EventCodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,14 @@ class EventCodes
* Activation key request is successful for partial match LPA type pfa
*/
public const PARTIAL_MATCH_KEY_REQUEST_SUCCESS_LPA_TYPE_PFA = 'PARTIAL_MATCH_KEY_REQUEST_SUCCESS_LPA_TYPE_PFA';

/**
* A one login authentication transaction resulted in a username/password account being migrated.
*/
public const AUTH_ONELOGIN_ACCOUNT_MIGRATED = 'AUTH_ONELOGIN_ACCOUNT_MIGRATED';

/**
* A one login authentication transaction resulted in a new local account being created.
*/
public const AUTH_ONELOGIN_ACCOUNT_CREATED = 'AUTH_ONELOGIN_ACCOUNT_CREATED';
}
11 changes: 7 additions & 4 deletions service-api/app/src/App/src/Service/User/ResolveOAuthUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Service\User;

use App\DataAccess\Repository\ActorUsersInterface;
use App\Service\Log\EventCodes;
use App\Exception\{ConflictException, CreationException, DateTimeException, NotFoundException, RandomException};
use App\Service\Log\Output\Email;
use DateTimeInterface;
Expand Down Expand Up @@ -116,8 +117,9 @@ public function attemptToFetchUserByEmail(string $identity, string $email): ?arr
$this->logger->info(
'Migrated existing account with email {email} to OIDC login',
[
'identity' => $identity,
'email' => new Email($email),
'identity' => $identity,
'email' => new Email($email),
'event_code' => EventCodes::AUTH_ONELOGIN_ACCOUNT_MIGRATED,
]
);
} catch (NotFoundException) {
Expand All @@ -142,8 +144,9 @@ public function addNewUser(string $identity, string $email): array
$this->logger->info(
'Created new OIDC login for account with email {email}',
[
'identity' => $identity,
'email' => new Email($email),
'identity' => $identity,
'email' => new Email($email),
'event_code' => EventCodes::AUTH_ONELOGIN_ACCOUNT_CREATED,
]
);

Expand Down
2 changes: 2 additions & 0 deletions terraform/environment/region/cloudwatch_metrics.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ locals {
"event_code.PARTIAL_MATCH_KEY_REQUEST_SUCCESS_LPA_TYPE_HW",
"event_code.PARTIAL_MATCH_KEY_REQUEST_SUCCESS_LPA_TYPE_PFA",
"event_code.ACTIVATION_KEY_REQUEST_REPLACEMENT_ATTORNEY",
"event_code.AUTH_ONELOGIN_ACCOUNT_MIGRATED",
"event_code.AUTH_ONELOGIN_ACCOUNT_CREATED",
]
}

Expand Down

0 comments on commit d6e9489

Please sign in to comment.