Browse Source

fix: shared base, auth token and preview based passport strategy and roles

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5444/head
Pranav C 2 years ago
parent
commit
52d1e9c7e1
  1. 83
      packages/nocodb-nest/src/guards/global/global.guard.ts
  2. 3
      packages/nocodb-nest/src/modules/api-tokens/api-tokens.controller.ts
  3. 3
      packages/nocodb-nest/src/modules/audits/audits.controller.ts
  4. 3
      packages/nocodb-nest/src/modules/auth/auth.controller.ts
  5. 3
      packages/nocodb-nest/src/modules/bases/bases.controller.ts
  6. 3
      packages/nocodb-nest/src/modules/columns/columns.controller.ts
  7. 3
      packages/nocodb-nest/src/modules/datas/bulk-data-alias/bulk-data-alias.controller.ts
  8. 3
      packages/nocodb-nest/src/modules/datas/data-alias-export/data-alias-export.controller.ts
  9. 3
      packages/nocodb-nest/src/modules/form-columns/form-columns.controller.ts
  10. 3
      packages/nocodb-nest/src/modules/forms/forms.controller.ts
  11. 3
      packages/nocodb-nest/src/modules/galleries/galleries.controller.ts
  12. 3
      packages/nocodb-nest/src/modules/grid-columns/grid-columns.controller.ts
  13. 3
      packages/nocodb-nest/src/modules/grids/grids.controller.ts
  14. 3
      packages/nocodb-nest/src/modules/hooks/hooks.controller.ts
  15. 3
      packages/nocodb-nest/src/modules/kanbans/kanbans.controller.ts
  16. 3
      packages/nocodb-nest/src/modules/maps/maps.controller.ts
  17. 3
      packages/nocodb-nest/src/modules/meta-diffs/meta-diffs.controller.ts
  18. 3
      packages/nocodb-nest/src/modules/model-visibilities/model-visibilities.controller.ts
  19. 3
      packages/nocodb-nest/src/modules/org-users/org-users.controller.ts
  20. 3
      packages/nocodb-nest/src/modules/project-users/project-users.controller.ts
  21. 3
      packages/nocodb-nest/src/modules/projects/projects.controller.ts
  22. 3
      packages/nocodb-nest/src/modules/shared-bases/shared-bases.controller.ts
  23. 3
      packages/nocodb-nest/src/modules/sorts/sorts.controller.ts
  24. 3
      packages/nocodb-nest/src/modules/tables/tables.controller.ts
  25. 3
      packages/nocodb-nest/src/modules/utils/utils.controller.ts
  26. 3
      packages/nocodb-nest/src/modules/view-columns/view-columns.controller.ts

83
packages/nocodb-nest/src/guards/global/global.guard.ts

@ -1,5 +1,8 @@
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context-host';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import passport from 'passport';
import { lastValueFrom, Observable } from 'rxjs';
import { JwtStrategy } from '../../strategies/jwt.strategy'; import { JwtStrategy } from '../../strategies/jwt.strategy';
import type { ExecutionContext } from '@nestjs/common'; import type { ExecutionContext } from '@nestjs/common';
@ -12,25 +15,83 @@ export class GlobalGuard extends AuthGuard(['jwt']) {
async canActivate(context: ExecutionContext) { async canActivate(context: ExecutionContext) {
let result; let result;
try { try {
result = (await super.canActivate(context)) as boolean; result = await this.extractBoolVal(super.canActivate(context));
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }
if (!result) {
// If JWT authentication fails, use the fallback strategy to set a default user const req = context.switchToHttp().getRequest();
const req = context.switchToHttp().getRequest();
const user = await this.fallbackAuthenticate(req); if (result && !req.headers['xc-shared-base-id']) {
req.user = user; if (
return true; req.path.indexOf('/user/me') === -1 &&
req.header('xc-preview') &&
['owner', 'creator'].some((role) => req.user.roles?.[role])
) {
return this.authenticate({
...req.user,
isAuthorized: true,
roles: req.header('xc-preview'),
});
}
} }
return true; if (req.headers['xc-token']) {
let canActivate = false;
try {
const guard = new (AuthGuard('authtoken'))(context);
canActivate = await this.extractBoolVal(guard.canActivate(context));
} catch {}
if (canActivate) {
return this.authenticate({
...req.user,
isAuthorized: true,
roles: req.user.roles === 'owner' ? 'owner,creator' : req.user.roles,
});
}
} else if (req.headers['xc-shared-base-id']) {
let canActivate = false;
try {
const guard = new (AuthGuard('base-view'))(context);
canActivate = await this.extractBoolVal(guard.canActivate(context));
} catch {}
if (canActivate) {
return this.authenticate({
...req.user,
isAuthorized: true,
isPublicBase: true,
});
}
}
// If JWT authentication fails, use the fallback strategy to set a default user
return await this.authenticate(req);
} }
private async fallbackAuthenticate(req: any): Promise<any> { private async authenticate(
return this.jwtStrategy.validate(req, { req: any,
user: any = {
roles: { roles: {
guest: true, guest: true,
}, },
}); },
): Promise<any> {
const u = this.jwtStrategy.validate(req, user);
req.user = user;
return true;
}
async extractBoolVal(
canActivate: boolean | Promise<boolean> | Observable<boolean>,
) {
if (canActivate instanceof Observable) {
return lastValueFrom(canActivate);
} else if (
typeof canActivate === 'boolean' ||
canActivate instanceof Promise
) {
return canActivate;
}
} }
} }

3
packages/nocodb-nest/src/modules/api-tokens/api-tokens.controller.ts

@ -9,6 +9,7 @@ import {
UseGuards, UseGuards,
} from '@nestjs/common' } from '@nestjs/common'
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { PagedResponseImpl } from '../../helpers/PagedResponse'; import { PagedResponseImpl } from '../../helpers/PagedResponse';
import { import {
Acl, Acl,
@ -17,7 +18,7 @@ import {
import { ApiTokensService } from './api-tokens.service'; import { ApiTokensService } from './api-tokens.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class ApiTokensController { export class ApiTokensController {
constructor(private readonly apiTokensService: ApiTokensService) {} constructor(private readonly apiTokensService: ApiTokensService) {}

3
packages/nocodb-nest/src/modules/audits/audits.controller.ts

@ -10,6 +10,7 @@ import {
UseGuards, UseGuards,
} from '@nestjs/common' } from '@nestjs/common'
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { PagedResponseImpl } from '../../helpers/PagedResponse'; import { PagedResponseImpl } from '../../helpers/PagedResponse';
import { import {
Acl, Acl,
@ -19,7 +20,7 @@ import { Audit } from '../../models';
import { AuditsService } from './audits.service'; import { AuditsService } from './audits.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class AuditsController { export class AuditsController {
constructor(private readonly auditsService: AuditsService) {} constructor(private readonly auditsService: AuditsService) {}

3
packages/nocodb-nest/src/modules/auth/auth.controller.ts

@ -7,6 +7,7 @@ import {
UseGuards, UseGuards,
} from '@nestjs/common' } from '@nestjs/common'
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { ExtractProjectIdMiddleware } from '../../middlewares/extract-project-id/extract-project-id.middleware'; import { ExtractProjectIdMiddleware } from '../../middlewares/extract-project-id/extract-project-id.middleware';
import extractRolesObj from '../../utils/extractRolesObj'; import extractRolesObj from '../../utils/extractRolesObj';
import { AuthService } from './auth.service'; import { AuthService } from './auth.service';
@ -34,7 +35,7 @@ export class AuthController {
return await this.authService.signup(createUserDto); return await this.authService.signup(createUserDto);
} }
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
@Get('/api/v1/auth/user/me') @Get('/api/v1/auth/user/me')
async me(@Request() req) { async me(@Request() req) {
const user = { const user = {

3
packages/nocodb-nest/src/modules/bases/bases.controller.ts

@ -10,6 +10,7 @@ import {
} from '@nestjs/common' } from '@nestjs/common'
import { BaseReqType } from 'nocodb-sdk'; import { BaseReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { PagedResponseImpl } from '../../helpers/PagedResponse'; import { PagedResponseImpl } from '../../helpers/PagedResponse';
import { import {
Acl, Acl,
@ -18,7 +19,7 @@ import {
import { BasesService } from './bases.service'; import { BasesService } from './bases.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class BasesController { export class BasesController {
constructor(private readonly basesService: BasesService) {} constructor(private readonly basesService: BasesService) {}

3
packages/nocodb-nest/src/modules/columns/columns.controller.ts

@ -11,6 +11,7 @@ import {
} from '@nestjs/common' } from '@nestjs/common'
import { ColumnReqType } from 'nocodb-sdk'; import { ColumnReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { import {
Acl, Acl,
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
@ -18,7 +19,7 @@ import {
import { ColumnsService } from './columns.service'; import { ColumnsService } from './columns.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware,GlobalGuard)
export class ColumnsController { export class ColumnsController {
constructor(private readonly columnsService: ColumnsService) {} constructor(private readonly columnsService: ColumnsService) {}

3
packages/nocodb-nest/src/modules/datas/bulk-data-alias/bulk-data-alias.controller.ts

@ -11,6 +11,7 @@ import {
UseGuards, UseGuards,
} from '@nestjs/common' } from '@nestjs/common'
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../../guards/global/global.guard'
import { import {
Acl, Acl,
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
@ -18,7 +19,7 @@ import {
import { BulkDataAliasService } from './bulk-data-alias.service'; import { BulkDataAliasService } from './bulk-data-alias.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class BulkDataAliasController { export class BulkDataAliasController {
constructor(private bulkDataAliasService: BulkDataAliasService) {} constructor(private bulkDataAliasService: BulkDataAliasService) {}

3
packages/nocodb-nest/src/modules/datas/data-alias-export/data-alias-export.controller.ts

@ -1,6 +1,7 @@
import { Controller, Get, Request, Response, UseGuards } from '@nestjs/common'; import { Controller, Get, Request, Response, UseGuards } from '@nestjs/common';
import * as XLSX from 'xlsx'; import * as XLSX from 'xlsx';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../../guards/global/global.guard'
import { import {
Acl, Acl,
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
@ -10,7 +11,7 @@ import { DatasService } from '../datas.service';
import { extractCsvData, extractXlsxData } from '../helpers'; import { extractCsvData, extractXlsxData } from '../helpers';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class DataAliasExportController { export class DataAliasExportController {
constructor(private datasService: DatasService) {} constructor(private datasService: DatasService) {}

3
packages/nocodb-nest/src/modules/form-columns/form-columns.controller.ts

@ -1,5 +1,6 @@
import { Body, Controller, Param, Patch, UseGuards } from '@nestjs/common'; import { Body, Controller, Param, Patch, UseGuards } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { import {
Acl, Acl,
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
@ -9,7 +10,7 @@ import { FormColumnsService } from './form-columns.service';
class FormColumnUpdateReqType {} class FormColumnUpdateReqType {}
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class FormColumnsController { export class FormColumnsController {
constructor(private readonly formColumnsService: FormColumnsService) {} constructor(private readonly formColumnsService: FormColumnsService) {}

3
packages/nocodb-nest/src/modules/forms/forms.controller.ts

@ -9,6 +9,7 @@ import {
} from '@nestjs/common' } from '@nestjs/common'
import { ViewCreateReqType } from 'nocodb-sdk'; import { ViewCreateReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { import {
Acl, Acl,
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
@ -16,7 +17,7 @@ import {
import { FormsService } from './forms.service'; import { FormsService } from './forms.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware,GlobalGuard)
export class FormsController { export class FormsController {
constructor(private readonly formsService: FormsService) {} constructor(private readonly formsService: FormsService) {}

3
packages/nocodb-nest/src/modules/galleries/galleries.controller.ts

@ -9,6 +9,7 @@ import {
} from '@nestjs/common' } from '@nestjs/common'
import { GalleryUpdateReqType, ViewCreateReqType } from 'nocodb-sdk'; import { GalleryUpdateReqType, ViewCreateReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { import {
Acl, Acl,
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
@ -16,7 +17,7 @@ import {
import { GalleriesService } from './galleries.service'; import { GalleriesService } from './galleries.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware,GlobalGuard)
export class GalleriesController { export class GalleriesController {
constructor(private readonly galleriesService: GalleriesService) {} constructor(private readonly galleriesService: GalleriesService) {}

3
packages/nocodb-nest/src/modules/grid-columns/grid-columns.controller.ts

@ -1,6 +1,7 @@
import { Body, Controller, Get, Param, Patch, UseGuards } from '@nestjs/common'; import { Body, Controller, Get, Param, Patch, UseGuards } from '@nestjs/common';
import { GridColumnReqType } from 'nocodb-sdk'; import { GridColumnReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { import {
Acl, Acl,
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
@ -8,7 +9,7 @@ import {
import { GridColumnsService } from './grid-columns.service'; import { GridColumnsService } from './grid-columns.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class GridColumnsController { export class GridColumnsController {
constructor(private readonly gridColumnsService: GridColumnsService) {} constructor(private readonly gridColumnsService: GridColumnsService) {}

3
packages/nocodb-nest/src/modules/grids/grids.controller.ts

@ -8,6 +8,7 @@ import {
} from '@nestjs/common' } from '@nestjs/common'
import { ViewCreateReqType } from 'nocodb-sdk'; import { ViewCreateReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { import {
Acl, Acl,
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
@ -15,7 +16,7 @@ import {
import { GridsService } from './grids.service'; import { GridsService } from './grids.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class GridsController { export class GridsController {
get '/api/v1/db/meta/tables/:tableId/grids/'() { get '/api/v1/db/meta/tables/:tableId/grids/'() {
return this['_/api/v1/db/meta/tables/:tableId/grids/']; return this['_/api/v1/db/meta/tables/:tableId/grids/'];

3
packages/nocodb-nest/src/modules/hooks/hooks.controller.ts

@ -11,6 +11,7 @@ import {
} from '@nestjs/common' } from '@nestjs/common'
import { HookReqType, HookTestReqType } from 'nocodb-sdk'; import { HookReqType, HookTestReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { PagedResponseImpl } from '../../helpers/PagedResponse'; import { PagedResponseImpl } from '../../helpers/PagedResponse';
import { import {
Acl, Acl,
@ -20,7 +21,7 @@ import { HooksService } from './hooks.service';
import type { HookType } from 'nocodb-sdk'; import type { HookType } from 'nocodb-sdk';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class HooksController { export class HooksController {
constructor(private readonly hooksService: HooksService) {} constructor(private readonly hooksService: HooksService) {}

3
packages/nocodb-nest/src/modules/kanbans/kanbans.controller.ts

@ -9,6 +9,7 @@ import {
} from '@nestjs/common' } from '@nestjs/common'
import { ViewCreateReqType } from 'nocodb-sdk'; import { ViewCreateReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { import {
Acl, Acl,
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
@ -16,7 +17,7 @@ import {
import { KanbansService } from './kanbans.service'; import { KanbansService } from './kanbans.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class KanbansController { export class KanbansController {
constructor(private readonly kanbansService: KanbansService) {} constructor(private readonly kanbansService: KanbansService) {}

3
packages/nocodb-nest/src/modules/maps/maps.controller.ts

@ -9,6 +9,7 @@ import {
} from '@nestjs/common' } from '@nestjs/common'
import { MapUpdateReqType, ViewCreateReqType } from 'nocodb-sdk'; import { MapUpdateReqType, ViewCreateReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { import {
Acl, Acl,
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
@ -16,7 +17,7 @@ import {
import { MapsService } from './maps.service'; import { MapsService } from './maps.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class MapsController { export class MapsController {
constructor(private readonly mapsService: MapsService) {} constructor(private readonly mapsService: MapsService) {}

3
packages/nocodb-nest/src/modules/meta-diffs/meta-diffs.controller.ts

@ -1,5 +1,6 @@
import { Controller, Get, HttpCode, Param, Post, UseGuards } from '@nestjs/common' import { Controller, Get, HttpCode, Param, Post, UseGuards } from '@nestjs/common'
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { import {
Acl, Acl,
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
@ -7,7 +8,7 @@ import {
import { MetaDiffsService } from './meta-diffs.service'; import { MetaDiffsService } from './meta-diffs.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class MetaDiffsController { export class MetaDiffsController {
constructor(private readonly metaDiffsService: MetaDiffsService) {} constructor(private readonly metaDiffsService: MetaDiffsService) {}

3
packages/nocodb-nest/src/modules/model-visibilities/model-visibilities.controller.ts

@ -8,6 +8,7 @@ import {
UseGuards, UseGuards,
} from '@nestjs/common' } from '@nestjs/common'
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { import {
Acl, Acl,
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
@ -15,7 +16,7 @@ import {
import { ModelVisibilitiesService } from './model-visibilities.service'; import { ModelVisibilitiesService } from './model-visibilities.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class ModelVisibilitiesController { export class ModelVisibilitiesController {
constructor( constructor(
private readonly modelVisibilitiesService: ModelVisibilitiesService, private readonly modelVisibilitiesService: ModelVisibilitiesService,

3
packages/nocodb-nest/src/modules/org-users/org-users.controller.ts

@ -12,6 +12,7 @@ import {
} from '@nestjs/common'; } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { OrgUserRoles } from 'nocodb-sdk'; import { OrgUserRoles } from 'nocodb-sdk';
import { GlobalGuard } from '../../guards/global/global.guard'
import { PagedResponseImpl } from '../../helpers/PagedResponse'; import { PagedResponseImpl } from '../../helpers/PagedResponse';
import { import {
Acl, Acl,
@ -21,7 +22,7 @@ import { User } from '../../models';
import { OrgUsersService } from './org-users.service'; import { OrgUsersService } from './org-users.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class OrgUsersController { export class OrgUsersController {
constructor(private readonly orgUsersService: OrgUsersService) {} constructor(private readonly orgUsersService: OrgUsersService) {}

3
packages/nocodb-nest/src/modules/project-users/project-users.controller.ts

@ -11,13 +11,14 @@ import {
} from '@nestjs/common' } from '@nestjs/common'
import { ProjectUserReqType } from 'nocodb-sdk'; import { ProjectUserReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { import {
Acl, Acl,
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
} from '../../middlewares/extract-project-id/extract-project-id.middleware'; } from '../../middlewares/extract-project-id/extract-project-id.middleware';
import { ProjectUsersService } from './project-users.service'; import { ProjectUsersService } from './project-users.service';
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
@Controller() @Controller()
export class ProjectUsersController { export class ProjectUsersController {
constructor(private readonly projectUsersService: ProjectUsersService) {} constructor(private readonly projectUsersService: ProjectUsersService) {}

3
packages/nocodb-nest/src/modules/projects/projects.controller.ts

@ -13,6 +13,7 @@ import {
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import isDocker from 'is-docker'; import isDocker from 'is-docker';
import { ProjectReqType } from 'nocodb-sdk'; import { ProjectReqType } from 'nocodb-sdk';
import { GlobalGuard } from '../../guards/global/global.guard'
import { PagedResponseImpl } from '../../helpers/PagedResponse'; import { PagedResponseImpl } from '../../helpers/PagedResponse';
import { import {
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
@ -24,7 +25,7 @@ import { packageVersion } from '../../utils/packageVersion';
import { ProjectsService } from './projects.service'; import { ProjectsService } from './projects.service';
import type { ProjectType } from 'nocodb-sdk'; import type { ProjectType } from 'nocodb-sdk';
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
@Controller() @Controller()
export class ProjectsController { export class ProjectsController {
constructor(private readonly projectsService: ProjectsService) {} constructor(private readonly projectsService: ProjectsService) {}

3
packages/nocodb-nest/src/modules/shared-bases/shared-bases.controller.ts

@ -10,6 +10,7 @@ import {
UseGuards, UseGuards,
} from '@nestjs/common' } from '@nestjs/common'
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { import {
Acl, Acl,
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
@ -17,7 +18,7 @@ import {
import { SharedBasesService } from './shared-bases.service'; import { SharedBasesService } from './shared-bases.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class SharedBasesController { export class SharedBasesController {
constructor(private readonly sharedBasesService: SharedBasesService) {} constructor(private readonly sharedBasesService: SharedBasesService) {}

3
packages/nocodb-nest/src/modules/sorts/sorts.controller.ts

@ -10,6 +10,7 @@ import {
} from '@nestjs/common' } from '@nestjs/common'
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { SortReqType } from 'nocodb-sdk'; import { SortReqType } from 'nocodb-sdk';
import { GlobalGuard } from '../../guards/global/global.guard'
import { PagedResponseImpl } from '../../helpers/PagedResponse'; import { PagedResponseImpl } from '../../helpers/PagedResponse';
import { import {
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
@ -18,7 +19,7 @@ import {
import { SortsService } from './sorts.service'; import { SortsService } from './sorts.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class SortsController { export class SortsController {
constructor(private readonly sortsService: SortsService) {} constructor(private readonly sortsService: SortsService) {}

3
packages/nocodb-nest/src/modules/tables/tables.controller.ts

@ -12,6 +12,7 @@ import {
} from '@nestjs/common' } from '@nestjs/common'
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { TableReqType } from 'nocodb-sdk'; import { TableReqType } from 'nocodb-sdk';
import { GlobalGuard } from '../../guards/global/global.guard'
import extractRolesObj from '../../utils/extractRolesObj'; import extractRolesObj from '../../utils/extractRolesObj';
import { PagedResponseImpl } from '../../helpers/PagedResponse'; import { PagedResponseImpl } from '../../helpers/PagedResponse';
import { import {
@ -21,7 +22,7 @@ import {
import { TablesService } from './tables.service'; import { TablesService } from './tables.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class TablesController { export class TablesController {
constructor(private readonly tablesService: TablesService) {} constructor(private readonly tablesService: TablesService) {}

3
packages/nocodb-nest/src/modules/utils/utils.controller.ts

@ -7,6 +7,7 @@ import {
UseGuards, UseGuards,
} from '@nestjs/common' } from '@nestjs/common'
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { import {
Acl, Acl,
ExtractProjectIdMiddleware, ExtractProjectIdMiddleware,
@ -29,7 +30,7 @@ export class UtilsController {
return this.utilsService.versionInfo(); return this.utilsService.versionInfo();
} }
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
@Post('/api/v1/db/meta/connection/test') @Post('/api/v1/db/meta/connection/test')
@Acl('testConnection') @Acl('testConnection')
@HttpCode(200) @HttpCode(200)

3
packages/nocodb-nest/src/modules/view-columns/view-columns.controller.ts

@ -9,6 +9,7 @@ import {
} from '@nestjs/common' } from '@nestjs/common'
import { ColumnReqType, ViewColumnReqType } from 'nocodb-sdk'; import { ColumnReqType, ViewColumnReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard'
import { PagedResponseImpl } from '../../helpers/PagedResponse'; import { PagedResponseImpl } from '../../helpers/PagedResponse';
import { import {
Acl, Acl,
@ -17,7 +18,7 @@ import {
import { ViewColumnsService } from './view-columns.service'; import { ViewColumnsService } from './view-columns.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class ViewColumnsController { export class ViewColumnsController {
constructor(private readonly viewColumnsService: ViewColumnsService) {} constructor(private readonly viewColumnsService: ViewColumnsService) {}

Loading…
Cancel
Save