1
0
mirror of https://github.com/bitwarden/directory-connector synced 2025-12-05 23:53:21 +00:00

Compare commits

..

6 Commits

Author SHA1 Message Date
github-actions[bot]
c999d40917 Bump version to 2.10.2 (#270)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
(cherry picked from commit 167c5e0108)
2022-05-03 12:12:22 -06:00
Robyn MacCallum
9d8ed5ea8d [EC-176] Fix CLI errors caused by server URLs (#269)
* Only get global environment urls

* remove unnecessary await
2022-05-03 07:35:44 -04:00
Thomas Rittson
f041c2b703 [EC-182] Refactor StateService secrets handling (#268) 2022-05-03 07:35:35 -04:00
github-actions[bot]
14a7833512 Bumped version to 2.10.1 (#265)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
(cherry picked from commit 2d02d54b56)
2022-04-25 08:49:25 -07:00
Joseph Flinn
94d3ece7a9 Bumping pinned commit of the download-artifact action to bypass the broken GitHub api (#260)
(cherry picked from commit 7753749b62)
2022-04-18 14:35:15 -07:00
Thomas Rittson
8981b97632 EC-134 Fix api token refresh (#257)
* Fix api token refresh

* Update jslib
2022-04-01 14:48:35 +10:00
13 changed files with 139 additions and 156 deletions

View File

@@ -61,7 +61,7 @@ jobs:
echo "::set-output name=branch-name::$BRANCH_NAME" echo "::set-output name=branch-name::$BRANCH_NAME"
- name: Download all artifacts - name: Download all artifacts
uses: bitwarden/gh-actions/download-artifacts@23433be15ed6fd046ce12b6889c5184a8d9c8783 uses: bitwarden/gh-actions/download-artifacts@c1fa8e09871a860862d6bbe36184b06d2c7e35a8
with: with:
workflow: build.yml workflow: build.yml
workflow_conclusion: success workflow_conclusion: success

2
jslib

Submodule jslib updated: 9950fb42a1...e595c0548e

View File

@@ -21,16 +21,6 @@ export abstract class StateService extends BaseStateServiceAbstraction<Account>
| OktaConfiguration | OktaConfiguration
| OneLoginConfiguration | OneLoginConfiguration
) => Promise<any>; ) => Promise<any>;
getLdapKey: (options?: StorageOptions) => Promise<string>;
setLdapKey: (value: string, options?: StorageOptions) => Promise<void>;
getGsuiteKey: (options?: StorageOptions) => Promise<string>;
setGsuiteKey: (value: string, options?: StorageOptions) => Promise<void>;
getAzureKey: (options?: StorageOptions) => Promise<string>;
setAzureKey: (value: string, options?: StorageOptions) => Promise<void>;
getOktaKey: (options?: StorageOptions) => Promise<string>;
setOktaKey: (value: string, options?: StorageOptions) => Promise<void>;
getOneLoginKey: (options?: StorageOptions) => Promise<string>;
setOneLoginKey: (value: string, options?: StorageOptions) => Promise<void>;
getLdapConfiguration: (options?: StorageOptions) => Promise<LdapConfiguration>; getLdapConfiguration: (options?: StorageOptions) => Promise<LdapConfiguration>;
setLdapConfiguration: (value: LdapConfiguration, options?: StorageOptions) => Promise<void>; setLdapConfiguration: (value: LdapConfiguration, options?: StorageOptions) => Promise<void>;
getGsuiteConfiguration: (options?: StorageOptions) => Promise<GSuiteConfiguration>; getGsuiteConfiguration: (options?: StorageOptions) => Promise<GSuiteConfiguration>;

View File

@@ -1,5 +0,0 @@
import { InjectionToken } from "@angular/core";
export const USE_SECURE_STORAGE_FOR_SECRETS = new InjectionToken<boolean>(
"USE_SECURE_STORAGE_FOR_SECRETS"
);

View File

@@ -9,12 +9,6 @@ import { CryptoService as CryptoServiceAbstraction } from "jslib-common/abstract
import { CryptoFunctionService as CryptoFunctionServiceAbstraction } from "jslib-common/abstractions/cryptoFunction.service"; import { CryptoFunctionService as CryptoFunctionServiceAbstraction } from "jslib-common/abstractions/cryptoFunction.service";
import { EnvironmentService as EnvironmentServiceAbstraction } from "jslib-common/abstractions/environment.service"; import { EnvironmentService as EnvironmentServiceAbstraction } from "jslib-common/abstractions/environment.service";
import { I18nService as I18nServiceAbstraction } from "jslib-common/abstractions/i18n.service"; import { I18nService as I18nServiceAbstraction } from "jslib-common/abstractions/i18n.service";
import {
CLIENT_TYPE,
SECURE_STORAGE,
STATE_FACTORY,
WINDOW_TOKEN,
} from "jslib-common/abstractions/injectionTokens";
import { KeyConnectorService as KeyConnectorServiceAbstraction } from "jslib-common/abstractions/keyConnector.service"; import { KeyConnectorService as KeyConnectorServiceAbstraction } from "jslib-common/abstractions/keyConnector.service";
import { LogService as LogServiceAbstraction } from "jslib-common/abstractions/log.service"; import { LogService as LogServiceAbstraction } from "jslib-common/abstractions/log.service";
import { MessagingService as MessagingServiceAbstraction } from "jslib-common/abstractions/messaging.service"; import { MessagingService as MessagingServiceAbstraction } from "jslib-common/abstractions/messaging.service";
@@ -23,7 +17,6 @@ import { StateMigrationService as StateMigrationServiceAbstraction } from "jslib
import { StorageService as StorageServiceAbstraction } from "jslib-common/abstractions/storage.service"; import { StorageService as StorageServiceAbstraction } from "jslib-common/abstractions/storage.service";
import { TokenService as TokenServiceAbstraction } from "jslib-common/abstractions/token.service"; import { TokenService as TokenServiceAbstraction } from "jslib-common/abstractions/token.service";
import { TwoFactorService as TwoFactorServiceAbstraction } from "jslib-common/abstractions/twoFactor.service"; import { TwoFactorService as TwoFactorServiceAbstraction } from "jslib-common/abstractions/twoFactor.service";
import { ClientType } from "jslib-common/enums/clientType";
import { StateFactory } from "jslib-common/factories/stateFactory"; import { StateFactory } from "jslib-common/factories/stateFactory";
import { GlobalState } from "jslib-common/models/domain/globalState"; import { GlobalState } from "jslib-common/models/domain/globalState";
import { ContainerService } from "jslib-common/services/container.service"; import { ContainerService } from "jslib-common/services/container.service";
@@ -37,7 +30,6 @@ import { NodeCryptoFunctionService } from "jslib-node/services/nodeCryptoFunctio
import { StateService as StateServiceAbstraction } from "../../abstractions/state.service"; import { StateService as StateServiceAbstraction } from "../../abstractions/state.service";
import { Account } from "../../models/account"; import { Account } from "../../models/account";
import { refreshToken } from "../../services/api.service";
import { AuthService } from "../../services/auth.service"; import { AuthService } from "../../services/auth.service";
import { I18nService } from "../../services/i18n.service"; import { I18nService } from "../../services/i18n.service";
import { NoopTwoFactorService } from "../../services/noop/noopTwoFactor.service"; import { NoopTwoFactorService } from "../../services/noop/noopTwoFactor.service";
@@ -46,17 +38,8 @@ import { StateMigrationService } from "../../services/stateMigration.service";
import { SyncService } from "../../services/sync.service"; import { SyncService } from "../../services/sync.service";
import { AuthGuardService } from "./auth-guard.service"; import { AuthGuardService } from "./auth-guard.service";
import { USE_SECURE_STORAGE_FOR_SECRETS } from "./injectionTokens";
import { LaunchGuardService } from "./launch-guard.service"; import { LaunchGuardService } from "./launch-guard.service";
function refreshTokenCallback(injector: Injector) {
return () => {
const stateService = injector.get(StateServiceAbstraction);
const authService = injector.get(AuthServiceAbstraction);
return refreshToken(stateService, authService);
};
}
export function initFactory( export function initFactory(
environmentService: EnvironmentServiceAbstraction, environmentService: EnvironmentServiceAbstraction,
i18nService: I18nService, i18nService: I18nService,
@@ -111,18 +94,23 @@ export function initFactory(
{ {
provide: I18nServiceAbstraction, provide: I18nServiceAbstraction,
useFactory: (window: Window) => new I18nService(window.navigator.language, "./locales"), useFactory: (window: Window) => new I18nService(window.navigator.language, "./locales"),
deps: [WINDOW_TOKEN], deps: ["WINDOW"],
}, },
{ {
provide: MessagingServiceAbstraction, provide: MessagingServiceAbstraction,
useClass: ElectronRendererMessagingService, useClass: ElectronRendererMessagingService,
deps: [BroadcasterServiceAbstraction],
}, },
{ provide: StorageServiceAbstraction, useClass: ElectronRendererStorageService }, { provide: StorageServiceAbstraction, useClass: ElectronRendererStorageService },
{ provide: SECURE_STORAGE, useClass: ElectronRendererSecureStorageService }, { provide: "SECURE_STORAGE", useClass: ElectronRendererSecureStorageService },
{ provide: CLIENT_TYPE, useValue: ClientType.DirectoryConnector },
{ {
provide: PlatformUtilsServiceAbstraction, provide: PlatformUtilsServiceAbstraction,
useClass: ElectronPlatformUtilsService, useFactory: (
i18nService: I18nServiceAbstraction,
messagingService: MessagingServiceAbstraction,
stateService: StateServiceAbstraction
) => new ElectronPlatformUtilsService(i18nService, messagingService, false, stateService),
deps: [I18nServiceAbstraction, MessagingServiceAbstraction, StateServiceAbstraction],
}, },
{ provide: CryptoFunctionServiceAbstraction, useClass: NodeCryptoFunctionService, deps: [] }, { provide: CryptoFunctionServiceAbstraction, useClass: NodeCryptoFunctionService, deps: [] },
{ {
@@ -132,53 +120,96 @@ export function initFactory(
platformUtilsService: PlatformUtilsServiceAbstraction, platformUtilsService: PlatformUtilsServiceAbstraction,
environmentService: EnvironmentServiceAbstraction, environmentService: EnvironmentServiceAbstraction,
messagingService: MessagingServiceAbstraction, messagingService: MessagingServiceAbstraction,
injector: Injector appIdService: AppIdServiceAbstraction
) => ) =>
new NodeApiService( new NodeApiService(
tokenService, tokenService,
platformUtilsService, platformUtilsService,
environmentService, environmentService,
appIdService,
async (expired: boolean) => messagingService.send("logout", { expired: expired }), async (expired: boolean) => messagingService.send("logout", { expired: expired }),
"Bitwarden_DC/" + "Bitwarden_DC/" +
platformUtilsService.getApplicationVersion() + platformUtilsService.getApplicationVersion() +
" (" + " (" +
platformUtilsService.getDeviceString().toUpperCase() + platformUtilsService.getDeviceString().toUpperCase() +
")", ")"
refreshTokenCallback(injector)
), ),
deps: [ deps: [
TokenServiceAbstraction, TokenServiceAbstraction,
PlatformUtilsServiceAbstraction, PlatformUtilsServiceAbstraction,
EnvironmentServiceAbstraction, EnvironmentServiceAbstraction,
MessagingServiceAbstraction, MessagingServiceAbstraction,
Injector, AppIdServiceAbstraction,
], ],
}, },
{ {
provide: AuthServiceAbstraction, provide: AuthServiceAbstraction,
useClass: AuthService, useClass: AuthService,
deps: [
CryptoServiceAbstraction,
ApiServiceAbstraction,
TokenServiceAbstraction,
AppIdServiceAbstraction,
PlatformUtilsServiceAbstraction,
MessagingServiceAbstraction,
LogServiceAbstraction,
KeyConnectorServiceAbstraction,
EnvironmentServiceAbstraction,
StateServiceAbstraction,
TwoFactorServiceAbstraction,
I18nServiceAbstraction,
],
}, },
{ {
provide: SyncService, provide: SyncService,
useClass: SyncService, useClass: SyncService,
deps: [
LogServiceAbstraction,
CryptoFunctionServiceAbstraction,
ApiServiceAbstraction,
MessagingServiceAbstraction,
I18nServiceAbstraction,
EnvironmentServiceAbstraction,
StateServiceAbstraction,
],
}, },
AuthGuardService, AuthGuardService,
LaunchGuardService, LaunchGuardService,
{
provide: STATE_FACTORY,
useFactory: () => new StateFactory(GlobalState, Account),
},
{
provide: USE_SECURE_STORAGE_FOR_SECRETS,
useValue: true,
},
{ {
provide: StateMigrationServiceAbstraction, provide: StateMigrationServiceAbstraction,
useClass: StateMigrationService, useFactory: (
storageService: StorageServiceAbstraction,
secureStorageService: StorageServiceAbstraction
) =>
new StateMigrationService(
storageService,
secureStorageService,
new StateFactory(GlobalState, Account)
),
deps: [StorageServiceAbstraction, "SECURE_STORAGE"],
}, },
{ {
provide: StateServiceAbstraction, provide: StateServiceAbstraction,
useClass: StateService, useFactory: (
storageService: StorageServiceAbstraction,
secureStorageService: StorageServiceAbstraction,
logService: LogServiceAbstraction,
stateMigrationService: StateMigrationServiceAbstraction
) =>
new StateService(
storageService,
secureStorageService,
logService,
stateMigrationService,
true,
new StateFactory(GlobalState, Account)
),
deps: [
StorageServiceAbstraction,
"SECURE_STORAGE",
LogServiceAbstraction,
StateMigrationServiceAbstraction,
],
}, },
{ {
provide: TwoFactorServiceAbstraction, provide: TwoFactorServiceAbstraction,

View File

@@ -7,7 +7,6 @@ import { ClientType } from "jslib-common/enums/clientType";
import { LogLevelType } from "jslib-common/enums/logLevelType"; import { LogLevelType } from "jslib-common/enums/logLevelType";
import { StateFactory } from "jslib-common/factories/stateFactory"; import { StateFactory } from "jslib-common/factories/stateFactory";
import { GlobalState } from "jslib-common/models/domain/globalState"; import { GlobalState } from "jslib-common/models/domain/globalState";
import { ApiLogInCredentials } from "jslib-common/models/domain/logInCredentials";
import { AppIdService } from "jslib-common/services/appId.service"; import { AppIdService } from "jslib-common/services/appId.service";
import { CipherService } from "jslib-common/services/cipher.service"; import { CipherService } from "jslib-common/services/cipher.service";
import { CollectionService } from "jslib-common/services/collection.service"; import { CollectionService } from "jslib-common/services/collection.service";
@@ -149,18 +148,20 @@ export class Main {
this.tokenService = new TokenService(this.stateService); this.tokenService = new TokenService(this.stateService);
this.messagingService = new NoopMessagingService(); this.messagingService = new NoopMessagingService();
this.environmentService = new EnvironmentService(this.stateService); this.environmentService = new EnvironmentService(this.stateService);
const customUserAgent =
"Bitwarden_DC/" +
this.platformUtilsService.getApplicationVersion() +
" (" +
this.platformUtilsService.getDeviceString().toUpperCase() +
")";
this.apiService = new NodeApiService( this.apiService = new NodeApiService(
this.tokenService, this.tokenService,
this.platformUtilsService, this.platformUtilsService,
this.environmentService, this.environmentService,
this.appIdService,
async (expired: boolean) => await this.logout(), async (expired: boolean) => await this.logout(),
"Bitwarden_DC/" + customUserAgent
this.platformUtilsService.getApplicationVersion() +
" (" +
this.platformUtilsService.getDeviceString().toUpperCase() +
")",
(clientId, clientSecret) =>
this.authService.logIn(new ApiLogInCredentials(clientId, clientSecret))
); );
this.containerService = new ContainerService(this.cryptoService); this.containerService = new ContainerService(this.cryptoService);

View File

@@ -2,7 +2,7 @@
"name": "@bitwarden/directory-connector", "name": "@bitwarden/directory-connector",
"productName": "Bitwarden Directory Connector", "productName": "Bitwarden Directory Connector",
"description": "Sync your user directory to your Bitwarden organization.", "description": "Sync your user directory to your Bitwarden organization.",
"version": "2.10.0", "version": "2.10.2",
"author": "Bitwarden Inc. <hello@bitwarden.com> (https://bitwarden.com)", "author": "Bitwarden Inc. <hello@bitwarden.com> (https://bitwarden.com)",
"homepage": "https://bitwarden.com", "homepage": "https://bitwarden.com",
"license": "GPL-3.0", "license": "GPL-3.0",

View File

@@ -1,37 +0,0 @@
import { AuthService } from "jslib-common/abstractions/auth.service";
import { EnvironmentService } from "jslib-common/abstractions/environment.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { TokenService } from "jslib-common/abstractions/token.service";
import { ApiLogInCredentials } from "jslib-common/models/domain/logInCredentials";
import { ApiService as ApiServiceBase } from "jslib-common/services/api.service";
import { StateService } from "../abstractions/state.service";
export async function refreshToken(stateService: StateService, authService: AuthService) {
try {
const clientId = await stateService.getApiKeyClientId();
const clientSecret = await stateService.getApiKeyClientSecret();
if (clientId != null && clientSecret != null) {
await authService.logIn(new ApiLogInCredentials(clientId, clientSecret));
}
} catch (e) {
return Promise.reject(e);
}
}
export class ApiService extends ApiServiceBase {
constructor(
tokenService: TokenService,
platformUtilsService: PlatformUtilsService,
environmentService: EnvironmentService,
private refreshTokenCallback: () => Promise<void>,
logoutCallback: (expired: boolean) => Promise<void>,
customUserAgent: string = null
) {
super(tokenService, platformUtilsService, environmentService, logoutCallback, customUserAgent);
}
doRefreshToken(): Promise<void> {
return this.refreshTokenCallback();
}
}

View File

@@ -1,5 +1,3 @@
import { Injectable } from "@angular/core";
import { ApiService } from "jslib-common/abstractions/api.service"; import { ApiService } from "jslib-common/abstractions/api.service";
import { AppIdService } from "jslib-common/abstractions/appId.service"; import { AppIdService } from "jslib-common/abstractions/appId.service";
import { CryptoService } from "jslib-common/abstractions/crypto.service"; import { CryptoService } from "jslib-common/abstractions/crypto.service";
@@ -18,7 +16,6 @@ import { AuthService as AuthServiceBase } from "jslib-common/services/auth.servi
import { StateService } from "../abstractions/state.service"; import { StateService } from "../abstractions/state.service";
import { OrganizationLogInStrategy } from "../misc/logInStrategies/organizationLogIn.strategy"; import { OrganizationLogInStrategy } from "../misc/logInStrategies/organizationLogIn.strategy";
@Injectable()
export class AuthService extends AuthServiceBase { export class AuthService extends AuthServiceBase {
constructor( constructor(
cryptoService: CryptoService, cryptoService: CryptoService,

View File

@@ -1,16 +1,13 @@
import { Inject, Injectable } from "@angular/core";
import { SECURE_STORAGE, STATE_FACTORY } from "jslib-common/abstractions/injectionTokens";
import { LogService } from "jslib-common/abstractions/log.service"; import { LogService } from "jslib-common/abstractions/log.service";
import { StateMigrationService } from "jslib-common/abstractions/stateMigration.service"; import { StateMigrationService } from "jslib-common/abstractions/stateMigration.service";
import { StorageService } from "jslib-common/abstractions/storage.service"; import { StorageService } from "jslib-common/abstractions/storage.service";
import { StateFactory } from "jslib-common/factories/stateFactory"; import { StateFactory } from "jslib-common/factories/stateFactory";
import { EnvironmentUrls } from "jslib-common/models/domain/environmentUrls";
import { GlobalState } from "jslib-common/models/domain/globalState"; import { GlobalState } from "jslib-common/models/domain/globalState";
import { StorageOptions } from "jslib-common/models/domain/storageOptions"; import { StorageOptions } from "jslib-common/models/domain/storageOptions";
import { StateService as BaseStateService } from "jslib-common/services/state.service"; import { StateService as BaseStateService } from "jslib-common/services/state.service";
import { StateService as StateServiceAbstraction } from "src/abstractions/state.service"; import { StateService as StateServiceAbstraction } from "src/abstractions/state.service";
import { USE_SECURE_STORAGE_FOR_SECRETS } from "src/app/services/injectionTokens";
import { DirectoryType } from "src/enums/directoryType"; import { DirectoryType } from "src/enums/directoryType";
import { IConfiguration } from "src/models/IConfiguration"; import { IConfiguration } from "src/models/IConfiguration";
import { Account } from "src/models/account"; import { Account } from "src/models/account";
@@ -21,7 +18,6 @@ import { OktaConfiguration } from "src/models/oktaConfiguration";
import { OneLoginConfiguration } from "src/models/oneLoginConfiguration"; import { OneLoginConfiguration } from "src/models/oneLoginConfiguration";
import { SyncConfiguration } from "src/models/syncConfiguration"; import { SyncConfiguration } from "src/models/syncConfiguration";
const SecureStorageKeys = { const SecureStorageKeys = {
ldap: "ldapPassword", ldap: "ldapPassword",
gsuite: "gsuitePrivateKey", gsuite: "gsuitePrivateKey",
@@ -43,18 +39,17 @@ const keys = {
const StoredSecurely = "[STORED SECURELY]"; const StoredSecurely = "[STORED SECURELY]";
@Injectable()
export class StateService export class StateService
extends BaseStateService<GlobalState, Account> extends BaseStateService<GlobalState, Account>
implements StateServiceAbstraction implements StateServiceAbstraction
{ {
constructor( constructor(
protected storageService: StorageService, protected storageService: StorageService,
@Inject(SECURE_STORAGE) protected secureStorageService: StorageService, protected secureStorageService: StorageService,
protected logService: LogService, protected logService: LogService,
protected stateMigrationService: StateMigrationService, protected stateMigrationService: StateMigrationService,
@Inject(USE_SECURE_STORAGE_FOR_SECRETS) private useSecureStorageForSecrets = true, private useSecureStorageForSecrets = true,
@Inject(STATE_FACTORY) protected stateFactory: StateFactory<GlobalState, Account> protected stateFactory: StateFactory<GlobalState, Account>
) { ) {
super(storageService, secureStorageService, logService, stateMigrationService, stateFactory); super(storageService, secureStorageService, logService, stateMigrationService, stateFactory);
} }
@@ -66,24 +61,30 @@ export class StateService
} }
if (this.useSecureStorageForSecrets) { if (this.useSecureStorageForSecrets) {
// Do not introduce secrets into the in-memory account object
const configWithSecrets = Object.assign({}, config);
switch (type) { switch (type) {
case DirectoryType.Ldap: case DirectoryType.Ldap:
(config as any).password = await this.getLdapKey(); (configWithSecrets as any).password = await this.getLdapKey();
break; break;
case DirectoryType.AzureActiveDirectory: case DirectoryType.AzureActiveDirectory:
(config as any).key = await this.getAzureKey(); (configWithSecrets as any).key = await this.getAzureKey();
break; break;
case DirectoryType.Okta: case DirectoryType.Okta:
(config as any).token = await this.getOktaKey(); (configWithSecrets as any).token = await this.getOktaKey();
break; break;
case DirectoryType.GSuite: case DirectoryType.GSuite:
(config as any).privateKey = await this.getGsuiteKey(); (configWithSecrets as any).privateKey = await this.getGsuiteKey();
break; break;
case DirectoryType.OneLogin: case DirectoryType.OneLogin:
(config as any).clientSecret = await this.getOneLoginKey(); (configWithSecrets as any).clientSecret = await this.getOneLoginKey();
break; break;
} }
return configWithSecrets as T;
} }
return config as T; return config as T;
} }
@@ -96,45 +97,53 @@ export class StateService
| OktaConfiguration | OktaConfiguration
| OneLoginConfiguration | OneLoginConfiguration
): Promise<any> { ): Promise<any> {
const savedConfig: any = Object.assign({}, config);
if (this.useSecureStorageForSecrets) { if (this.useSecureStorageForSecrets) {
switch (type) { switch (type) {
case DirectoryType.Ldap: case DirectoryType.Ldap: {
await this.setLdapKey(savedConfig.password); const ldapConfig = config as LdapConfiguration;
savedConfig.password = StoredSecurely; await this.setLdapKey(ldapConfig.password);
await this.setLdapConfiguration(savedConfig); ldapConfig.password = StoredSecurely;
await this.setLdapConfiguration(ldapConfig);
break; break;
case DirectoryType.AzureActiveDirectory: }
await this.setAzureKey(savedConfig.key); case DirectoryType.AzureActiveDirectory: {
savedConfig.key = StoredSecurely; const azureConfig = config as AzureConfiguration;
await this.setAzureConfiguration(savedConfig); await this.setAzureKey(azureConfig.key);
azureConfig.key = StoredSecurely;
await this.setAzureConfiguration(azureConfig);
break; break;
case DirectoryType.Okta: }
await this.setOktaKey(savedConfig.token); case DirectoryType.Okta: {
savedConfig.token = StoredSecurely; const oktaConfig = config as OktaConfiguration;
await this.setOktaConfiguration(savedConfig); await this.setOktaKey(oktaConfig.token);
oktaConfig.token = StoredSecurely;
await this.setOktaConfiguration(oktaConfig);
break; break;
case DirectoryType.GSuite: }
if (savedConfig.privateKey == null) { case DirectoryType.GSuite: {
const gsuiteConfig = config as GSuiteConfiguration;
if (gsuiteConfig.privateKey == null) {
await this.setGsuiteKey(null); await this.setGsuiteKey(null);
} else { } else {
(config as GSuiteConfiguration).privateKey = savedConfig.privateKey = const normalizedPrivateKey = gsuiteConfig.privateKey.replace(/\\n/g, "\n");
savedConfig.privateKey.replace(/\\n/g, "\n"); await this.setGsuiteKey(normalizedPrivateKey);
await this.setGsuiteKey(savedConfig.privateKey); gsuiteConfig.privateKey = StoredSecurely;
savedConfig.privateKey = StoredSecurely;
} }
await this.setGsuiteConfiguration(savedConfig); await this.setGsuiteConfiguration(gsuiteConfig);
break; break;
case DirectoryType.OneLogin: }
await this.setOneLoginKey(savedConfig.clientSecret); case DirectoryType.OneLogin: {
savedConfig.clientSecret = StoredSecurely; const oneLoginConfig = config as OneLoginConfiguration;
await this.setOneLoginConfiguration(savedConfig); await this.setOneLoginKey(oneLoginConfig.clientSecret);
oneLoginConfig.clientSecret = StoredSecurely;
await this.setOneLoginConfiguration(oneLoginConfig);
break; break;
}
} }
} }
} }
async getLdapKey(options?: StorageOptions): Promise<string> { private async getLdapKey(options?: StorageOptions): Promise<string> {
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions()); options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
if (options?.userId == null) { if (options?.userId == null) {
return null; return null;
@@ -144,7 +153,7 @@ export class StateService
); );
} }
async setLdapKey(value: string, options?: StorageOptions): Promise<void> { private async setLdapKey(value: string, options?: StorageOptions): Promise<void> {
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions()); options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
if (options?.userId == null) { if (options?.userId == null) {
return; return;
@@ -156,7 +165,7 @@ export class StateService
); );
} }
async getGsuiteKey(options?: StorageOptions): Promise<string> { private async getGsuiteKey(options?: StorageOptions): Promise<string> {
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions()); options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
if (options?.userId == null) { if (options?.userId == null) {
return null; return null;
@@ -166,7 +175,7 @@ export class StateService
); );
} }
async setGsuiteKey(value: string, options?: StorageOptions): Promise<void> { private async setGsuiteKey(value: string, options?: StorageOptions): Promise<void> {
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions()); options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
if (options?.userId == null) { if (options?.userId == null) {
return; return;
@@ -178,7 +187,7 @@ export class StateService
); );
} }
async getAzureKey(options?: StorageOptions): Promise<string> { private async getAzureKey(options?: StorageOptions): Promise<string> {
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions()); options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
if (options?.userId == null) { if (options?.userId == null) {
return null; return null;
@@ -188,7 +197,7 @@ export class StateService
); );
} }
async setAzureKey(value: string, options?: StorageOptions): Promise<void> { private async setAzureKey(value: string, options?: StorageOptions): Promise<void> {
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions()); options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
if (options?.userId == null) { if (options?.userId == null) {
return; return;
@@ -200,7 +209,7 @@ export class StateService
); );
} }
async getOktaKey(options?: StorageOptions): Promise<string> { private async getOktaKey(options?: StorageOptions): Promise<string> {
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions()); options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
if (options?.userId == null) { if (options?.userId == null) {
return null; return null;
@@ -210,7 +219,7 @@ export class StateService
); );
} }
async setOktaKey(value: string, options?: StorageOptions): Promise<void> { private async setOktaKey(value: string, options?: StorageOptions): Promise<void> {
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions()); options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
if (options?.userId == null) { if (options?.userId == null) {
return; return;
@@ -222,7 +231,7 @@ export class StateService
); );
} }
async getOneLoginKey(options?: StorageOptions): Promise<string> { private async getOneLoginKey(options?: StorageOptions): Promise<string> {
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions()); options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
if (options?.userId == null) { if (options?.userId == null) {
return null; return null;
@@ -232,7 +241,7 @@ export class StateService
); );
} }
async setOneLoginKey(value: string, options?: StorageOptions): Promise<void> { private async setOneLoginKey(value: string, options?: StorageOptions): Promise<void> {
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions()); options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
if (options?.userId == null) { if (options?.userId == null) {
return; return;
@@ -574,4 +583,8 @@ export class StateService
}; };
return Object.assign(this.createAccount(), persistentAccountInformation); return Object.assign(this.createAccount(), persistentAccountInformation);
} }
async getEnvironmentUrls(options?: StorageOptions): Promise<EnvironmentUrls> {
return this.getGlobalEnvironmentUrls(options);
}
} }

View File

@@ -1,5 +1,3 @@
import { Injectable } from "@angular/core";
import { StateVersion } from "jslib-common/enums/stateVersion"; import { StateVersion } from "jslib-common/enums/stateVersion";
import { StateMigrationService as BaseStateMigrationService } from "jslib-common/services/stateMigration.service"; import { StateMigrationService as BaseStateMigrationService } from "jslib-common/services/stateMigration.service";
@@ -51,7 +49,6 @@ const ClientKeys: { [key: string]: any } = {
clientSecret: "apikey_clientSecret", clientSecret: "apikey_clientSecret",
}; };
@Injectable()
export class StateMigrationService extends BaseStateMigrationService { export class StateMigrationService extends BaseStateMigrationService {
async migrate(): Promise<void> { async migrate(): Promise<void> {
let currentStateVersion = await this.getCurrentStateVersion(); let currentStateVersion = await this.getCurrentStateVersion();

View File

@@ -1,5 +1,3 @@
import { Injectable } from "@angular/core";
import { ApiService } from "jslib-common/abstractions/api.service"; import { ApiService } from "jslib-common/abstractions/api.service";
import { CryptoFunctionService } from "jslib-common/abstractions/cryptoFunction.service"; import { CryptoFunctionService } from "jslib-common/abstractions/cryptoFunction.service";
import { EnvironmentService } from "jslib-common/abstractions/environment.service"; import { EnvironmentService } from "jslib-common/abstractions/environment.service";
@@ -22,7 +20,6 @@ import { LdapDirectoryService } from "./ldap-directory.service";
import { OktaDirectoryService } from "./okta-directory.service"; import { OktaDirectoryService } from "./okta-directory.service";
import { OneLoginDirectoryService } from "./onelogin-directory.service"; import { OneLoginDirectoryService } from "./onelogin-directory.service";
@Injectable()
export class SyncService { export class SyncService {
private dirType: DirectoryType; private dirType: DirectoryType;

View File

@@ -39,7 +39,6 @@ const plugins = [
resourceRegExp: /^encoding$/, resourceRegExp: /^encoding$/,
contextRegExp: /node-fetch/, contextRegExp: /node-fetch/,
}), }),
new webpack.NormalModuleReplacementPlugin(/@angular\/core/, "jslib-node/angular-core.noop"),
]; ];
const config = { const config = {