Compare commits

...
17 Commits
Author SHA1 Message Date
Rodrigo Zamboni bc108d43e3 Merge pull request #94 from dadosfera/beta
Beta
2022-05-18 16:54:04 -03:00
Gabriel Rosa f4a5f91cbb FIX: remove backmerge 2022-05-16 17:03:12 -03:00
Arthur Simas 65f6f03e55 CHORE: pinning protospack version to 1.7.4 2022-05-13 11:15:05 -03:00
Arthur Simas a54300f600 CHORE: pinning protospack version to 1.7.2 2022-05-13 11:00:25 -03:00
Arthur Simas 5ef85f79d3 Merge branch 'alpha' into beta 2022-05-13 10:49:27 -03:00
rodrigo.zamboni a8a429977f UPDATE: Implementing MFA routes on maestro 2022-05-11 18:02:01 -03:00
Gabriel Amorim 692a9de0af FEAT: add refresh token - Merge pull request #90 from dadosfera/feat/refreshToken
FEATURE: add refresh token
2022-05-11 10:37:36 -03:00
rodrigo.zamboni 7dc669ca44 FIX: fix auth trim 2022-05-10 15:53:47 -03:00
rodrigo.zamboni e897da1ef0 FIX: Fix login middleware 2022-05-10 15:32:34 -03:00
Arthur Simas b366e786ba STYLE: styling conforming to ESLint 2022-05-10 10:23:55 -03:00
Arthur Simas 24d56c7a58 FEAT: add refresh token 2022-05-09 11:47:25 -03:00
rodrigo.zamboni d7f205901b UPDATE: Changing transformation factory microservice client url to inputs factory 2022-05-05 16:27:20 -03:00
rodrigo.zamboni 7212c5249c FIX: testing timeout on testconnection input client 2022-05-04 16:44:00 -03:00
rodrigo.zamboni 827c7b1bf1 FIX: Summary-rating returning default 0 values 2022-05-04 12:00:01 -03:00
rodrigo.zamboni 8d89b747b4 FIX: Fix delete routes method 2022-05-04 00:24:44 -03:00
rodrigo.zamboni 4f18328603 FIX: update protospack lib version 2022-05-03 17:59:51 -03:00
rodrigo.zamboni a68d312447 FIX: updated protospack lib 2022-05-03 17:07:57 -03:00
13 changed files with 319 additions and 43 deletions
-1
View File
@@ -38,7 +38,6 @@ jobs:
with:
semantic_version: 16
extra_plugins: |
@saithodev/semantic-release-backmerge
conventional-changelog-eslint
branches: |
[
-12
View File
@@ -26,18 +26,6 @@
"preset": "eslint"
}
],
[
"@saithodev/semantic-release-backmerge",
{
"branches": [
{ "from": "main", "to": "alpha" },
{ "from": "main", "to": "beta" }
],
"backmergeStrategy": "merge",
"clearWorkspace": true,
"restoreWorkspace": true
}
],
"@semantic-release/npm",
"@semantic-release/github"
]
+33 -3
View File
@@ -1109,6 +1109,15 @@
"tslib": "2.3.1"
}
},
"@nestjs/schedule": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@nestjs/schedule/-/schedule-1.1.0.tgz",
"integrity": "sha512-0QpbwClUildXqlyoaygG+aIQZNNMv31XDyQxX+Ob1zw/3I8+AVrDlBwZHQ+tlhIcJFR8aG+VTH8xwIjXwtS1UA==",
"requires": {
"cron": "1.8.2",
"uuid": "8.3.2"
}
},
"@nestjs/schematics": {
"version": "8.0.8",
"resolved": "https://registry.npmjs.org/@nestjs/schematics/-/schematics-8.0.8.tgz",
@@ -1706,9 +1715,9 @@
}
},
"@victorradael/protospack": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/@victorradael/protospack/-/protospack-1.6.1.tgz",
"integrity": "sha512-GEW+NYaMNnuUZ4/WsNJGpi3dHAOXkbm4BQKFkT/Ij7P9vSelyx9RGqkrs5m0biAXfITWDHe8hjI4AbRQe6AMDw==",
"version": "1.7.4",
"resolved": "https://registry.npmjs.org/@victorradael/protospack/-/protospack-1.7.4.tgz",
"integrity": "sha512-iQLJn88TaS6msH3JSm3CDqctqY24Xy42tZRRfbxipQ4NMfrQ2TEjLhNYeKEGHqidCjTHF/bhSnx+4ml2yqkpKQ==",
"requires": {
"rxjs": "^7.5.5"
}
@@ -2645,6 +2654,14 @@
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
"dev": true
},
"cron": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/cron/-/cron-1.8.2.tgz",
"integrity": "sha512-Gk2c4y6xKEO8FSAUTklqtfSr7oTq0CiPQeLBG5Fl0qoXpZyMcj1SG59YL+hqq04bu6/IuEA7lMkYDAplQNKkyg==",
"requires": {
"moment-timezone": "^0.5.x"
}
},
"cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
@@ -5173,6 +5190,19 @@
"minimist": "^1.2.5"
}
},
"moment": {
"version": "2.29.3",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.3.tgz",
"integrity": "sha512-c6YRvhEo//6T2Jz/vVtYzqBzwvPT95JBQ+smCytzf7c50oMZRsR/a4w88aD34I+/QVSfnoAnSBFPJHItlOMJVw=="
},
"moment-timezone": {
"version": "0.5.34",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.34.tgz",
"integrity": "sha512-3zAEHh2hKUs3EXLESx/wsgw6IQdusOT8Bxm3D9UrHPQR7zlMmzwybC8zHEM1tQ4LJwP7fcxrWr8tuBg05fFCbg==",
"requires": {
"moment": ">= 2.9.0"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
+2 -1
View File
@@ -29,8 +29,9 @@
"@nestjs/mapped-types": "*",
"@nestjs/microservices": "^8.4.3",
"@nestjs/platform-express": "^8.4.3",
"@nestjs/schedule": "^1.1.0",
"@nestjs/swagger": "^5.2.1",
"@victorradael/protospack": "^1.6.1",
"@victorradael/protospack": "1.7.4",
"axios": "^0.25.0",
"dotenv": "^14.2.0",
"helmet": "^5.0.2",
+175 -3
View File
@@ -2,11 +2,16 @@ import { OnModuleInit, Inject } from '@nestjs/common';
import { ClientGrpc } from '@nestjs/microservices';
import {
AuthConfirmationRequest,
AuthDisableTotpMfaRequest,
AuthEnableTotpMfaRequest,
AuthResendConfirmationCodeRequest,
AuthServiceInterface,
AuthVerifyTotpMfaRequest,
DucServicesNames,
} from '@victorradael/protospack';
import { ILogin } from './interfaces';
import { ISignIn, IRefreshAccessToken } from './interfaces';
export class AuthClientService implements OnModuleInit {
private authService: AuthServiceInterface;
@@ -20,11 +25,11 @@ export class AuthClientService implements OnModuleInit {
);
}
async signIn({ username, password }: ILogin): Promise<any> {
async signIn({ username, password, totp }: ISignIn): Promise<any> {
console.log('AuthClientService', 'SignIn');
const tokens = await new Promise((resolve, reject) => {
this.authService.signIn({ username, password }).subscribe({
this.authService.signIn({ username, password, totp }).subscribe({
next(x) {
resolve(x);
},
@@ -43,4 +48,171 @@ export class AuthClientService implements OnModuleInit {
});
return tokens;
}
async enableTotpMFA({
username,
password,
}: AuthEnableTotpMfaRequest): Promise<any> {
console.log('AuthClientService', 'enableTotpMFA');
const tokens = await new Promise((resolve, reject) => {
this.authService.enableTotpMfa({ username, password }).subscribe({
next(x) {
resolve(x);
},
error(err) {
console.log('Observable Error');
reject(err);
},
complete() {
console.log('done');
},
});
})
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return tokens;
}
async disableTotpMFA({
username,
password,
totp,
}: AuthDisableTotpMfaRequest): Promise<any> {
console.log('AuthClientService', 'disableTotpMFA');
const tokens = await new Promise((resolve, reject) => {
this.authService.disableTotpMfa({ username, password, totp }).subscribe({
next(x) {
resolve(x);
},
error(err) {
console.log('Observable Error');
reject(err);
},
complete() {
console.log('done');
},
});
})
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return tokens;
}
async verifyTotp({
username,
accessToken,
totp,
}: AuthVerifyTotpMfaRequest): Promise<any> {
console.log('AuthClientService', 'disableTotpMFA');
const tokens = await new Promise((resolve, reject) => {
this.authService.verifyTotp({ username, accessToken, totp }).subscribe({
next(x) {
resolve(x);
},
error(err) {
console.log('Observable Error');
reject(err);
},
complete() {
console.log('done');
},
});
})
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return tokens;
}
async confirmRegister({
username,
code,
}: AuthConfirmationRequest): Promise<any> {
console.log('AuthClientService', 'confirmRegister');
const tokens = await new Promise((resolve, reject) => {
this.authService.confirmRegister({ username, code }).subscribe({
next(x) {
resolve(x);
},
error(err) {
console.log('Observable Error');
reject(err);
},
complete() {
console.log('done');
},
});
})
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return tokens;
}
async resendeConfirmationCode({
username,
}: AuthResendConfirmationCodeRequest): Promise<any> {
console.log('AuthClientService', 'resendeConfirmationCode');
const authResendConfirmationCodeRequestReturn = await new Promise(
(resolve, reject) => {
this.authService.resendeConfirmationCode({ username }).subscribe({
next(x) {
resolve(x);
},
error(err) {
console.log('Observable Error');
reject(err);
},
complete() {
console.log('done');
},
});
},
)
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return authResendConfirmationCodeRequestReturn;
}
async refreshAccessToken({
username,
refreshToken,
}: IRefreshAccessToken): Promise<any> {
console.log('AuthClientService', 'RefreshAccessToken');
const tokens = await new Promise((resolve, reject) => {
this.authService
.refreshAccessToken({ username, refreshToken })
.subscribe({
next(x) {
resolve(x);
},
error(err) {
console.log('Observable Error');
reject(err);
},
complete() {
console.log('done');
},
});
})
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return tokens;
}
}
+7 -1
View File
@@ -1,4 +1,10 @@
export interface ILogin {
export interface ISignIn {
username: string;
password: string;
totp: string;
}
export interface IRefreshAccessToken {
username: string;
refreshToken: string;
}
+1 -1
View File
@@ -10,7 +10,7 @@ export class TransformationsClientConfiguration {
return {
transport: Transport.GRPC,
options: {
url: process.env.TRFACTORY_URL,
url: process.env.INFACTORY_URL,
package: TransformationPackages,
credentials: credentials.createSsl(),
protoPath: TransformationProtoFilePath,
+4 -2
View File
@@ -17,9 +17,11 @@ export class LoggerMiddleware implements NestMiddleware {
const idToken = request.get('Dadosfera-User');
const accessToken = request.get('Authorization');
const privateKey = process.env.JWT_PRIVATE_KEY;
let requiredRoute = '';
const requiredMethod = request.method.trim();
const requiredRoute = request.route.path.split('/')[1].trim();
if (request.route.path.split('/').length >= 2) {
requiredRoute = request.route.path.split('/')[1].trim();
}
verify(idToken, privateKey, (err) => {
if (err) {
+81 -8
View File
@@ -1,22 +1,43 @@
import { Body, Controller, Post, UnauthorizedException } from '@nestjs/common';
import {
Body,
Controller,
Headers,
Post,
UnauthorizedException,
} from '@nestjs/common';
import {
AuthEnableTotpMfaRequest,
AuthVerifyTotpMfaRequest,
} from '@victorradael/protospack';
import { AuthClientService } from 'src/clients/auth/client.service';
interface ISignIn {
username: string;
password: string;
}
import { ISignIn, IRefreshAccessToken } from 'src/clients/auth/interfaces';
@Controller('auth')
export class AuthController {
constructor(private authClient: AuthClientService) {}
// DEPRECADO!
@Post()
async signIn(@Body() { username, password }: ISignIn) {
async signIn_old(@Body() body: ISignIn) {
console.log(`/auth`, 'SignIn_old');
return this.signIn(body);
}
@Post('login')
async signIn_login(@Body() body: ISignIn) {
console.log(`/auth`, 'SignIn_login');
return this.signIn(body);
}
@Post('sign-in')
async signIn(@Body() { username, password, totp }: ISignIn) {
console.log(`/auth`, 'SignIn');
const tokens = await this.authClient
.signIn({ username, password })
.signIn({ username, password, totp })
.then((result) => result)
.catch((err) => {
throw new UnauthorizedException(err.message);
@@ -24,4 +45,56 @@ export class AuthController {
return tokens;
}
@Post('refresh-access-token')
async refreshAccessToken(
@Body() { username, refreshToken }: IRefreshAccessToken,
) {
console.log(`/auth`, 'RefreshAccessToken');
const accessToken = await this.authClient
.refreshAccessToken({ username, refreshToken })
.then((result) => result)
.catch((err) => {
throw new UnauthorizedException(err.message);
});
return accessToken;
}
@Post('enable-totp')
async enableTotpMFA(
@Body() { username, password }: AuthEnableTotpMfaRequest,
) {
console.log(`/auth`, 'enable-totp');
const enableTotpResponse = await this.authClient
.enableTotpMFA({ username, password })
.then((result) => result)
.catch((err) => {
throw new UnauthorizedException(err.message);
});
return enableTotpResponse;
}
@Post('verify-totp')
async verifyTotp(
@Body() body: AuthVerifyTotpMfaRequest,
@Headers() headers,
): Promise<any> {
console.log(`/auth`, 'enable-totp');
const { username, totp } = body;
const { Authorization } = headers;
const enableTotpResponse = await this.authClient
.verifyTotp({ username, totp, accessToken: Authorization })
.then((result) => result)
.catch((err) => {
throw new UnauthorizedException(err.message);
});
return enableTotpResponse;
}
}
+8 -5
View File
@@ -218,15 +218,18 @@ export class CatalogController {
}
@Get('summary-rating/:id')
async getSummaryRating(@Param() params, @Body() body) {
async getSummaryRating() {
console.log(`/catalog`, 'ON GET SUMMARY RATING ROUTE');
const { id } = params;
//const { id } = params;
const catalogService = new CatalogService();
//const catalogService = new CatalogService();
const res = await catalogService.getSummaryRating(id, body);
//const res = await catalogService.getSummaryRating(id, body);
return res;
return {
avg_rating: 0,
rating_count: 0,
};
}
@Get('data-comment')
+5 -5
View File
@@ -136,7 +136,7 @@ class CatalogService {
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.get(
const { data } = await axios.delete(
`${nimbusUrl}/api/catalog/table-metadata/${id}`,
);
return data;
@@ -171,7 +171,7 @@ class CatalogService {
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.get(
const { data } = await axios.delete(
`${nimbusUrl}/api/catalog/column-metadata/${id}/`,
);
return data;
@@ -454,7 +454,7 @@ class CatalogService {
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.get(`${nimbusUrl}/api/catalog/tags/${id}`);
const { data } = await axios.delete(`${nimbusUrl}/api/catalog/tags/${id}`);
return data;
}
@@ -487,7 +487,7 @@ class CatalogService {
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.get(
const { data } = await axios.delete(
`${nimbusUrl}/api/catalog/table-tags/${id}`,
);
return data;
@@ -522,7 +522,7 @@ class CatalogService {
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.get(
const { data } = await axios.delete(
`${nimbusUrl}/api/catalog/table-rules/${id}`,
);
return data;
+2
View File
@@ -1,4 +1,5 @@
import { Body, HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { Timeout } from '@nestjs/schedule';
import { InputNewCreateRequest } from '@victorradael/protospack';
import { InputsClientService } from 'src/clients/inputs/client.service';
import { IIdRequest, Info } from 'src/clients/inputs/interfaces';
@@ -60,6 +61,7 @@ export class InputsService {
}
}
@Timeout(60000 * 10) // Timeout set for 10 minutes
async testConnection(data) {
try {
const testConnectionInputResponse = await this.inputClient.testConnection(
+1 -1
View File
File diff suppressed because one or more lines are too long