mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-05 23:53:21 +00:00
Compare commits
2 Commits
v2.10.2
...
refactor/i
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
acc3473731 | ||
|
|
c80805ded6 |
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -61,7 +61,7 @@ jobs:
|
||||
echo "::set-output name=branch-name::$BRANCH_NAME"
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: bitwarden/gh-actions/download-artifacts@c1fa8e09871a860862d6bbe36184b06d2c7e35a8
|
||||
uses: bitwarden/gh-actions/download-artifacts@23433be15ed6fd046ce12b6889c5184a8d9c8783
|
||||
with:
|
||||
workflow: build.yml
|
||||
workflow_conclusion: success
|
||||
|
||||
2
jslib
2
jslib
Submodule jslib updated: e595c0548e...9950fb42a1
@@ -21,6 +21,16 @@ export abstract class StateService extends BaseStateServiceAbstraction<Account>
|
||||
| OktaConfiguration
|
||||
| OneLoginConfiguration
|
||||
) => 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>;
|
||||
setLdapConfiguration: (value: LdapConfiguration, options?: StorageOptions) => Promise<void>;
|
||||
getGsuiteConfiguration: (options?: StorageOptions) => Promise<GSuiteConfiguration>;
|
||||
|
||||
5
src/app/services/injectionTokens.ts
Normal file
5
src/app/services/injectionTokens.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { InjectionToken } from "@angular/core";
|
||||
|
||||
export const USE_SECURE_STORAGE_FOR_SECRETS = new InjectionToken<boolean>(
|
||||
"USE_SECURE_STORAGE_FOR_SECRETS"
|
||||
);
|
||||
@@ -9,6 +9,12 @@ import { CryptoService as CryptoServiceAbstraction } from "jslib-common/abstract
|
||||
import { CryptoFunctionService as CryptoFunctionServiceAbstraction } from "jslib-common/abstractions/cryptoFunction.service";
|
||||
import { EnvironmentService as EnvironmentServiceAbstraction } from "jslib-common/abstractions/environment.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 { LogService as LogServiceAbstraction } from "jslib-common/abstractions/log.service";
|
||||
import { MessagingService as MessagingServiceAbstraction } from "jslib-common/abstractions/messaging.service";
|
||||
@@ -17,6 +23,7 @@ import { StateMigrationService as StateMigrationServiceAbstraction } from "jslib
|
||||
import { StorageService as StorageServiceAbstraction } from "jslib-common/abstractions/storage.service";
|
||||
import { TokenService as TokenServiceAbstraction } from "jslib-common/abstractions/token.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 { GlobalState } from "jslib-common/models/domain/globalState";
|
||||
import { ContainerService } from "jslib-common/services/container.service";
|
||||
@@ -30,6 +37,7 @@ import { NodeCryptoFunctionService } from "jslib-node/services/nodeCryptoFunctio
|
||||
|
||||
import { StateService as StateServiceAbstraction } from "../../abstractions/state.service";
|
||||
import { Account } from "../../models/account";
|
||||
import { refreshToken } from "../../services/api.service";
|
||||
import { AuthService } from "../../services/auth.service";
|
||||
import { I18nService } from "../../services/i18n.service";
|
||||
import { NoopTwoFactorService } from "../../services/noop/noopTwoFactor.service";
|
||||
@@ -38,8 +46,17 @@ import { StateMigrationService } from "../../services/stateMigration.service";
|
||||
import { SyncService } from "../../services/sync.service";
|
||||
|
||||
import { AuthGuardService } from "./auth-guard.service";
|
||||
import { USE_SECURE_STORAGE_FOR_SECRETS } from "./injectionTokens";
|
||||
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(
|
||||
environmentService: EnvironmentServiceAbstraction,
|
||||
i18nService: I18nService,
|
||||
@@ -94,23 +111,18 @@ export function initFactory(
|
||||
{
|
||||
provide: I18nServiceAbstraction,
|
||||
useFactory: (window: Window) => new I18nService(window.navigator.language, "./locales"),
|
||||
deps: ["WINDOW"],
|
||||
deps: [WINDOW_TOKEN],
|
||||
},
|
||||
{
|
||||
provide: MessagingServiceAbstraction,
|
||||
useClass: ElectronRendererMessagingService,
|
||||
deps: [BroadcasterServiceAbstraction],
|
||||
},
|
||||
{ provide: StorageServiceAbstraction, useClass: ElectronRendererStorageService },
|
||||
{ provide: "SECURE_STORAGE", useClass: ElectronRendererSecureStorageService },
|
||||
{ provide: SECURE_STORAGE, useClass: ElectronRendererSecureStorageService },
|
||||
{ provide: CLIENT_TYPE, useValue: ClientType.DirectoryConnector },
|
||||
{
|
||||
provide: PlatformUtilsServiceAbstraction,
|
||||
useFactory: (
|
||||
i18nService: I18nServiceAbstraction,
|
||||
messagingService: MessagingServiceAbstraction,
|
||||
stateService: StateServiceAbstraction
|
||||
) => new ElectronPlatformUtilsService(i18nService, messagingService, false, stateService),
|
||||
deps: [I18nServiceAbstraction, MessagingServiceAbstraction, StateServiceAbstraction],
|
||||
useClass: ElectronPlatformUtilsService,
|
||||
},
|
||||
{ provide: CryptoFunctionServiceAbstraction, useClass: NodeCryptoFunctionService, deps: [] },
|
||||
{
|
||||
@@ -120,96 +132,53 @@ export function initFactory(
|
||||
platformUtilsService: PlatformUtilsServiceAbstraction,
|
||||
environmentService: EnvironmentServiceAbstraction,
|
||||
messagingService: MessagingServiceAbstraction,
|
||||
appIdService: AppIdServiceAbstraction
|
||||
injector: Injector
|
||||
) =>
|
||||
new NodeApiService(
|
||||
tokenService,
|
||||
platformUtilsService,
|
||||
environmentService,
|
||||
appIdService,
|
||||
async (expired: boolean) => messagingService.send("logout", { expired: expired }),
|
||||
"Bitwarden_DC/" +
|
||||
platformUtilsService.getApplicationVersion() +
|
||||
" (" +
|
||||
platformUtilsService.getDeviceString().toUpperCase() +
|
||||
")"
|
||||
")",
|
||||
refreshTokenCallback(injector)
|
||||
),
|
||||
deps: [
|
||||
TokenServiceAbstraction,
|
||||
PlatformUtilsServiceAbstraction,
|
||||
EnvironmentServiceAbstraction,
|
||||
MessagingServiceAbstraction,
|
||||
AppIdServiceAbstraction,
|
||||
Injector,
|
||||
],
|
||||
},
|
||||
{
|
||||
provide: AuthServiceAbstraction,
|
||||
useClass: AuthService,
|
||||
deps: [
|
||||
CryptoServiceAbstraction,
|
||||
ApiServiceAbstraction,
|
||||
TokenServiceAbstraction,
|
||||
AppIdServiceAbstraction,
|
||||
PlatformUtilsServiceAbstraction,
|
||||
MessagingServiceAbstraction,
|
||||
LogServiceAbstraction,
|
||||
KeyConnectorServiceAbstraction,
|
||||
EnvironmentServiceAbstraction,
|
||||
StateServiceAbstraction,
|
||||
TwoFactorServiceAbstraction,
|
||||
I18nServiceAbstraction,
|
||||
],
|
||||
},
|
||||
{
|
||||
provide: SyncService,
|
||||
useClass: SyncService,
|
||||
deps: [
|
||||
LogServiceAbstraction,
|
||||
CryptoFunctionServiceAbstraction,
|
||||
ApiServiceAbstraction,
|
||||
MessagingServiceAbstraction,
|
||||
I18nServiceAbstraction,
|
||||
EnvironmentServiceAbstraction,
|
||||
StateServiceAbstraction,
|
||||
],
|
||||
},
|
||||
AuthGuardService,
|
||||
LaunchGuardService,
|
||||
{
|
||||
provide: STATE_FACTORY,
|
||||
useFactory: () => new StateFactory(GlobalState, Account),
|
||||
},
|
||||
{
|
||||
provide: USE_SECURE_STORAGE_FOR_SECRETS,
|
||||
useValue: true,
|
||||
},
|
||||
{
|
||||
provide: StateMigrationServiceAbstraction,
|
||||
useFactory: (
|
||||
storageService: StorageServiceAbstraction,
|
||||
secureStorageService: StorageServiceAbstraction
|
||||
) =>
|
||||
new StateMigrationService(
|
||||
storageService,
|
||||
secureStorageService,
|
||||
new StateFactory(GlobalState, Account)
|
||||
),
|
||||
deps: [StorageServiceAbstraction, "SECURE_STORAGE"],
|
||||
useClass: StateMigrationService,
|
||||
},
|
||||
{
|
||||
provide: StateServiceAbstraction,
|
||||
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,
|
||||
],
|
||||
useClass: StateService,
|
||||
},
|
||||
{
|
||||
provide: TwoFactorServiceAbstraction,
|
||||
|
||||
17
src/bwdc.ts
17
src/bwdc.ts
@@ -7,6 +7,7 @@ import { ClientType } from "jslib-common/enums/clientType";
|
||||
import { LogLevelType } from "jslib-common/enums/logLevelType";
|
||||
import { StateFactory } from "jslib-common/factories/stateFactory";
|
||||
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 { CipherService } from "jslib-common/services/cipher.service";
|
||||
import { CollectionService } from "jslib-common/services/collection.service";
|
||||
@@ -148,20 +149,18 @@ export class Main {
|
||||
this.tokenService = new TokenService(this.stateService);
|
||||
this.messagingService = new NoopMessagingService();
|
||||
this.environmentService = new EnvironmentService(this.stateService);
|
||||
|
||||
const customUserAgent =
|
||||
"Bitwarden_DC/" +
|
||||
this.platformUtilsService.getApplicationVersion() +
|
||||
" (" +
|
||||
this.platformUtilsService.getDeviceString().toUpperCase() +
|
||||
")";
|
||||
this.apiService = new NodeApiService(
|
||||
this.tokenService,
|
||||
this.platformUtilsService,
|
||||
this.environmentService,
|
||||
this.appIdService,
|
||||
async (expired: boolean) => await this.logout(),
|
||||
customUserAgent
|
||||
"Bitwarden_DC/" +
|
||||
this.platformUtilsService.getApplicationVersion() +
|
||||
" (" +
|
||||
this.platformUtilsService.getDeviceString().toUpperCase() +
|
||||
")",
|
||||
(clientId, clientSecret) =>
|
||||
this.authService.logIn(new ApiLogInCredentials(clientId, clientSecret))
|
||||
);
|
||||
this.containerService = new ContainerService(this.cryptoService);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "@bitwarden/directory-connector",
|
||||
"productName": "Bitwarden Directory Connector",
|
||||
"description": "Sync your user directory to your Bitwarden organization.",
|
||||
"version": "2.10.2",
|
||||
"version": "2.10.0",
|
||||
"author": "Bitwarden Inc. <hello@bitwarden.com> (https://bitwarden.com)",
|
||||
"homepage": "https://bitwarden.com",
|
||||
"license": "GPL-3.0",
|
||||
|
||||
37
src/services/api.service.ts
Normal file
37
src/services/api.service.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
|
||||
import { ApiService } from "jslib-common/abstractions/api.service";
|
||||
import { AppIdService } from "jslib-common/abstractions/appId.service";
|
||||
import { CryptoService } from "jslib-common/abstractions/crypto.service";
|
||||
@@ -16,6 +18,7 @@ import { AuthService as AuthServiceBase } from "jslib-common/services/auth.servi
|
||||
import { StateService } from "../abstractions/state.service";
|
||||
import { OrganizationLogInStrategy } from "../misc/logInStrategies/organizationLogIn.strategy";
|
||||
|
||||
@Injectable()
|
||||
export class AuthService extends AuthServiceBase {
|
||||
constructor(
|
||||
cryptoService: CryptoService,
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
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 { StateMigrationService } from "jslib-common/abstractions/stateMigration.service";
|
||||
import { StorageService } from "jslib-common/abstractions/storage.service";
|
||||
import { StateFactory } from "jslib-common/factories/stateFactory";
|
||||
import { EnvironmentUrls } from "jslib-common/models/domain/environmentUrls";
|
||||
import { GlobalState } from "jslib-common/models/domain/globalState";
|
||||
import { StorageOptions } from "jslib-common/models/domain/storageOptions";
|
||||
import { StateService as BaseStateService } from "jslib-common/services/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 { IConfiguration } from "src/models/IConfiguration";
|
||||
import { Account } from "src/models/account";
|
||||
@@ -18,6 +21,7 @@ import { OktaConfiguration } from "src/models/oktaConfiguration";
|
||||
import { OneLoginConfiguration } from "src/models/oneLoginConfiguration";
|
||||
import { SyncConfiguration } from "src/models/syncConfiguration";
|
||||
|
||||
|
||||
const SecureStorageKeys = {
|
||||
ldap: "ldapPassword",
|
||||
gsuite: "gsuitePrivateKey",
|
||||
@@ -39,17 +43,18 @@ const keys = {
|
||||
|
||||
const StoredSecurely = "[STORED SECURELY]";
|
||||
|
||||
@Injectable()
|
||||
export class StateService
|
||||
extends BaseStateService<GlobalState, Account>
|
||||
implements StateServiceAbstraction
|
||||
{
|
||||
constructor(
|
||||
protected storageService: StorageService,
|
||||
protected secureStorageService: StorageService,
|
||||
@Inject(SECURE_STORAGE) protected secureStorageService: StorageService,
|
||||
protected logService: LogService,
|
||||
protected stateMigrationService: StateMigrationService,
|
||||
private useSecureStorageForSecrets = true,
|
||||
protected stateFactory: StateFactory<GlobalState, Account>
|
||||
@Inject(USE_SECURE_STORAGE_FOR_SECRETS) private useSecureStorageForSecrets = true,
|
||||
@Inject(STATE_FACTORY) protected stateFactory: StateFactory<GlobalState, Account>
|
||||
) {
|
||||
super(storageService, secureStorageService, logService, stateMigrationService, stateFactory);
|
||||
}
|
||||
@@ -61,30 +66,24 @@ export class StateService
|
||||
}
|
||||
|
||||
if (this.useSecureStorageForSecrets) {
|
||||
// Do not introduce secrets into the in-memory account object
|
||||
const configWithSecrets = Object.assign({}, config);
|
||||
|
||||
switch (type) {
|
||||
case DirectoryType.Ldap:
|
||||
(configWithSecrets as any).password = await this.getLdapKey();
|
||||
(config as any).password = await this.getLdapKey();
|
||||
break;
|
||||
case DirectoryType.AzureActiveDirectory:
|
||||
(configWithSecrets as any).key = await this.getAzureKey();
|
||||
(config as any).key = await this.getAzureKey();
|
||||
break;
|
||||
case DirectoryType.Okta:
|
||||
(configWithSecrets as any).token = await this.getOktaKey();
|
||||
(config as any).token = await this.getOktaKey();
|
||||
break;
|
||||
case DirectoryType.GSuite:
|
||||
(configWithSecrets as any).privateKey = await this.getGsuiteKey();
|
||||
(config as any).privateKey = await this.getGsuiteKey();
|
||||
break;
|
||||
case DirectoryType.OneLogin:
|
||||
(configWithSecrets as any).clientSecret = await this.getOneLoginKey();
|
||||
(config as any).clientSecret = await this.getOneLoginKey();
|
||||
break;
|
||||
}
|
||||
|
||||
return configWithSecrets as T;
|
||||
}
|
||||
|
||||
return config as T;
|
||||
}
|
||||
|
||||
@@ -97,53 +96,45 @@ export class StateService
|
||||
| OktaConfiguration
|
||||
| OneLoginConfiguration
|
||||
): Promise<any> {
|
||||
const savedConfig: any = Object.assign({}, config);
|
||||
if (this.useSecureStorageForSecrets) {
|
||||
switch (type) {
|
||||
case DirectoryType.Ldap: {
|
||||
const ldapConfig = config as LdapConfiguration;
|
||||
await this.setLdapKey(ldapConfig.password);
|
||||
ldapConfig.password = StoredSecurely;
|
||||
await this.setLdapConfiguration(ldapConfig);
|
||||
case DirectoryType.Ldap:
|
||||
await this.setLdapKey(savedConfig.password);
|
||||
savedConfig.password = StoredSecurely;
|
||||
await this.setLdapConfiguration(savedConfig);
|
||||
break;
|
||||
}
|
||||
case DirectoryType.AzureActiveDirectory: {
|
||||
const azureConfig = config as AzureConfiguration;
|
||||
await this.setAzureKey(azureConfig.key);
|
||||
azureConfig.key = StoredSecurely;
|
||||
await this.setAzureConfiguration(azureConfig);
|
||||
case DirectoryType.AzureActiveDirectory:
|
||||
await this.setAzureKey(savedConfig.key);
|
||||
savedConfig.key = StoredSecurely;
|
||||
await this.setAzureConfiguration(savedConfig);
|
||||
break;
|
||||
}
|
||||
case DirectoryType.Okta: {
|
||||
const oktaConfig = config as OktaConfiguration;
|
||||
await this.setOktaKey(oktaConfig.token);
|
||||
oktaConfig.token = StoredSecurely;
|
||||
await this.setOktaConfiguration(oktaConfig);
|
||||
case DirectoryType.Okta:
|
||||
await this.setOktaKey(savedConfig.token);
|
||||
savedConfig.token = StoredSecurely;
|
||||
await this.setOktaConfiguration(savedConfig);
|
||||
break;
|
||||
}
|
||||
case DirectoryType.GSuite: {
|
||||
const gsuiteConfig = config as GSuiteConfiguration;
|
||||
if (gsuiteConfig.privateKey == null) {
|
||||
case DirectoryType.GSuite:
|
||||
if (savedConfig.privateKey == null) {
|
||||
await this.setGsuiteKey(null);
|
||||
} else {
|
||||
const normalizedPrivateKey = gsuiteConfig.privateKey.replace(/\\n/g, "\n");
|
||||
await this.setGsuiteKey(normalizedPrivateKey);
|
||||
gsuiteConfig.privateKey = StoredSecurely;
|
||||
(config as GSuiteConfiguration).privateKey = savedConfig.privateKey =
|
||||
savedConfig.privateKey.replace(/\\n/g, "\n");
|
||||
await this.setGsuiteKey(savedConfig.privateKey);
|
||||
savedConfig.privateKey = StoredSecurely;
|
||||
}
|
||||
await this.setGsuiteConfiguration(gsuiteConfig);
|
||||
await this.setGsuiteConfiguration(savedConfig);
|
||||
break;
|
||||
}
|
||||
case DirectoryType.OneLogin: {
|
||||
const oneLoginConfig = config as OneLoginConfiguration;
|
||||
await this.setOneLoginKey(oneLoginConfig.clientSecret);
|
||||
oneLoginConfig.clientSecret = StoredSecurely;
|
||||
await this.setOneLoginConfiguration(oneLoginConfig);
|
||||
case DirectoryType.OneLogin:
|
||||
await this.setOneLoginKey(savedConfig.clientSecret);
|
||||
savedConfig.clientSecret = StoredSecurely;
|
||||
await this.setOneLoginConfiguration(savedConfig);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async getLdapKey(options?: StorageOptions): Promise<string> {
|
||||
async getLdapKey(options?: StorageOptions): Promise<string> {
|
||||
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
|
||||
if (options?.userId == null) {
|
||||
return null;
|
||||
@@ -153,7 +144,7 @@ export class StateService
|
||||
);
|
||||
}
|
||||
|
||||
private async setLdapKey(value: string, options?: StorageOptions): Promise<void> {
|
||||
async setLdapKey(value: string, options?: StorageOptions): Promise<void> {
|
||||
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
|
||||
if (options?.userId == null) {
|
||||
return;
|
||||
@@ -165,7 +156,7 @@ export class StateService
|
||||
);
|
||||
}
|
||||
|
||||
private async getGsuiteKey(options?: StorageOptions): Promise<string> {
|
||||
async getGsuiteKey(options?: StorageOptions): Promise<string> {
|
||||
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
|
||||
if (options?.userId == null) {
|
||||
return null;
|
||||
@@ -175,7 +166,7 @@ export class StateService
|
||||
);
|
||||
}
|
||||
|
||||
private async setGsuiteKey(value: string, options?: StorageOptions): Promise<void> {
|
||||
async setGsuiteKey(value: string, options?: StorageOptions): Promise<void> {
|
||||
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
|
||||
if (options?.userId == null) {
|
||||
return;
|
||||
@@ -187,7 +178,7 @@ export class StateService
|
||||
);
|
||||
}
|
||||
|
||||
private async getAzureKey(options?: StorageOptions): Promise<string> {
|
||||
async getAzureKey(options?: StorageOptions): Promise<string> {
|
||||
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
|
||||
if (options?.userId == null) {
|
||||
return null;
|
||||
@@ -197,7 +188,7 @@ export class StateService
|
||||
);
|
||||
}
|
||||
|
||||
private async setAzureKey(value: string, options?: StorageOptions): Promise<void> {
|
||||
async setAzureKey(value: string, options?: StorageOptions): Promise<void> {
|
||||
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
|
||||
if (options?.userId == null) {
|
||||
return;
|
||||
@@ -209,7 +200,7 @@ export class StateService
|
||||
);
|
||||
}
|
||||
|
||||
private async getOktaKey(options?: StorageOptions): Promise<string> {
|
||||
async getOktaKey(options?: StorageOptions): Promise<string> {
|
||||
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
|
||||
if (options?.userId == null) {
|
||||
return null;
|
||||
@@ -219,7 +210,7 @@ export class StateService
|
||||
);
|
||||
}
|
||||
|
||||
private async setOktaKey(value: string, options?: StorageOptions): Promise<void> {
|
||||
async setOktaKey(value: string, options?: StorageOptions): Promise<void> {
|
||||
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
|
||||
if (options?.userId == null) {
|
||||
return;
|
||||
@@ -231,7 +222,7 @@ export class StateService
|
||||
);
|
||||
}
|
||||
|
||||
private async getOneLoginKey(options?: StorageOptions): Promise<string> {
|
||||
async getOneLoginKey(options?: StorageOptions): Promise<string> {
|
||||
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
|
||||
if (options?.userId == null) {
|
||||
return null;
|
||||
@@ -241,7 +232,7 @@ export class StateService
|
||||
);
|
||||
}
|
||||
|
||||
private async setOneLoginKey(value: string, options?: StorageOptions): Promise<void> {
|
||||
async setOneLoginKey(value: string, options?: StorageOptions): Promise<void> {
|
||||
options = this.reconcileOptions(options, await this.defaultSecureStorageOptions());
|
||||
if (options?.userId == null) {
|
||||
return;
|
||||
@@ -583,8 +574,4 @@ export class StateService
|
||||
};
|
||||
return Object.assign(this.createAccount(), persistentAccountInformation);
|
||||
}
|
||||
|
||||
async getEnvironmentUrls(options?: StorageOptions): Promise<EnvironmentUrls> {
|
||||
return this.getGlobalEnvironmentUrls(options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
|
||||
import { StateVersion } from "jslib-common/enums/stateVersion";
|
||||
import { StateMigrationService as BaseStateMigrationService } from "jslib-common/services/stateMigration.service";
|
||||
|
||||
@@ -49,6 +51,7 @@ const ClientKeys: { [key: string]: any } = {
|
||||
clientSecret: "apikey_clientSecret",
|
||||
};
|
||||
|
||||
@Injectable()
|
||||
export class StateMigrationService extends BaseStateMigrationService {
|
||||
async migrate(): Promise<void> {
|
||||
let currentStateVersion = await this.getCurrentStateVersion();
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
|
||||
import { ApiService } from "jslib-common/abstractions/api.service";
|
||||
import { CryptoFunctionService } from "jslib-common/abstractions/cryptoFunction.service";
|
||||
import { EnvironmentService } from "jslib-common/abstractions/environment.service";
|
||||
@@ -20,6 +22,7 @@ import { LdapDirectoryService } from "./ldap-directory.service";
|
||||
import { OktaDirectoryService } from "./okta-directory.service";
|
||||
import { OneLoginDirectoryService } from "./onelogin-directory.service";
|
||||
|
||||
@Injectable()
|
||||
export class SyncService {
|
||||
private dirType: DirectoryType;
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ const plugins = [
|
||||
resourceRegExp: /^encoding$/,
|
||||
contextRegExp: /node-fetch/,
|
||||
}),
|
||||
new webpack.NormalModuleReplacementPlugin(/@angular\/core/, "jslib-node/angular-core.noop"),
|
||||
];
|
||||
|
||||
const config = {
|
||||
|
||||
Reference in New Issue
Block a user