mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-09 16:39:09 +00:00
hubspot guard
This commit is contained in:
@@ -31,6 +31,7 @@ import { InputsClientConfiguration } from './clients/inputs/client.config';
|
||||
import { PipelinesClientConfiguration } from './clients/pipelines/client.config';
|
||||
import { CatalogController } from './modules/catalog/catalog.controller';
|
||||
import { CatalogService } from './modules/catalog/catalog.service';
|
||||
import { HubspotStrategy } from './modules/inputs/passport-strategies/hubspot';
|
||||
|
||||
const authClient = new AuthClient();
|
||||
const inputClient = new InputsClientConfiguration();
|
||||
@@ -61,6 +62,7 @@ const transformationClient = new TransformationsClientConfiguration();
|
||||
PipelinesClientService,
|
||||
AuthClientService,
|
||||
CatalogService,
|
||||
HubspotStrategy,
|
||||
],
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
|
||||
@@ -6,6 +6,8 @@ import {
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Req,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { InputsService } from './inputs.service';
|
||||
import { InputsClientService } from 'src/clients/inputs/client.service';
|
||||
@@ -21,6 +23,7 @@ import {
|
||||
TestConnectionReq,
|
||||
TestConnectionRes,
|
||||
} from './dtos/input.model';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
|
||||
@ApiTags('inputs')
|
||||
@Controller('inputs')
|
||||
@@ -125,4 +128,14 @@ export class InputsController {
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('hubspot'))
|
||||
@Get('oauth/hubspot')
|
||||
async oauthHubspot(@Req() req) {
|
||||
return true;
|
||||
}
|
||||
@Get('oauth/hubspot/callback')
|
||||
async oauthHubspotCallback(@Req() req) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { Strategy } from 'passport-hubspot';
|
||||
import { PassportStrategy } from '@nestjs/passport';
|
||||
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class HubspotStrategy extends PassportStrategy(Strategy) {
|
||||
constructor(private authService: AuthService) {
|
||||
super();
|
||||
constructor() {
|
||||
super({
|
||||
clientID: 'asd',
|
||||
clientSecret: '',
|
||||
callbackURL: 'http://localhost:4200/coletix/auth-callback',
|
||||
});
|
||||
}
|
||||
|
||||
async validate(username: string, password: string): Promise<any> {
|
||||
const user = await this.authService.validateUser(username, password);
|
||||
if (!user) {
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
return user;
|
||||
async validate(accessToken: string, refreshToken: string) {
|
||||
return { accessToken, refreshToken };
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user