mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-17 02:29:08 +00:00
get credentials from AWS secrets manager
This commit is contained in:
+16
-14
@@ -8,22 +8,24 @@ class OauthSecretsObject {
|
||||
client_secret = '';
|
||||
redirect_uri = '';
|
||||
}
|
||||
|
||||
export class OauthScrets {
|
||||
// @Injectable()
|
||||
export class OauthSecrets {
|
||||
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);
|
||||
}
|
||||
}
|
||||
export async function getOauthSecrets() {
|
||||
const secrets = new OauthSecrets();
|
||||
const path = process.env.SM_OAUTH_PATH;
|
||||
const secretsManagerClient = new SecretsManagerClient({});
|
||||
for (const key in secrets) {
|
||||
const getSecretComand = new GetSecretValueCommand({
|
||||
SecretId: `${path}/${key}`,
|
||||
});
|
||||
const res = await secretsManagerClient
|
||||
.send(getSecretComand)
|
||||
.catch(() => null);
|
||||
if (res) secrets[key] = JSON.parse(res.SecretString);
|
||||
}
|
||||
return secrets;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user