mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-07 15:29:08 +00:00
Merge branch 'ft/connection-manager' of https://github.com/dadosfera/maestro into ft/connection-manager
This commit is contained in:
Generated
+7
-7
@@ -12,7 +12,7 @@
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.3",
|
||||
"@dadosfera/protospack-v2": "^3.15.2",
|
||||
"@dadosfera/protospack-v2": "3.15.3",
|
||||
"@grpc/grpc-js": "^1.6.7",
|
||||
"@grpc/proto-loader": "^0.6.13",
|
||||
"@nestjs/common": "^8.4.7",
|
||||
@@ -1726,9 +1726,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@dadosfera/protospack-v2": {
|
||||
"version": "3.15.2",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.15.2.tgz",
|
||||
"integrity": "sha512-N0B7Fw/EbCp91dQvYPDnoiGsD9byj7H2b5ecqLcUiVRVMZFcF84XVfD7oE45T3q7vwv67xs/nwC7lSvlkRbxYA==",
|
||||
"version": "3.15.3",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.15.3.tgz",
|
||||
"integrity": "sha512-/TNTnjm8XIQ3DFiJc8nnSRFQE23lF8Dm+8wzL1VJIqivdQK2gUwkpEoYT0CA6PFVvVFhDrEWo/zGY55tBHXJBg==",
|
||||
"dependencies": {
|
||||
"@grpc/grpc-js": "^1.6.7",
|
||||
"rxjs": "^7.5.5",
|
||||
@@ -12305,9 +12305,9 @@
|
||||
}
|
||||
},
|
||||
"@dadosfera/protospack-v2": {
|
||||
"version": "3.15.2",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.15.2.tgz",
|
||||
"integrity": "sha512-N0B7Fw/EbCp91dQvYPDnoiGsD9byj7H2b5ecqLcUiVRVMZFcF84XVfD7oE45T3q7vwv67xs/nwC7lSvlkRbxYA==",
|
||||
"version": "3.15.3",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.15.3.tgz",
|
||||
"integrity": "sha512-/TNTnjm8XIQ3DFiJc8nnSRFQE23lF8Dm+8wzL1VJIqivdQK2gUwkpEoYT0CA6PFVvVFhDrEWo/zGY55tBHXJBg==",
|
||||
"requires": {
|
||||
"@grpc/grpc-js": "^1.6.7",
|
||||
"rxjs": "^7.5.5",
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.3",
|
||||
"@dadosfera/protospack-v2": "^3.15.2",
|
||||
"@dadosfera/protospack-v2": "3.15.3",
|
||||
"@grpc/grpc-js": "^1.6.7",
|
||||
"@grpc/proto-loader": "^0.6.13",
|
||||
"@nestjs/common": "^8.4.7",
|
||||
|
||||
@@ -4,6 +4,7 @@ import { AuthGuard } from '@nestjs/passport';
|
||||
import { ConnectionClientService } from '../connection/client.service';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import DadosferaLogger from '@dadosfera/dadosfera-logs/dist';
|
||||
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
||||
@ApiTags('oauth')
|
||||
@Controller('oauth')
|
||||
export class OauthController {
|
||||
@@ -157,7 +158,7 @@ export class OauthController {
|
||||
try {
|
||||
const response = await this.connectionService.createConnection(
|
||||
connectionInfo,
|
||||
{ customer_id, customer_name, user_id },
|
||||
PackTheMetadata({ customer_id, customer_name, user_id }),
|
||||
);
|
||||
this.redirectUrl.searchParams.set(
|
||||
'connection_id',
|
||||
|
||||
@@ -7,10 +7,11 @@ class PartialConnection extends PartialType(ConnectionDto) {}
|
||||
|
||||
@Injectable()
|
||||
export class OauthService {
|
||||
generateStateFromRequest(req, type): string {
|
||||
const plugin: string = req.route.path
|
||||
.replace('/oauth/', '')
|
||||
.replace('/callback', '');
|
||||
generateStateFromRequest(prevState, req, type): string {
|
||||
if (req.route.path.includes('callback')) {
|
||||
return prevState;
|
||||
}
|
||||
const plugin: string = req.route.path.replace('/oauth/', '');
|
||||
|
||||
const { query } = req;
|
||||
const {
|
||||
@@ -43,6 +44,7 @@ export class OauthService {
|
||||
customer_name,
|
||||
type,
|
||||
properties,
|
||||
plugin,
|
||||
};
|
||||
return jwt.sign({ ...newConnection }, process.env.JWT_PRIVATE_KEY);
|
||||
}
|
||||
|
||||
@@ -10,12 +10,14 @@ import { OauthSecrets } from 'src/utils/OauthSecrets';
|
||||
import { Request } from 'express';
|
||||
import { ParamsDictionary } from 'express-serve-static-core';
|
||||
import { ParsedQs } from 'qs';
|
||||
import { OauthService } from '../oauth.service';
|
||||
|
||||
@Injectable()
|
||||
export class FacebookStrategy extends PassportStrategy(Strategy) {
|
||||
constructor(
|
||||
@Inject('OAUTH_SECRETS')
|
||||
private readonly oauthSecrets: OauthSecrets,
|
||||
private oauthService: OauthService,
|
||||
) {
|
||||
const options: StrategyOption = {
|
||||
clientID: oauthSecrets.facebook.client_id,
|
||||
@@ -37,8 +39,11 @@ export class FacebookStrategy extends PassportStrategy(Strategy) {
|
||||
req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>,
|
||||
options?: any,
|
||||
): void {
|
||||
const { customer_id } = req.query;
|
||||
options.state = customer_id;
|
||||
options.state = this.oauthService.generateStateFromRequest(
|
||||
options.state,
|
||||
req,
|
||||
'application',
|
||||
);
|
||||
options.scope = 'ads_read ads_management';
|
||||
super.authenticate(req, options);
|
||||
}
|
||||
|
||||
@@ -52,13 +52,18 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
|
||||
switch (plugin) {
|
||||
case 'googleads':
|
||||
options.state = this.oauthService.generateStateFromRequest(
|
||||
options.state,
|
||||
req,
|
||||
'application',
|
||||
);
|
||||
options.scope.push('https://www.googleapis.com/auth/adwords');
|
||||
break;
|
||||
case 'google-sheets':
|
||||
options.state = this.oauthService.generateStateFromRequest(req, 'file');
|
||||
options.state = this.oauthService.generateStateFromRequest(
|
||||
options.state,
|
||||
req,
|
||||
'file',
|
||||
);
|
||||
options.scope.push(
|
||||
'https://www.googleapis.com/auth/drive.metadata.readonly',
|
||||
'https://www.googleapis.com/auth/spreadsheets.readonly',
|
||||
|
||||
@@ -28,6 +28,7 @@ export class HubspotStrategy extends PassportStrategy(Strategy) {
|
||||
|
||||
authenticate(req, options) {
|
||||
options.state = this.oauthService.generateStateFromRequest(
|
||||
options.state,
|
||||
req,
|
||||
'application',
|
||||
);
|
||||
|
||||
@@ -30,10 +30,12 @@ export class MailChimpStrategy extends PassportStrategy(Strategy, 'mailchimp') {
|
||||
}
|
||||
|
||||
authenticate(@Req() req, options) {
|
||||
options.state = this.oauthService.generateStateFromRequest(
|
||||
req,
|
||||
'application',
|
||||
);
|
||||
if (!req.route.path.includes('callback'))
|
||||
options.state = this.oauthService.generateStateFromRequest(
|
||||
options.state,
|
||||
req,
|
||||
'application',
|
||||
);
|
||||
super.authenticate(req, options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,11 @@ export class SalesforceStrategy extends PassportStrategy(
|
||||
}
|
||||
|
||||
authenticate(req, options) {
|
||||
options.state = this.oauthService.generateStateFromRequest(req, 'file');
|
||||
options.state = this.oauthService.generateStateFromRequest(
|
||||
options.state,
|
||||
req,
|
||||
'file',
|
||||
);
|
||||
super.authenticate(req, options);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user