mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-11 14:48:46 +01:00
PM-13659 - 2FA Timeout Log All the things (#12275)
This commit is contained in:
parent
7e2456224d
commit
9fcc4f0543
@ -102,10 +102,20 @@ export class TwoFactorComponent extends CaptchaProtectedComponent implements OnI
|
||||
super(environmentService, i18nService, platformUtilsService, toastService);
|
||||
this.webAuthnSupported = this.platformUtilsService.supportsWebAuthn(win);
|
||||
|
||||
this.logService.info(
|
||||
"Subscribing to timeout on LoginStrategyService with service id: " +
|
||||
this.loginStrategyService.id,
|
||||
);
|
||||
|
||||
// Add subscription to twoFactorTimeout$ and navigate to twoFactorTimeoutRoute if expired
|
||||
this.loginStrategyService.twoFactorTimeout$
|
||||
.pipe(takeUntilDestroyed())
|
||||
.subscribe(async (expired) => {
|
||||
this.logService.info(
|
||||
"Received emission from LoginStrategyService.twoFactorTimeout$ with service id: " +
|
||||
this.loginStrategyService.id,
|
||||
);
|
||||
|
||||
if (!expired) {
|
||||
return;
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ import {
|
||||
} from "../models/domain/login-credentials";
|
||||
|
||||
export abstract class LoginStrategyServiceAbstraction {
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The current strategy being used to authenticate.
|
||||
* Emits null if the session has timed out.
|
||||
|
@ -7,6 +7,7 @@ import {
|
||||
shareReplay,
|
||||
Subscription,
|
||||
BehaviorSubject,
|
||||
tap,
|
||||
} from "rxjs";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
@ -31,6 +32,7 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
|
||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
import { TaskSchedulerService, ScheduledTaskNames } from "@bitwarden/common/platform/scheduling";
|
||||
import { GlobalState, GlobalStateProvider } from "@bitwarden/common/platform/state";
|
||||
import { DeviceTrustServiceAbstraction } from "@bitwarden/common/src/auth/abstractions/device-trust.service.abstraction";
|
||||
@ -81,7 +83,36 @@ export class LoginStrategyService implements LoginStrategyServiceAbstraction {
|
||||
private authRequestPushNotificationState: GlobalState<string>;
|
||||
private twoFactorTimeoutSubject = new BehaviorSubject<boolean>(false);
|
||||
|
||||
twoFactorTimeout$: Observable<boolean> = this.twoFactorTimeoutSubject.asObservable();
|
||||
twoFactorTimeout$: Observable<boolean> = this.twoFactorTimeoutSubject.asObservable().pipe(
|
||||
// line 87 is the tap?
|
||||
tap({
|
||||
next: (value) => {
|
||||
this.logService.info(
|
||||
`LoginStrategyService.twoFactorTimeout$ with service id: ${this.id} emmitted value: ${value}`,
|
||||
);
|
||||
},
|
||||
error: (error: unknown) => {
|
||||
this.logService.error(
|
||||
`LoginStrategyService.twoFactorTimeout$ with service id: ${this.id} errored with error: ${JSON.stringify(error)}`,
|
||||
);
|
||||
},
|
||||
finalize: () => {
|
||||
this.logService.info(
|
||||
`LoginStrategyService.twoFactorTimeout$ with service id: ${this.id} finalized`,
|
||||
);
|
||||
},
|
||||
complete: () => {
|
||||
this.logService.info(
|
||||
`LoginStrategyService.twoFactorTimeout$ with service id: ${this.id} completed`,
|
||||
);
|
||||
},
|
||||
subscribe: () => {
|
||||
this.logService.info(
|
||||
`LoginStrategyService.twoFactorTimeout$ with service id: ${this.id} subscribed`,
|
||||
);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
private loginStrategy$: Observable<
|
||||
| UserApiLoginStrategy
|
||||
@ -94,6 +125,8 @@ export class LoginStrategyService implements LoginStrategyServiceAbstraction {
|
||||
|
||||
currentAuthType$: Observable<AuthenticationType | null>;
|
||||
|
||||
id: string = Utils.newGuid();
|
||||
|
||||
constructor(
|
||||
protected accountService: AccountService,
|
||||
protected masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
||||
@ -131,6 +164,7 @@ export class LoginStrategyService implements LoginStrategyServiceAbstraction {
|
||||
this.taskSchedulerService.registerTaskHandler(
|
||||
ScheduledTaskNames.loginStrategySessionTimeout,
|
||||
async () => {
|
||||
this.logService.info("Timeout executing for LoginStrategyService with id: " + this.id);
|
||||
this.authnSessionTimeoutExecutor(async () => {
|
||||
this.twoFactorTimeoutSubject.next(true);
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user