mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-12 13:49:08 +00:00
get oauth secrets from secrets manager
This commit is contained in:
Generated
+1600
File diff suppressed because it is too large
Load Diff
@@ -24,6 +24,7 @@
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
||||
"@grpc/grpc-js": "^1.5.10",
|
||||
"@grpc/proto-loader": "^0.6.9",
|
||||
"@nestjs/common": "^8.4.3",
|
||||
|
||||
@@ -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