1
0
mirror of https://github.com/bitwarden/directory-connector synced 2025-12-10 05:13:17 +00:00

Refresh token with api key (#135)

* Do not persist client creds on logout

* Override refreshing token flow with re-authentication flow

* Update jslib

* PR review comments
This commit is contained in:
Matt Gibson
2021-06-22 16:13:08 -04:00
committed by GitHub
parent 4e098462dc
commit 647b087fa7
8 changed files with 71 additions and 7 deletions

View File

@@ -9,6 +9,7 @@ import { ConfigurationService } from './services/configuration.service';
import { I18nService } from './services/i18n.service';
import { KeytarSecureStorageService } from './services/keytarSecureStorage.service';
import { LowdbStorageService } from './services/lowdbStorage.service';
import { NodeApiService } from './services/nodeApi.service';
import { SyncService } from './services/sync.service';
import { CliPlatformUtilsService } from 'jslib-node/cli/services/cliPlatformUtils.service';
@@ -25,11 +26,11 @@ import { NoopMessagingService } from 'jslib-common/services/noopMessaging.servic
import { PasswordGenerationService } from 'jslib-common/services/passwordGeneration.service';
import { TokenService } from 'jslib-common/services/token.service';
import { UserService } from 'jslib-common/services/user.service';
import { NodeApiService } from 'jslib-node/services/nodeApi.service';
import { StorageService as StorageServiceAbstraction } from 'jslib-common/abstractions/storage.service';
import { Program } from './program';
import { refreshToken } from './services/api.service';
// tslint:disable-next-line
const packageJson = require('./package.json');
@@ -90,7 +91,7 @@ export class Main {
this.appIdService = new AppIdService(this.storageService);
this.tokenService = new TokenService(this.storageService);
this.messagingService = new NoopMessagingService();
this.apiService = new NodeApiService(this.tokenService, this.platformUtilsService,
this.apiService = new NodeApiService(this.tokenService, this.platformUtilsService, this.refreshTokenCallback,
async (expired: boolean) => await this.logout());
this.environmentService = new EnvironmentService(this.apiService, this.storageService, null);
this.apiKeyService = new ApiKeyService(this.tokenService, this.storageService);
@@ -117,6 +118,10 @@ export class Main {
await this.apiKeyService.clear();
}
refreshTokenCallback() {
return refreshToken(this.apiKeyService, this.authService);
}
private async init() {
await this.storageService.init();
this.containerService.attachToWindow(global);