mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-26 16:50:04 +00:00
get oauth secrets from secrets manager
This commit is contained in:
@@ -22,18 +22,23 @@ import {
|
||||
objectSnakeToCamel,
|
||||
} from 'src/utils/CaseConverter';
|
||||
import { mustache } from 'src/utils/mustache';
|
||||
import { OauthScrets } from 'src/utils/OauthSecrets';
|
||||
import { URLSearchParams } from 'url';
|
||||
import { IIdRequest, UpdateInputRequest } from './interfaces';
|
||||
|
||||
export class InputsClientService implements OnModuleInit {
|
||||
private inputService: InputService;
|
||||
oauthSecrets: OauthScrets;
|
||||
constructor(
|
||||
@Inject('INPUTS_PACKAGE') private readonly grpcClient: ClientGrpc,
|
||||
) {}
|
||||
|
||||
onModuleInit() {
|
||||
async onModuleInit() {
|
||||
this.inputService =
|
||||
this.grpcClient.getService<InputService>('InputService');
|
||||
this.oauthSecrets = new OauthScrets();
|
||||
await this.oauthSecrets.init();
|
||||
console.log(this.oauthSecrets);
|
||||
}
|
||||
|
||||
async newCreate(createInputDto: InputNewCreateRequest) {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import {
|
||||
SecretsManagerClient,
|
||||
GetSecretValueCommand,
|
||||
} from '@aws-sdk/client-secrets-manager';
|
||||
|
||||
class OauthSecretsObject {
|
||||
client_id: string;
|
||||
client_secret: string;
|
||||
redirect_uri: string;
|
||||
}
|
||||
|
||||
export class OauthScrets {
|
||||
hubspot = new OauthSecretsObject();
|
||||
google = new OauthSecretsObject();
|
||||
mailchimp = new OauthSecretsObject();
|
||||
async init() {
|
||||
const path = process.env.SM_OAUTH_PATH;
|
||||
const secretsManagerClient = new SecretsManagerClient({});
|
||||
for (const key in this) {
|
||||
const getSecretComand = new GetSecretValueCommand({
|
||||
SecretId: `${path}/${key}`,
|
||||
});
|
||||
const res = await secretsManagerClient
|
||||
.send(getSecretComand)
|
||||
.catch(() => null);
|
||||
if (res) this[key] = JSON.parse(res.SecretString);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user