bitwarden / passwordless-server

Bitwarden Passwordless.dev infrastructure/backend (API, database, Docker, etc).
https://bitwarden.com/
Other
86 stars 28 forks source link

PAS-552 | CurrentUserCount no longer updating #664

Closed jonashendrickx closed 3 months ago

jonashendrickx commented 3 months ago

Ticket

Description

The CurrentUserCount was no longer being updated in the Applications table of the admin console. This was happening because we listen to the OnSignedIn callback, where we are successfully able to listen when an admin signs in and execute custom code to perform certain actions, such as updating and caching the amount of users.

The caching of the amount of users was running on a background job half a year ago which was running every few hours, but was causing an unnecessary amount of network traffic.

We injected an object which is responsible for handling any post signin events, but it turns out the ClaimsPrincipal is not signed in inside this handler, although the ClaimsPrincipal is signed in inside theConfigureApplicationCookiemethod inProgram.css`.

We pass the OrganizationId for now as a parameter to the handler.

Shape

Screenshots

Checklist

I did the following to ensure that my changes were tested thoroughly:

I did the following to ensure that my changes do not introduce security vulnerabilities:

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Project coverage is 34.84%. Comparing base (7f72d2f) to head (153af7d).

Files Patch % Lines
src/AdminConsole/Program.cs 0.00% 9 Missing :warning:
.../AdminConsole/Services/PostSignInHandlerService.cs 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #664 +/- ## ======================================= Coverage 34.84% 34.84% ======================================= Files 565 565 Lines 30901 30900 -1 Branches 922 921 -1 ======================================= Hits 10768 10768 + Misses 19990 19989 -1 Partials 143 143 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.