1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

Auth/ps 2298 reorg auth (#4564)

* Move auth service factories to Auth team

* Move authentication componenets to Auth team

* Move auth guard services to Auth team

* Move Duo content script to Auth team

* Move auth CLI commands to Auth team

* Move Desktop Account components to Auth Team

* Move Desktop guards to Auth team

* Move two-factor provider images to Auth team

* Move web Accounts components to Auth Team

* Move web settings components to Auth Team

* Move web two factor images to Auth Team

* Fix missed import changes for Auth Team

* Fix Linting errors

* Fix missed CLI imports

* Fix missed Desktop imports

* Revert images move

* Fix missed imports in Web

* Move angular lib components to Auth Team

* Move angular auth guards to Auth team

* Move strategy specs to Auth team

* Update .eslintignore for new paths

* Move lib common abstractions to Auth team

* Move services to Auth team

* Move common lib enums to Auth team

* Move webauthn iframe to Auth team

* Move lib common domain models to Auth team

* Move common lib requests to Auth team

* Move response models to Auth team

* Clean up whitelist

* Move bit web components to Auth team

* Move SSO and SCIM files to Auth team

* Revert move SCIM to Auth team

SCIM belongs to Admin Console team

* Move captcha to Auth team

* Move key connector to Auth team

* Move emergency access to auth team

* Delete extra file

* linter fixes

* Move kdf config to auth team

* Fix whitelist

* Fix duo autoformat

* Complete two factor provider request move

* Fix whitelist names

* Fix login capitalization

* Revert hint dependency reordering

* Revert hint dependency reordering

* Revert hint component

This components is being picked up as a move between clients

* Move web hint component to Auth team

* Move new files to auth team

* Fix desktop build

* Fix browser build
This commit is contained in:
Matt Gibson
2023-02-06 16:53:37 -05:00
committed by GitHub
parent 084c89107e
commit cf972e784c
377 changed files with 1030 additions and 998 deletions

View File

@@ -1,12 +0,0 @@
import { BaseResponse } from "./base.response";
export class ApiKeyResponse extends BaseResponse {
apiKey: string;
revisionDate: Date;
constructor(response: any) {
super(response);
this.apiKey = this.getResponseProperty("ApiKey");
this.revisionDate = new Date(this.getResponseProperty("RevisionDate"));
}
}

View File

@@ -1,59 +0,0 @@
import { DeviceType } from "../../enums/deviceType";
import { BaseResponse } from "./base.response";
const RequestTimeOut = 60000 * 15; //15 Minutes
export class AuthRequestResponse extends BaseResponse {
id: string;
publicKey: string;
requestDeviceType: DeviceType;
requestIpAddress: string;
key: string;
masterPasswordHash: string;
creationDate: string;
requestApproved?: boolean;
requestFingerprint?: string;
responseDate?: string;
isAnswered: boolean;
isExpired: boolean;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty("Id");
this.publicKey = this.getResponseProperty("PublicKey");
this.requestDeviceType = this.getResponseProperty("RequestDeviceType");
this.requestIpAddress = this.getResponseProperty("RequestIpAddress");
this.key = this.getResponseProperty("Key");
this.masterPasswordHash = this.getResponseProperty("MasterPasswordHash");
this.creationDate = this.getResponseProperty("CreationDate");
this.requestApproved = this.getResponseProperty("RequestApproved");
this.requestFingerprint = this.getResponseProperty("RequestFingerprint");
this.responseDate = this.getResponseProperty("ResponseDate");
const requestDate = new Date(this.creationDate);
const requestDateUTC = Date.UTC(
requestDate.getUTCFullYear(),
requestDate.getUTCMonth(),
requestDate.getDate(),
requestDate.getUTCHours(),
requestDate.getUTCMinutes(),
requestDate.getUTCSeconds(),
requestDate.getUTCMilliseconds()
);
const dateNow = new Date(Date.now());
const dateNowUTC = Date.UTC(
dateNow.getUTCFullYear(),
dateNow.getUTCMonth(),
dateNow.getDate(),
dateNow.getUTCHours(),
dateNow.getUTCMinutes(),
dateNow.getUTCSeconds(),
dateNow.getUTCMilliseconds()
);
this.isExpired = dateNowUTC - requestDateUTC >= RequestTimeOut;
this.isAnswered = this.requestApproved != null && this.responseDate != null;
}
}

View File

@@ -1,3 +0,0 @@
export interface ICaptchaProtectedResponse {
captchaBypassToken: string;
}

View File

@@ -1,12 +0,0 @@
import { BaseResponse } from "../base.response";
import { ICaptchaProtectedResponse } from "./captcha-protected.response";
export class RegisterResponse extends BaseResponse implements ICaptchaProtectedResponse {
captchaBypassToken: string;
constructor(response: any) {
super(response);
this.captchaBypassToken = this.getResponseProperty("CaptchaBypassToken");
}
}

View File

@@ -1,16 +0,0 @@
import { BaseResponse } from "./base.response";
export class DeviceVerificationResponse extends BaseResponse {
isDeviceVerificationSectionEnabled: boolean;
unknownDeviceVerificationEnabled: boolean;
constructor(response: any) {
super(response);
this.isDeviceVerificationSectionEnabled = this.getResponseProperty(
"IsDeviceVerificationSectionEnabled"
);
this.unknownDeviceVerificationEnabled = this.getResponseProperty(
"UnknownDeviceVerificationEnabled"
);
}
}

View File

@@ -1,20 +0,0 @@
import { DeviceType } from "../../enums/deviceType";
import { BaseResponse } from "./base.response";
export class DeviceResponse extends BaseResponse {
id: string;
name: number;
identifier: string;
type: DeviceType;
creationDate: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty("Id");
this.name = this.getResponseProperty("Name");
this.identifier = this.getResponseProperty("Identifier");
this.type = this.getResponseProperty("Type");
this.creationDate = this.getResponseProperty("CreationDate");
}
}

View File

@@ -1,90 +0,0 @@
import { EmergencyAccessStatusType } from "../../enums/emergencyAccessStatusType";
import { EmergencyAccessType } from "../../enums/emergencyAccessType";
import { KdfType } from "../../enums/kdfType";
import { CipherResponse } from "../../vault/models/response/cipher.response";
import { BaseResponse } from "./base.response";
export class EmergencyAccessGranteeDetailsResponse extends BaseResponse {
id: string;
granteeId: string;
name: string;
email: string;
type: EmergencyAccessType;
status: EmergencyAccessStatusType;
waitTimeDays: number;
creationDate: string;
avatarColor: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty("Id");
this.granteeId = this.getResponseProperty("GranteeId");
this.name = this.getResponseProperty("Name");
this.email = this.getResponseProperty("Email");
this.type = this.getResponseProperty("Type");
this.status = this.getResponseProperty("Status");
this.waitTimeDays = this.getResponseProperty("WaitTimeDays");
this.creationDate = this.getResponseProperty("CreationDate");
this.avatarColor = this.getResponseProperty("AvatarColor");
}
}
export class EmergencyAccessGrantorDetailsResponse extends BaseResponse {
id: string;
grantorId: string;
name: string;
email: string;
type: EmergencyAccessType;
status: EmergencyAccessStatusType;
waitTimeDays: number;
creationDate: string;
avatarColor: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty("Id");
this.grantorId = this.getResponseProperty("GrantorId");
this.name = this.getResponseProperty("Name");
this.email = this.getResponseProperty("Email");
this.type = this.getResponseProperty("Type");
this.status = this.getResponseProperty("Status");
this.waitTimeDays = this.getResponseProperty("WaitTimeDays");
this.creationDate = this.getResponseProperty("CreationDate");
this.avatarColor = this.getResponseProperty("AvatarColor");
}
}
export class EmergencyAccessTakeoverResponse extends BaseResponse {
keyEncrypted: string;
kdf: KdfType;
kdfIterations: number;
kdfMemory?: number;
kdfParallelism?: number;
constructor(response: any) {
super(response);
this.keyEncrypted = this.getResponseProperty("KeyEncrypted");
this.kdf = this.getResponseProperty("Kdf");
this.kdfIterations = this.getResponseProperty("KdfIterations");
this.kdfMemory = this.getResponseProperty("KdfMemory");
this.kdfParallelism = this.getResponseProperty("KdfParallelism");
}
}
export class EmergencyAccessViewResponse extends BaseResponse {
keyEncrypted: string;
ciphers: CipherResponse[] = [];
constructor(response: any) {
super(response);
this.keyEncrypted = this.getResponseProperty("KeyEncrypted");
const ciphers = this.getResponseProperty("Ciphers");
if (ciphers != null) {
this.ciphers = ciphers.map((c: any) => new CipherResponse(c));
}
}
}

View File

@@ -1,10 +0,0 @@
import { BaseResponse } from "./base.response";
export class IdentityCaptchaResponse extends BaseResponse {
siteKey: string;
constructor(response: any) {
super(response);
this.siteKey = this.getResponseProperty("HCaptcha_SiteKey");
}
}

View File

@@ -1,42 +0,0 @@
import { KdfType } from "../../enums/kdfType";
import { BaseResponse } from "./base.response";
export class IdentityTokenResponse extends BaseResponse {
accessToken: string;
expiresIn: number;
refreshToken: string;
tokenType: string;
resetMasterPassword: boolean;
privateKey: string;
key: string;
twoFactorToken: string;
kdf: KdfType;
kdfIterations: number;
kdfMemory?: number;
kdfParallelism?: number;
forcePasswordReset: boolean;
apiUseKeyConnector: boolean;
keyConnectorUrl: string;
constructor(response: any) {
super(response);
this.accessToken = response.access_token;
this.expiresIn = response.expires_in;
this.refreshToken = response.refresh_token;
this.tokenType = response.token_type;
this.resetMasterPassword = this.getResponseProperty("ResetMasterPassword");
this.privateKey = this.getResponseProperty("PrivateKey");
this.key = this.getResponseProperty("Key");
this.twoFactorToken = this.getResponseProperty("TwoFactorToken");
this.kdf = this.getResponseProperty("Kdf");
this.kdfIterations = this.getResponseProperty("KdfIterations");
this.kdfMemory = this.getResponseProperty("KdfMemory");
this.kdfParallelism = this.getResponseProperty("KdfParallelism");
this.forcePasswordReset = this.getResponseProperty("ForcePasswordReset");
this.apiUseKeyConnector = this.getResponseProperty("ApiUseKeyConnector");
this.keyConnectorUrl = this.getResponseProperty("KeyConnectorUrl");
}
}

View File

@@ -1,24 +0,0 @@
import { TwoFactorProviderType } from "../../enums/twoFactorProviderType";
import { BaseResponse } from "./base.response";
export class IdentityTwoFactorResponse extends BaseResponse {
twoFactorProviders: TwoFactorProviderType[];
twoFactorProviders2 = new Map<TwoFactorProviderType, { [key: string]: string }>();
captchaToken: string;
constructor(response: any) {
super(response);
this.captchaToken = this.getResponseProperty("CaptchaBypassToken");
this.twoFactorProviders = this.getResponseProperty("TwoFactorProviders");
const twoFactorProviders2 = this.getResponseProperty("TwoFactorProviders2");
if (twoFactorProviders2 != null) {
for (const prop in twoFactorProviders2) {
// eslint-disable-next-line
if (twoFactorProviders2.hasOwnProperty(prop)) {
this.twoFactorProviders2.set(parseInt(prop, null), twoFactorProviders2[prop]);
}
}
}
}
}

View File

@@ -1,10 +0,0 @@
import { BaseResponse } from "./base.response";
export class KeyConnectorUserKeyResponse extends BaseResponse {
key: string;
constructor(response: any) {
super(response);
this.key = this.getResponseProperty("Key");
}
}

View File

@@ -1,4 +1,4 @@
import { OrganizationApiKeyType } from "../../enums/organizationApiKeyType";
import { OrganizationApiKeyType } from "../../auth/enums/organization-api-key-type";
import { BaseResponse } from "./base.response";

View File

@@ -1,37 +0,0 @@
import { SsoConfigApi } from "../../api/sso-config.api";
import { BaseResponse } from "../base.response";
export class OrganizationSsoResponse extends BaseResponse {
enabled: boolean;
identifier: string;
data: SsoConfigApi;
urls: SsoUrls;
constructor(response: any) {
super(response);
this.enabled = this.getResponseProperty("Enabled");
this.identifier = this.getResponseProperty("Identifier");
this.data =
this.getResponseProperty("Data") != null
? new SsoConfigApi(this.getResponseProperty("Data"))
: null;
this.urls = new SsoUrls(this.getResponseProperty("Urls"));
}
}
class SsoUrls extends BaseResponse {
callbackPath: string;
signedOutCallbackPath: string;
spEntityId: string;
spMetadataUrl: string;
spAcsUrl: string;
constructor(response: any) {
super(response);
this.callbackPath = this.getResponseProperty("CallbackPath");
this.signedOutCallbackPath = this.getResponseProperty("SignedOutCallbackPath");
this.spEntityId = this.getResponseProperty("SpEntityId");
this.spMetadataUrl = this.getResponseProperty("SpMetadataUrl");
this.spAcsUrl = this.getResponseProperty("SpAcsUrl");
}
}

View File

@@ -1,18 +0,0 @@
import { KdfType } from "../../enums/kdfType";
import { BaseResponse } from "./base.response";
export class PreloginResponse extends BaseResponse {
kdf: KdfType;
kdfIterations: number;
kdfMemory?: number;
kdfParallelism?: number;
constructor(response: any) {
super(response);
this.kdf = this.getResponseProperty("Kdf");
this.kdfIterations = this.getResponseProperty("KdfIterations");
this.kdfMemory = this.getResponseProperty("KdfMemory");
this.kdfParallelism = this.getResponseProperty("KdfParallelism");
}
}

View File

@@ -1,10 +0,0 @@
import { BaseResponse } from "./base.response";
export class SsoPreValidateResponse extends BaseResponse {
token: string;
constructor(response: any) {
super(response);
this.token = this.getResponseProperty("Token");
}
}

View File

@@ -1,12 +0,0 @@
import { BaseResponse } from "./base.response";
export class TwoFactorAuthenticatorResponse extends BaseResponse {
enabled: boolean;
key: string;
constructor(response: any) {
super(response);
this.enabled = this.getResponseProperty("Enabled");
this.key = this.getResponseProperty("Key");
}
}

View File

@@ -1,16 +0,0 @@
import { BaseResponse } from "./base.response";
export class TwoFactorDuoResponse extends BaseResponse {
enabled: boolean;
host: string;
secretKey: string;
integrationKey: string;
constructor(response: any) {
super(response);
this.enabled = this.getResponseProperty("Enabled");
this.host = this.getResponseProperty("Host");
this.secretKey = this.getResponseProperty("SecretKey");
this.integrationKey = this.getResponseProperty("IntegrationKey");
}
}

View File

@@ -1,12 +0,0 @@
import { BaseResponse } from "./base.response";
export class TwoFactorEmailResponse extends BaseResponse {
enabled: boolean;
email: string;
constructor(response: any) {
super(response);
this.enabled = this.getResponseProperty("Enabled");
this.email = this.getResponseProperty("Email");
}
}

View File

@@ -1,14 +0,0 @@
import { TwoFactorProviderType } from "../../enums/twoFactorProviderType";
import { BaseResponse } from "./base.response";
export class TwoFactorProviderResponse extends BaseResponse {
enabled: boolean;
type: TwoFactorProviderType;
constructor(response: any) {
super(response);
this.enabled = this.getResponseProperty("Enabled");
this.type = this.getResponseProperty("Type");
}
}

View File

@@ -1,10 +0,0 @@
import { BaseResponse } from "./base.response";
export class TwoFactorRecoverResponse extends BaseResponse {
code: string;
constructor(response: any) {
super(response);
this.code = this.getResponseProperty("Code");
}
}

View File

@@ -1,60 +0,0 @@
import { Utils } from "../../misc/utils";
import { BaseResponse } from "./base.response";
export class TwoFactorWebAuthnResponse extends BaseResponse {
enabled: boolean;
keys: KeyResponse[];
constructor(response: any) {
super(response);
this.enabled = this.getResponseProperty("Enabled");
const keys = this.getResponseProperty("Keys");
this.keys = keys == null ? null : keys.map((k: any) => new KeyResponse(k));
}
}
export class KeyResponse extends BaseResponse {
name: string;
id: number;
migrated: boolean;
constructor(response: any) {
super(response);
this.name = this.getResponseProperty("Name");
this.id = this.getResponseProperty("Id");
this.migrated = this.getResponseProperty("Migrated");
}
}
export class ChallengeResponse extends BaseResponse implements PublicKeyCredentialCreationOptions {
attestation?: AttestationConveyancePreference;
authenticatorSelection?: AuthenticatorSelectionCriteria;
challenge: BufferSource;
excludeCredentials?: PublicKeyCredentialDescriptor[];
extensions?: AuthenticationExtensionsClientInputs;
pubKeyCredParams: PublicKeyCredentialParameters[];
rp: PublicKeyCredentialRpEntity;
timeout?: number;
user: PublicKeyCredentialUserEntity;
constructor(response: any) {
super(response);
this.attestation = this.getResponseProperty("attestation");
this.authenticatorSelection = this.getResponseProperty("authenticatorSelection");
this.challenge = Utils.fromUrlB64ToArray(this.getResponseProperty("challenge"));
this.excludeCredentials = this.getResponseProperty("excludeCredentials").map((c: any) => {
c.id = Utils.fromUrlB64ToArray(c.id).buffer;
return c;
});
this.extensions = this.getResponseProperty("extensions");
this.pubKeyCredParams = this.getResponseProperty("pubKeyCredParams");
this.rp = this.getResponseProperty("rp");
this.timeout = this.getResponseProperty("timeout");
const user = this.getResponseProperty("user");
user.id = Utils.fromUrlB64ToArray(user.id);
this.user = user;
}
}

View File

@@ -1,22 +0,0 @@
import { BaseResponse } from "./base.response";
export class TwoFactorYubiKeyResponse extends BaseResponse {
enabled: boolean;
key1: string;
key2: string;
key3: string;
key4: string;
key5: string;
nfc: boolean;
constructor(response: any) {
super(response);
this.enabled = this.getResponseProperty("Enabled");
this.key1 = this.getResponseProperty("Key1");
this.key2 = this.getResponseProperty("Key2");
this.key3 = this.getResponseProperty("Key3");
this.key4 = this.getResponseProperty("Key4");
this.key5 = this.getResponseProperty("Key5");
this.nfc = this.getResponseProperty("Nfc");
}
}