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

[PM-15063] Show banner in web app when user has at least one pending authrequest #13147

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

Conversation

alec-livefront
Copy link
Collaborator

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-15063?atlOrigin=eyJpIjoiOGY5MzdhNDMyZDllNDc0ZWFkMzk2NjI1NjRhMTU5MGIiLCJwIjoiaiJ9

📔 Objective

Adds a new banner to the vault that will display when a device auth request is made. The banner contains a link to the device management screen (/#/settings/security/device-management). This PR also modifies the device management screen to listen for the openLoginApproval message and upsert the new request data into the table.

📸 Screenshots

GMT20250129-223543_Clip_Alec.Rippberger.s.Clip.01_29_2025.mp4

⏰ 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

Copy link
Contributor

github-actions bot commented Jan 29, 2025

Logo
Checkmarx One – Scan Summary & Detailsb68d6c8d-ab64-4ccc-8d99-ab79f1933e0e

Great job, no security vulnerabilities found in this Pull Request

@alec-livefront alec-livefront marked this pull request as ready for review January 29, 2025 22:46
@alec-livefront alec-livefront requested review from a team as code owners January 29, 2025 22:46
Copy link

codecov bot commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 50.76923% with 32 lines in your changes missing coverage. Please review.

Project coverage is 35.08%. Comparing base (9cbe295) to head (271376d).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...h/settings/security/device-management.component.ts 44.73% 20 Missing and 1 partial ⚠️
...ual-vault/vault-banners/vault-banners.component.ts 56.25% 7 Missing ⚠️
.../src/auth/models/response/auth-request.response.ts 0.00% 2 Missing ⚠️
...lt/vault-banners/services/vault-banners.service.ts 87.50% 0 Missing and 1 partial ⚠️
...src/auth/abstractions/devices/views/device.view.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13147      +/-   ##
==========================================
+ Coverage   35.03%   35.08%   +0.05%     
==========================================
  Files        3034     3036       +2     
  Lines       92636    92776     +140     
  Branches    16858    16905      +47     
==========================================
+ Hits        32452    32549      +97     
- Misses      57724    57753      +29     
- Partials     2460     2474      +14     

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

@alec-livefront alec-livefront changed the title Auth/pm 15063/pending auth request banner PM-15063: pending auth request banner Jan 30, 2025
@alec-livefront alec-livefront changed the title PM-15063: pending auth request banner PM-15063: Show banner in web app when user has at least one pending authrequest Jan 30, 2025
@alec-livefront alec-livefront changed the title PM-15063: Show banner in web app when user has at least one pending authrequest [PM-15063] Show banner in web app when user has at least one pending authrequest Feb 5, 2025
Jingo88
Jingo88 previously approved these changes Feb 5, 2025
dataSource = new TableDataSource<DeviceTableData>();
currentDevice: DeviceView | undefined;
loading = true;
asyncActionLoading = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Vault files look gewd. Just curious why the protected was removed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm guessing I was working with some finicky testing situation here - it's not necessary to remove though so I've added it back: 271376d

Copy link
Contributor

@rr-bw rr-bw left a comment

Choose a reason for hiding this comment

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

The same device will show up 2x when there is a pending auth request and after it is approved. The duplicate only goes away when you refresh the screen. Here are three screenshots showing each state.

Pending auth request (device shown 2x)

before-approval

After auth request has been approved (device shown 2x)

after-approval

After refreshing the device management screen (device shown 1x)

after-refresh

@@ -44,7 +49,7 @@ interface DeviceTableData {
imports: [CommonModule, SharedModule, TableModule, PopoverModule],
})
export class DeviceManagementComponent {
protected readonly tableId = "device-management-table";
protected readonly retableId = "device-management-table";
Copy link
Contributor

Choose a reason for hiding this comment

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

Why "retable"?

Comment on lines +67 to +80
// Load devices
this.loadDevices().catch((error) => this.validationService.showError(error));

// Listen for auth request messages
this.messageListener.allMessages$.pipe(takeUntilDestroyed()).subscribe((message) => {
if (message.command !== "openLoginApproval") {
return;
}
// Handle inserting a new device when an auth request is received
this.handleAuthRequest(message as { command: string; notificationId: string }).catch(
(error) => this.validationService.showError(error),
);
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we aren't awaiting loadDevices(), I think this creates a race condition. If handleAuthRequest() were to finish first, then I believe loadDevices() could potentially overwrite the table data and remove the newDevice that was added in handleAuthRequest().

* Handle inserting a new device when an auth request is received
* @param message - The auth request message
*/
private async handleAuthRequest(message: {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rename this to upsertDeviceWithPendingAuthRequest or something similar. Otherwise the name seems like it's actually handling/managing the auth request, which we do in managePendingAuthRequest()

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.

3 participants