Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(active-user-state-refactor): [PM-12040] Remove ActiveUserSta… #13149

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Patrick-Pimentel-Bitwarden
Copy link
Contributor

@Patrick-Pimentel-Bitwarden Patrick-Pimentel-Bitwarden commented Jan 29, 2025

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-12040

📔 Objective

Update the SSO Login Service to use SingleUserState instead of deprecated ActiveUserState.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

…te from SSO Service - First pass of work to update the state. In the middle of testing.
…om SSO Service - Fix for jslib-services.module.ts
Copy link
Contributor

github-actions bot commented Jan 29, 2025

Logo
Checkmarx One – Scan Summary & Details2c51086c-7405-4c99-85cc-997aefb56cc8

New Issues (4)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
HIGH CVE-2024-21538 Npm-cross-spawn-7.0.3 Vulnerable Package
MEDIUM CVE-2024-55565 Npm-nanoid-3.3.7 Vulnerable Package
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/critical-applications.component.html: 87
detailsMethod critical_applications_component at line 87 of /bitwarden_license/bit-web/src/app/tools/access-intelligence/critical-applications.component.h...
Attack Vector
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/critical-applications.component.html: 82
detailsMethod critical_applications_component at line 82 of /bitwarden_license/bit-web/src/app/tools/access-intelligence/critical-applications.component.h...
Attack Vector

Copy link

codecov bot commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 15 lines in your changes missing coverage. Please review.

Project coverage is 35.51%. Comparing base (4b45029) to head (56f977f).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...ular/src/auth/components/set-password.component.ts 0.00% 7 Missing ⚠️
libs/auth/src/angular/sso/sso.component.ts 0.00% 2 Missing ⚠️
apps/browser/src/background/main.background.ts 0.00% 1 Missing ⚠️
...ents/base-login-decryption-options-v1.component.ts 0.00% 1 Missing ⚠️
libs/angular/src/auth/components/sso.component.ts 50.00% 1 Missing ⚠️
...nents/two-factor-auth/two-factor-auth.component.ts 50.00% 1 Missing ⚠️
...ngular/src/auth/components/two-factor.component.ts 50.00% 1 Missing ⚠️
...tion-options/login-decryption-options.component.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13149      +/-   ##
==========================================
+ Coverage   35.38%   35.51%   +0.13%     
==========================================
  Files        3010     3007       -3     
  Lines       91152    90879     -273     
  Branches    16985    16909      -76     
==========================================
+ Hits        32254    32277      +23     
+ Misses      56396    56100     -296     
  Partials     2502     2502              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Patrick-Pimentel-Bitwarden Patrick-Pimentel-Bitwarden force-pushed the auth/pm-12040/remove-active-user-state-from-sso-login branch from 4ade22d to 0091a20 Compare January 29, 2025 23:59
Copy link
Contributor

@JaredSnider-Bitwarden JaredSnider-Bitwarden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on this! Would you mind adding recordings of SSO login working still on each client on the PR? Just a few nits below:

@@ -74,12 +76,16 @@ export abstract class SsoLoginServiceAbstraction {
* Gets the value of the active user's organization sso identifier.
*
* This should only be used post successful SSO login once the user is initialized.
* @param userId The user id for the current
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: comment needs to be finished?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding this test suite! Love to see our test coverage go up!

Comment on lines +118 to +124
if (userId !== undefined) {
await this.userOrgSsoIdentifierState(userId).update((_) => organizationIdentifier);
} else {
this.logService.warning(
"Tried to set a new user organization sso identifier with an undefined user id.",
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: using the early return approach cleans this up just a bit, but isn't 100% necessary just something to think about for the future.

Example:

if (userId === undefined) {
    this.logService.warning(
        "Tried to set a new user organization sso identifier with an undefined user id.",
      );
    return;
      }
await this.userOrgSsoIdentifierState(userId).update((_) => organizationIdentifier);
    

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer that approach too, thanks for catching that. I'll get that fixed in a sec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants