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-9723] Refresh: LoginViaAuthRequestComponent #11545

Open
wants to merge 57 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
721a482
Rename legacy components to V1
rr-bw Oct 13, 2024
ff97793
setup new component
rr-bw Oct 14, 2024
0ead3c3
migrate constructor() and ngOnInit()
rr-bw Oct 14, 2024
847bf94
migrate verifyAndHandleApprovedAuthReq(), loginViaAuthRequestStrategyโ€ฆ
rr-bw Oct 14, 2024
eed331e
migrate startAuthRequestLogin() and buildAuthRequest()
rr-bw Oct 14, 2024
0dd948d
migrate handleExistingAdminAuthRequest() and handleExistingAdminAuthRโ€ฆ
rr-bw Oct 14, 2024
05f5543
migrate handleApprovedAdminAuthRequest() and handleSuccessfulLoginNavโ€ฆ
rr-bw Oct 14, 2024
513f7b9
migrate handlePostLoginNavigation()
rr-bw Oct 14, 2024
8674d22
migrate web template
rr-bw Oct 14, 2024
e4c6ea9
Merge branch 'main' into auth/pm-9723/login-via-auth-request-componenโ€ฆ
rr-bw Oct 15, 2024
44eb5a6
Update Web route
rr-bw Oct 15, 2024
0198707
Merge branch 'main' into auth/pm-9723/login-via-auth-request-componenโ€ฆ
rr-bw Oct 16, 2024
3c88925
Update template for standard auth request
rr-bw Oct 16, 2024
19556ac
Update template for admin auth request
rr-bw Oct 16, 2024
78ca231
Update browser routes
rr-bw Oct 17, 2024
65e65e4
Update desktop routes
rr-bw Oct 17, 2024
17f024c
Add devices icon
rr-bw Oct 17, 2024
940f14c
update Web route for 'admin-approval-requested'
rr-bw Oct 17, 2024
8dcf015
update browser and desktop routes for admin-approval-requested
rr-bw Oct 17, 2024
2d1c603
browser route cleanup and comment
rr-bw Oct 17, 2024
4f27362
comments and cleanup
rr-bw Oct 17, 2024
1443f08
refactor use of deprecated method
rr-bw Oct 17, 2024
3a675c8
refactor onSuccess navigation logic
rr-bw Oct 17, 2024
9b924d7
refactoring - use takeUntilDestroyed() instead of a destroy$ subject
rr-bw Oct 17, 2024
0350eee
merge main, fix conflict
rr-bw Oct 18, 2024
882f995
refactor - ngOnInit() logic
rr-bw Oct 19, 2024
4ea7d3f
refactor - renaming
rr-bw Oct 20, 2024
8381a00
renaming
rr-bw Oct 22, 2024
880d562
refactor routes to a backToRoute variable
rr-bw Oct 22, 2024
832d32b
refactoring - move code from loginViaAuthRequestStrategy() to verifyAโ€ฆ
rr-bw Oct 22, 2024
38b608d
add doc comments to buildAuthRequestLoginCredentials()
rr-bw Oct 22, 2024
97f5bea
Merge branch 'main' into auth/pm-9723/login-via-auth-request-componenโ€ฆ
rr-bw Oct 23, 2024
e32ca6c
refactor comments
rr-bw Oct 23, 2024
055f642
reorder methods
rr-bw Oct 23, 2024
7ecce82
create AuthRequestApiService
rr-bw Oct 25, 2024
fcd8d96
update comments for flows
rr-bw Oct 25, 2024
daa61da
merge main, fix conflicts
rr-bw Oct 28, 2024
3921594
remove console statements
rr-bw Oct 28, 2024
06636ce
update translations
rr-bw Oct 28, 2024
ff5269c
translation update
rr-bw Oct 28, 2024
03cca93
Merge branch 'main' into auth/pm-9723/login-via-auth-request-componenโ€ฆ
rr-bw Oct 31, 2024
0658708
remove unnecessary route component prop, and update route ani
rr-bw Oct 31, 2024
9393abd
remove TODO comments
rr-bw Oct 31, 2024
1cb3083
remove environment selector on admin-approval-requested because user โ€ฆ
rr-bw Oct 31, 2024
2efef5f
Merge branch 'main' into auth/pm-9723/login-via-auth-request-componenโ€ฆ
rr-bw Nov 5, 2024
5e11b4d
Merge branch 'main' into auth/pm-9723/login-via-auth-request-componenโ€ฆ
rr-bw Nov 5, 2024
f32b2c9
Merge branch 'main' into auth/pm-9723/login-via-auth-request-componenโ€ฆ
rr-bw Nov 6, 2024
9de7a01
add TODO comment to remind us to remove ApiService methods when removโ€ฆ
rr-bw Nov 6, 2024
b21edf1
update SVG icon with viewBox
rr-bw Nov 6, 2024
dd610e3
refactor ngOnInit to use two paths
rr-bw Nov 7, 2024
a1100e7
Merge branch 'main' into auth/pm-9723/login-via-auth-request-componenโ€ฆ
withinfocus Nov 11, 2024
a3ef8ba
Merge branch 'main' into auth/pm-9723/login-via-auth-request-componenโ€ฆ
rr-bw Nov 13, 2024
254215c
remove comment
rr-bw Nov 14, 2024
90fdc34
rewrite documentation to cover all flows
rr-bw Nov 14, 2024
a2b58f2
add handlers to distinguish authed and unauthed flows
rr-bw Nov 15, 2024
34d857f
Merge branch 'main' into auth/pm-9723/login-via-auth-request-componenโ€ฆ
rr-bw Nov 15, 2024
aea6bb8
restructure verifyAndHandleApprovedAuthReq()
rr-bw Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions apps/browser/src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3150,12 +3150,27 @@
"resendNotification": {
"message": "Resend notification"
},
"viewAllLogInOptions": {
"message": "View all log in options"
},
"viewAllLoginOptions": {
"message": "View all log in options"
},
"notificationSentDevice": {
"message": "A notification has been sent to your device."
},
"aNotificationWasSentToYourDevice": {
"message": "A notification was sent to your device"
},
"makeSureYourAccountIsUnlockedAndTheFingerprintEtc": {
"message": "Make sure your account is unlocked and the fingerprint phrase matches on the other device"
},
"youWillBeNotifiedOnceTheRequestIsApproved": {
"message": "You will be notified once the request is approved"
},
"needAnotherOptionV1": {
"message": "Need another option?"
},
"loginInitiated": {
"message": "Login initiated"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Component } from "@angular/core";
import { Router } from "@angular/router";

import { LoginViaAuthRequestComponent as BaseLoginWithDeviceComponent } from "@bitwarden/angular/auth/components/login-via-auth-request.component";
import { LoginViaAuthRequestComponentV1 as BaseLoginViaAuthRequestComponentV1 } from "@bitwarden/angular/auth/components/login-via-auth-request-v1.component";

Check warning on line 5 in apps/browser/src/auth/popup/login-via-auth-request-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/auth/popup/login-via-auth-request-v1.component.ts#L5

Added line #L5 was not covered by tests
import {
AuthRequestServiceAbstraction,
LoginStrategyServiceAbstraction,
Expand All @@ -27,9 +27,9 @@

@Component({
selector: "app-login-via-auth-request",
templateUrl: "login-via-auth-request.component.html",
templateUrl: "login-via-auth-request-v1.component.html",
})
export class LoginViaAuthRequestComponent extends BaseLoginWithDeviceComponent {
export class LoginViaAuthRequestComponentV1 extends BaseLoginViaAuthRequestComponentV1 {

Check warning on line 32 in apps/browser/src/auth/popup/login-via-auth-request-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/auth/popup/login-via-auth-request-v1.component.ts#L32

Added line #L32 was not covered by tests
constructor(
router: Router,
keyService: KeyService,
Expand Down
3 changes: 3 additions & 0 deletions apps/browser/src/popup/app-routing.animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ export const routerTransition = trigger("routerTransition", [
transition("login-with-device => tabs, login-with-device => 2fa", inSlideLeft),
transition("login-with-device => login", outSlideRight),

transition("admin-approval-requested => tabs, admin-approval-requested => 2fa", inSlideLeft),
transition("admin-approval-requested => login", outSlideRight),

transition(tabsToCiphers, inSlideLeft),
transition(ciphersToTabs, outSlideRight),

Expand Down
71 changes: 58 additions & 13 deletions apps/browser/src/popup/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import {
AnonLayoutWrapperComponent,
AnonLayoutWrapperData,
DevicesIcon,
LoginComponent,
LoginSecondaryContentComponent,
LockIcon,
LockV2Component,
LoginViaAuthRequestComponent,
PasswordHintComponent,
RegistrationFinishComponent,
RegistrationLockAltIcon,
Expand All @@ -51,7 +53,7 @@
import { LockComponent } from "../auth/popup/lock.component";
import { LoginDecryptionOptionsComponent } from "../auth/popup/login-decryption-options/login-decryption-options.component";
import { LoginComponentV1 } from "../auth/popup/login-v1.component";
import { LoginViaAuthRequestComponent } from "../auth/popup/login-via-auth-request.component";
import { LoginViaAuthRequestComponentV1 } from "../auth/popup/login-via-auth-request-v1.component";

Check warning on line 56 in apps/browser/src/popup/app-routing.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/popup/app-routing.module.ts#L56

Added line #L56 was not covered by tests
import { RegisterComponent } from "../auth/popup/register.component";
import { RemovePasswordComponent } from "../auth/popup/remove-password.component";
import { SetPasswordComponent } from "../auth/popup/set-password.component";
Expand Down Expand Up @@ -171,18 +173,6 @@
canActivate: [fido2AuthGuard],
data: { state: "fido2" } satisfies RouteDataProperties,
}),
{
path: "login-with-device",
component: LoginViaAuthRequestComponent,
canActivate: [],
data: { state: "login-with-device" } satisfies RouteDataProperties,
},
{
path: "admin-approval-requested",
component: LoginViaAuthRequestComponent,
canActivate: [],
data: { state: "login-with-device" } satisfies RouteDataProperties,
},
{
path: "lock",
component: LockComponent,
Expand Down Expand Up @@ -409,6 +399,61 @@
canActivate: [authGuard],
data: { state: "update-temp-password" } satisfies RouteDataProperties,
},
...unauthUiRefreshSwap(
LoginViaAuthRequestComponentV1,
ExtensionAnonLayoutWrapperComponent,
{
path: "login-with-device",
data: { state: "login-with-device" } satisfies RouteDataProperties,
},
{
path: "login-with-device",
data: {
pageIcon: DevicesIcon,
pageTitle: {
key: "loginInitiated",
},
pageSubtitle: {
key: "aNotificationWasSentToYourDevice",
},
showLogo: false,
showBackButton: true,
state: "login-with-device",
} satisfies RouteDataProperties & ExtensionAnonLayoutWrapperData,
children: [
{ path: "", component: LoginViaAuthRequestComponent },
{
path: "",
component: EnvironmentSelectorComponent,
outlet: "environment-selector",
},
],
},
),
...unauthUiRefreshSwap(
LoginViaAuthRequestComponentV1,
ExtensionAnonLayoutWrapperComponent,
{
path: "admin-approval-requested",
data: { state: "admin-approval-requested" } satisfies RouteDataProperties,
},
{
path: "admin-approval-requested",
data: {
pageIcon: DevicesIcon,
pageTitle: {
key: "adminApprovalRequested",
},
pageSubtitle: {
key: "adminApprovalRequestSentToAdmins",
},
showLogo: false,
showBackButton: true,
state: "admin-approval-requested",
} satisfies RouteDataProperties & ExtensionAnonLayoutWrapperData,
children: [{ path: "", component: LoginViaAuthRequestComponent }],
},
),
...unauthUiRefreshSwap(
HintComponent,
ExtensionAnonLayoutWrapperComponent,
Expand Down
4 changes: 2 additions & 2 deletions apps/browser/src/popup/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import { LockComponent } from "../auth/popup/lock.component";
import { LoginDecryptionOptionsComponent } from "../auth/popup/login-decryption-options/login-decryption-options.component";
import { LoginComponentV1 } from "../auth/popup/login-v1.component";
import { LoginViaAuthRequestComponent } from "../auth/popup/login-via-auth-request.component";
import { LoginViaAuthRequestComponentV1 } from "../auth/popup/login-via-auth-request-v1.component";

Check warning on line 29 in apps/browser/src/popup/app.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/popup/app.module.ts#L29

Added line #L29 was not covered by tests
import { RegisterComponent } from "../auth/popup/register.component";
import { RemovePasswordComponent } from "../auth/popup/remove-password.component";
import { SetPasswordComponent } from "../auth/popup/set-password.component";
Expand Down Expand Up @@ -159,8 +159,8 @@
HintComponent,
HomeComponent,
LockComponent,
LoginViaAuthRequestComponentV1,
LoginComponentV1,
LoginViaAuthRequestComponent,
LoginDecryptionOptionsComponent,
NotificationsSettingsV1Component,
AppearanceComponent,
Expand Down
59 changes: 50 additions & 9 deletions apps/desktop/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
import {
AnonLayoutWrapperComponent,
AnonLayoutWrapperData,
DevicesIcon,
LoginComponent,
LoginSecondaryContentComponent,
LockIcon,
LockV2Component,
LoginViaAuthRequestComponent,
PasswordHintComponent,
RegistrationFinishComponent,
RegistrationLockAltIcon,
Expand All @@ -42,7 +44,7 @@
import { LockComponent } from "../auth/lock.component";
import { LoginDecryptionOptionsComponent } from "../auth/login/login-decryption-options/login-decryption-options.component";
import { LoginComponentV1 } from "../auth/login/login-v1.component";
import { LoginViaAuthRequestComponent } from "../auth/login/login-via-auth-request.component";
import { LoginViaAuthRequestComponentV1 } from "../auth/login/login-via-auth-request-v1.component";

Check warning on line 47 in apps/desktop/src/app/app-routing.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/app/app-routing.module.ts#L47

Added line #L47 was not covered by tests
import { RegisterComponent } from "../auth/register.component";
import { RemovePasswordComponent } from "../auth/remove-password.component";
import { SetPasswordComponent } from "../auth/set-password.component";
Expand Down Expand Up @@ -75,14 +77,6 @@
canActivate: [lockGuard()],
canMatch: [extensionRefreshRedirect("/lockV2")],
},
{
path: "login-with-device",
component: LoginViaAuthRequestComponent,
},
{
path: "admin-approval-requested",
component: LoginViaAuthRequestComponent,
},
...twofactorRefactorSwap(
TwoFactorComponent,
AnonLayoutWrapperComponent,
Expand Down Expand Up @@ -130,6 +124,53 @@
component: RemovePasswordComponent,
canActivate: [authGuard],
},
...unauthUiRefreshSwap(
LoginViaAuthRequestComponentV1,
AnonLayoutWrapperComponent,
{
path: "login-with-device",
},
{
path: "login-with-device",
data: {
pageIcon: DevicesIcon,
pageTitle: {
key: "loginInitiated",
},
pageSubtitle: {
key: "aNotificationWasSentToYourDevice",
},
} satisfies AnonLayoutWrapperData,
children: [
{ path: "", component: LoginViaAuthRequestComponent },
{
path: "",
component: EnvironmentSelectorComponent,
outlet: "environment-selector",
},
],
},
),
...unauthUiRefreshSwap(
LoginViaAuthRequestComponentV1,
AnonLayoutWrapperComponent,
{
path: "admin-approval-requested",
},
{
path: "admin-approval-requested",
data: {
pageIcon: DevicesIcon,
pageTitle: {
key: "adminApprovalRequested",
},
pageSubtitle: {
key: "adminApprovalRequestSentToAdmins",
},
} satisfies AnonLayoutWrapperData,
children: [{ path: "", component: LoginViaAuthRequestComponent }],
},
),
...unauthUiRefreshSwap(
HintComponent,
AnonLayoutWrapperComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Component, ViewChild, ViewContainerRef } from "@angular/core";
import { Router } from "@angular/router";

import { LoginViaAuthRequestComponent as BaseLoginWithDeviceComponent } from "@bitwarden/angular/auth/components/login-via-auth-request.component";
import { LoginViaAuthRequestComponentV1 as BaseLoginViaAuthRequestComponentV1 } from "@bitwarden/angular/auth/components/login-via-auth-request-v1.component";

Check warning on line 5 in apps/desktop/src/auth/login/login-via-auth-request-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/auth/login/login-via-auth-request-v1.component.ts#L5

Added line #L5 was not covered by tests
import { ModalService } from "@bitwarden/angular/services/modal.service";
import {
AuthRequestServiceAbstraction,
Expand Down Expand Up @@ -30,9 +30,9 @@

@Component({
selector: "app-login-via-auth-request",
templateUrl: "login-via-auth-request.component.html",
templateUrl: "login-via-auth-request-v1.component.html",
})
export class LoginViaAuthRequestComponent extends BaseLoginWithDeviceComponent {
export class LoginViaAuthRequestComponentV1 extends BaseLoginViaAuthRequestComponentV1 {

Check warning on line 35 in apps/desktop/src/auth/login/login-via-auth-request-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/auth/login/login-via-auth-request-v1.component.ts#L35

Added line #L35 was not covered by tests
@ViewChild("environment", { read: ViewContainerRef, static: true })
environmentModal: ViewContainerRef;
showingModal = false;
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/auth/login/login.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

import { LoginDecryptionOptionsComponent } from "./login-decryption-options/login-decryption-options.component";
import { LoginComponentV1 } from "./login-v1.component";
import { LoginViaAuthRequestComponent } from "./login-via-auth-request.component";
import { LoginViaAuthRequestComponentV1 } from "./login-via-auth-request-v1.component";

Check warning on line 10 in apps/desktop/src/auth/login/login.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/auth/login/login.module.ts#L10

Added line #L10 was not covered by tests

@NgModule({
imports: [SharedModule, RouterModule],
declarations: [
LoginComponentV1,
LoginViaAuthRequestComponent,
LoginViaAuthRequestComponentV1,
EnvironmentSelectorComponent,
LoginDecryptionOptionsComponent,
],
exports: [LoginComponentV1, LoginViaAuthRequestComponent],
exports: [LoginComponentV1, LoginViaAuthRequestComponentV1],
})
export class LoginModule {}
15 changes: 15 additions & 0 deletions apps/desktop/src/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2669,15 +2669,30 @@
"notificationSentDevice": {
"message": "A notification has been sent to your device."
},
"aNotificationWasSentToYourDevice": {
"message": "A notification was sent to your device"
},
"makeSureYourAccountIsUnlockedAndTheFingerprintEtc": {
"message": "Make sure your account is unlocked and the fingerprint phrase matches on the other device"
},
"needAnotherOptionV1": {
"message": "Need another option?"
},
"fingerprintMatchInfo": {
"message": "Please make sure your vault is unlocked and Fingerprint phrase matches the other device."
},
"fingerprintPhraseHeader": {
"message": "Fingerprint phrase"
},
"youWillBeNotifiedOnceTheRequestIsApproved": {
"message": "You will be notified once the request is approved"
},
"needAnotherOption": {
"message": "Log in with device must be set up in the settings of the Bitwarden app. Need another option?"
},
"viewAllLogInOptions": {
"message": "View all log in options"
},
"viewAllLoginOptions": {
"message": "View all login options"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ <h4 class="tw-font-semibold">{{ "fingerprintPhraseHeader" | i18n }}</h4>
</div>
</div>
</ng-container>

<ng-container *ngIf="state == StateEnum.AdminAuthRequest">
<div
class="tw-mt-3 tw-rounded-md tw-border tw-border-solid tw-border-secondary-300 tw-bg-background tw-p-6"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Component } from "@angular/core";

Check warning on line 1 in apps/web/src/app/auth/login/login-via-auth-request-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/login/login-via-auth-request-v1.component.ts#L1

Added line #L1 was not covered by tests

import { LoginViaAuthRequestComponentV1 as BaseLoginViaAuthRequestComponentV1 } from "@bitwarden/angular/auth/components/login-via-auth-request-v1.component";

Check warning on line 3 in apps/web/src/app/auth/login/login-via-auth-request-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/login/login-via-auth-request-v1.component.ts#L3

Added line #L3 was not covered by tests

@Component({
selector: "app-login-via-auth-request",
templateUrl: "login-via-auth-request-v1.component.html",
})
export class LoginViaAuthRequestComponentV1 extends BaseLoginViaAuthRequestComponentV1 {}

Check warning on line 9 in apps/web/src/app/auth/login/login-via-auth-request-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/login/login-via-auth-request-v1.component.ts#L9

Added line #L9 was not covered by tests

This file was deleted.

6 changes: 3 additions & 3 deletions apps/web/src/app/auth/login/login.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@

import { LoginDecryptionOptionsComponent } from "./login-decryption-options/login-decryption-options.component";
import { LoginComponentV1 } from "./login-v1.component";
import { LoginViaAuthRequestComponent } from "./login-via-auth-request.component";
import { LoginViaAuthRequestComponentV1 } from "./login-via-auth-request-v1.component";

Check warning on line 9 in apps/web/src/app/auth/login/login.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/login/login.module.ts#L9

Added line #L9 was not covered by tests
import { LoginViaWebAuthnComponent } from "./login-via-webauthn/login-via-webauthn.component";

@NgModule({
imports: [SharedModule, CheckboxModule],
declarations: [
LoginComponentV1,
LoginViaAuthRequestComponent,
LoginViaAuthRequestComponentV1,
LoginDecryptionOptionsComponent,
LoginViaWebAuthnComponent,
],
exports: [
LoginComponentV1,
LoginViaAuthRequestComponent,
LoginViaAuthRequestComponentV1,
LoginDecryptionOptionsComponent,
LoginViaWebAuthnComponent,
],
Expand Down
Loading
Loading