mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-12 14:56:58 +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);
|
super(environmentService, i18nService, platformUtilsService, toastService);
|
||||||
this.webAuthnSupported = this.platformUtilsService.supportsWebAuthn(win);
|
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
|
// Add subscription to twoFactorTimeout$ and navigate to twoFactorTimeoutRoute if expired
|
||||||
this.loginStrategyService.twoFactorTimeout$
|
this.loginStrategyService.twoFactorTimeout$
|
||||||
.pipe(takeUntilDestroyed())
|
.pipe(takeUntilDestroyed())
|
||||||
.subscribe(async (expired) => {
|
.subscribe(async (expired) => {
|
||||||
|
this.logService.info(
|
||||||
|
"Received emission from LoginStrategyService.twoFactorTimeout$ with service id: " +
|
||||||
|
this.loginStrategyService.id,
|
||||||
|
);
|
||||||
|
|
||||||
if (!expired) {
|
if (!expired) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@ import {
|
|||||||
} from "../models/domain/login-credentials";
|
} from "../models/domain/login-credentials";
|
||||||
|
|
||||||
export abstract class LoginStrategyServiceAbstraction {
|
export abstract class LoginStrategyServiceAbstraction {
|
||||||
|
id: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current strategy being used to authenticate.
|
* The current strategy being used to authenticate.
|
||||||
* Emits null if the session has timed out.
|
* Emits null if the session has timed out.
|
||||||
|
@ -7,6 +7,7 @@ import {
|
|||||||
shareReplay,
|
shareReplay,
|
||||||
Subscription,
|
Subscription,
|
||||||
BehaviorSubject,
|
BehaviorSubject,
|
||||||
|
tap,
|
||||||
} from "rxjs";
|
} from "rxjs";
|
||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
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 { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.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 { TaskSchedulerService, ScheduledTaskNames } from "@bitwarden/common/platform/scheduling";
|
||||||
import { GlobalState, GlobalStateProvider } from "@bitwarden/common/platform/state";
|
import { GlobalState, GlobalStateProvider } from "@bitwarden/common/platform/state";
|
||||||
import { DeviceTrustServiceAbstraction } from "@bitwarden/common/src/auth/abstractions/device-trust.service.abstraction";
|
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 authRequestPushNotificationState: GlobalState<string>;
|
||||||
private twoFactorTimeoutSubject = new BehaviorSubject<boolean>(false);
|
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<
|
private loginStrategy$: Observable<
|
||||||
| UserApiLoginStrategy
|
| UserApiLoginStrategy
|
||||||
@ -94,6 +125,8 @@ export class LoginStrategyService implements LoginStrategyServiceAbstraction {
|
|||||||
|
|
||||||
currentAuthType$: Observable<AuthenticationType | null>;
|
currentAuthType$: Observable<AuthenticationType | null>;
|
||||||
|
|
||||||
|
id: string = Utils.newGuid();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected accountService: AccountService,
|
protected accountService: AccountService,
|
||||||
protected masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
protected masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
||||||
@ -131,6 +164,7 @@ export class LoginStrategyService implements LoginStrategyServiceAbstraction {
|
|||||||
this.taskSchedulerService.registerTaskHandler(
|
this.taskSchedulerService.registerTaskHandler(
|
||||||
ScheduledTaskNames.loginStrategySessionTimeout,
|
ScheduledTaskNames.loginStrategySessionTimeout,
|
||||||
async () => {
|
async () => {
|
||||||
|
this.logService.info("Timeout executing for LoginStrategyService with id: " + this.id);
|
||||||
this.authnSessionTimeoutExecutor(async () => {
|
this.authnSessionTimeoutExecutor(async () => {
|
||||||
this.twoFactorTimeoutSubject.next(true);
|
this.twoFactorTimeoutSubject.next(true);
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user