refactor(core): Store SSH key pair for source control in DB settings (#8965)

This commit is contained in:
Iván Ovejero
2024-03-26 19:09:46 +01:00
committed by GitHub
parent 19d9e71cb9
commit ddc0f57116
8 changed files with 201 additions and 33 deletions

View File

@@ -28,7 +28,8 @@ export class SourceControlController {
@Get('/preferences', { middlewares: [sourceControlLicensedMiddleware], skipAuth: true })
async getPreferences(): Promise<SourceControlPreferences> {
// returns the settings with the privateKey property redacted
return this.sourceControlPreferencesService.getPreferences();
const publicKey = await this.sourceControlPreferencesService.getPublicKey();
return { ...this.sourceControlPreferencesService.getPreferences(), publicKey };
}
@Post('/preferences', { middlewares: [sourceControlLicensedMiddleware] })
@@ -238,7 +239,8 @@ export class SourceControlController {
try {
const keyPairType = req.body.keyGeneratorType;
const result = await this.sourceControlPreferencesService.generateAndSaveKeyPair(keyPairType);
return result;
const publicKey = await this.sourceControlPreferencesService.getPublicKey();
return { ...result, publicKey };
} catch (error) {
throw new BadRequestError((error as { message: string }).message);
}