Skip to content

Commit

Permalink
Bc 4922 cleanup exports authentication (#4487)
Browse files Browse the repository at this point in the history
  • Loading branch information
CeEv authored Oct 20, 2023
1 parent 7b42e1e commit 0ab2dfb
Show file tree
Hide file tree
Showing 49 changed files with 86 additions and 125 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Body, Controller, Delete, Get, Param, Patch, Query } from '@nestjs/common';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { EntityNotFoundError, ForbiddenOperationError, ValidationError } from '@shared/common';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { ICurrentUser, Authenticate, CurrentUser } from '@src/modules/authentication';
import { AccountUc } from '../uc/account.uc';
import {
AccountByIdBodyParams,
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/modules/account/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './account.module';
export * from './account-config';
export { AccountService } from './services';
1 change: 1 addition & 0 deletions apps/server/src/modules/account/services/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './account.service';
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Body, Controller, HttpCode, HttpStatus, Post, UseGuards } from '@nestjs
import { AuthGuard } from '@nestjs/passport';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ForbiddenOperationError, ValidationError } from '@shared/common';
import { CurrentUser } from '../decorator/auth.decorator';
import { CurrentUser } from '../decorator';
import type { ICurrentUser, OauthCurrentUser } from '../interface';
import { LoginDto } from '../uc/dto';
import { LoginUc } from '../uc/login.uc';
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/modules/authentication/decorator/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './auth.decorator';
4 changes: 4 additions & 0 deletions apps/server/src/modules/authentication/errors/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './brute-force.error';
export * from './ldap-connection.error';
export * from './school-in-migration.error';
export * from './unauthorized.loggable-exception';
4 changes: 2 additions & 2 deletions apps/server/src/modules/authentication/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './interface';
export * from './guard/jwt-auth.guard';
export { ICurrentUser } from './interface';
export { JWT, CurrentUser, Authenticate } from './decorator';
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface CreateJwtPayload {
roles: string[];
systemId?: string; // without this the user needs to change his PW during first login
support?: boolean;
// support UserId is missed see featherJS
}

export interface JwtPayload extends CreateJwtPayload {
Expand Down
24 changes: 0 additions & 24 deletions apps/server/src/modules/authentication/interface/user.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
import { EntityId } from '@shared/domain';

export interface IRole {
name: string;

id: string;
}

export interface IResolvedUser {
firstName: string;

lastName: string;

id: string;

createdAt: Date;

updatedAt: Date;

roles: IRole[];

permissions: string[];

schoolId: string;
}

export interface ICurrentUser {
/** authenticated users id */
userId: EntityId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { JwtService } from '@nestjs/jwt';
import { AccountService } from '@src/modules/account/services/account.service';
import { AccountService } from '@src/modules/account';
// invalid import
import { AccountDto } from '@src/modules/account/services/dto';
import { JwtValidationAdapter } from '@src/modules/authentication/strategy/jwt-validation.adapter';
// invalid import, can produce dependency cycles
import type { IServerConfig } from '@src/modules/server';
import { randomUUID } from 'crypto';
import jwt, { JwtPayload } from 'jsonwebtoken';
import { BruteForceError } from '../errors/brute-force.error';
import { UnauthorizedLoggableException } from '../errors/unauthorized.loggable-exception';
import { JwtValidationAdapter } from '../strategy/jwt-validation.adapter';
import { BruteForceError, UnauthorizedLoggableException } from '../errors';
import { CreateJwtPayload } from '../interface/jwt-payload';
import { LoginDto } from '../uc/dto';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@shared/testing';
import { ICurrentUser } from '@src/modules/authentication';
import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard';
import { ServerTestModule } from '@src/modules/server/server.module';
import { ServerTestModule } from '@src/modules/server';
import { Request } from 'express';
import request from 'supertest';
import { BoardResponse } from '../dto';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '@shared/testing';
import { ICurrentUser } from '@src/modules/authentication';
import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard';
import { ServerTestModule } from '@src/modules/server/server.module';
import { ServerTestModule } from '@src/modules/server';
import { Request } from 'express';
import request from 'supertest';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Body, Controller, ForbiddenException, Get, HttpCode, NotFoundException, Param, Patch } from '@nestjs/common';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiValidationError } from '@shared/common';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { SubmissionsResponse } from '@src/modules/board/controller/dto/submission-item/submissions.response';
import { ICurrentUser, Authenticate, CurrentUser } from '@src/modules/authentication';
import { SubmissionsResponse } from './dto/submission-item/submissions.response';
import { CardUc } from '../uc';
import { ElementUc } from '../uc/element.uc';
import { SubmissionItemUc } from '../uc/submission-item.uc';
Expand Down
3 changes: 1 addition & 2 deletions apps/server/src/modules/board/controller/board.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import {
} from '@nestjs/common';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiValidationError } from '@shared/common';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { ICurrentUser, Authenticate, CurrentUser } from '@src/modules/authentication';
import { BoardUc } from '../uc';
import { BoardResponse, BoardUrlParams, ColumnResponse, RenameBodyParams } from './dto';
import { BoardContextResponse } from './dto/board/board-context.reponse';
Expand Down
3 changes: 1 addition & 2 deletions apps/server/src/modules/board/controller/card.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {
} from '@nestjs/common';
import { ApiExtraModels, ApiOperation, ApiResponse, ApiTags, getSchemaPath } from '@nestjs/swagger';
import { ApiValidationError } from '@shared/common';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { ICurrentUser, Authenticate, CurrentUser } from '@src/modules/authentication';
import { BoardUc, CardUc } from '../uc';
import {
AnyContentElementResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import {
} from '@nestjs/common';
import { ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiValidationError } from '@shared/common';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { ICurrentUser, Authenticate, CurrentUser } from '@src/modules/authentication';
import { BoardUc } from '../uc';
import { CardResponse, ColumnUrlParams, MoveColumnBodyParams, RenameBodyParams } from './dto';
import { CardResponseMapper } from './mapper';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import {
} from '@nestjs/common';
import { ApiBody, ApiExtraModels, ApiOperation, ApiResponse, ApiTags, getSchemaPath } from '@nestjs/swagger';
import { ApiValidationError } from '@shared/common';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { ICurrentUser, Authenticate, CurrentUser } from '@src/modules/authentication';
import { CardUc } from '../uc';
import { ElementUc } from '../uc/element.uc';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { ApiResponse, ApiTags } from '@nestjs/swagger';
import { Body, Controller, Param, Patch } from '@nestjs/common';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { Authenticate, CurrentUser, ICurrentUser } from '@src/modules/authentication';
import { LegacyLogger } from '@src/core/logger';
import { ICurrentUser } from '../../authentication/interface/user';
import { CollaborativeStorageUc } from '../uc/collaborative-storage.uc';
import { TeamPermissionsBody } from './dto/team-permissions.body.params';
import { TeamRoleDto } from './dto/team-role.params';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import {
import { ApiConsumes, ApiHeader, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiValidationError, RequestLoggingInterceptor } from '@shared/common';
import { PaginationParams } from '@shared/controller';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { ICurrentUser, Authenticate, CurrentUser } from '@src/modules/authentication';
import { Request, Response } from 'express';
import { GetFileResponse } from '../interface';
import { FilesStorageMapper } from '../mapper';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
StreamableFile,
} from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Authenticate } from '@src/modules/authentication/decorator/auth.decorator';
import { Authenticate } from '@src/modules/authentication';
import { Request, Response } from 'express';
import { FwuLearningContentsUc } from '../uc/fwu-learning-contents.uc';
import { GetFwuLearningContentParams } from './dto/fwu-learning-contents.params';
Expand Down
3 changes: 1 addition & 2 deletions apps/server/src/modules/group/controller/group.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { PaginationParams } from '@shared/controller';
import { Page } from '@shared/domain';
import { ErrorResponse } from '@src/core/error/dto';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { ICurrentUser, Authenticate, CurrentUser } from '@src/modules/authentication';
import { GroupUc } from '../uc';
import { ClassInfoDto } from '../uc/dto';
import { ClassInfoSearchListResponse, ClassSortParams } from './dto';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BadRequestException, Controller, ForbiddenException, Get, InternalServerErrorException } from '@nestjs/common';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiValidationError } from '@shared/common';
import { Authenticate } from '@src/modules/authentication/decorator/auth.decorator';
import { Authenticate } from '@src/modules/authentication';

// Dummy html response so we can test i-frame integration
const dummyResponse = (title: string) => `
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Controller, Get, NotFoundException, Param, Query, Res, StreamableFile } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { ICurrentUser, Authenticate, CurrentUser } from '@src/modules/authentication';
import { PaginationParams } from '@shared/controller/';
import { ICurrentUser } from '@src/modules/authentication';
import { Response } from 'express';
import { ConfigService } from '@nestjs/config';
import { CourseUc } from '../uc/course.uc';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Body, Controller, Get, Param, Patch, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { ICurrentUser, Authenticate, CurrentUser } from '@src/modules/authentication';
import { DashboardMapper } from '../mapper/dashboard.mapper';
import { DashboardUc } from '../uc/dashboard.uc';
import { DashboardResponse, DashboardUrlParams, MoveElementParams, PatchGroupParams } from './dto';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { RequestTimeout } from '@shared/common';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { ICurrentUser, Authenticate, CurrentUser } from '@src/modules/authentication';
import { CopyApiResponse, CopyMapper } from '@src/modules/copy-helper';
import { serverConfig } from '@src/modules/server/server.config';
import { RoomBoardResponseMapper } from '../mapper/room-board-response.mapper';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {
ApiTags,
ApiUnauthorizedResponse,
} from '@nestjs/swagger';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { ICurrentUser, Authenticate, CurrentUser } from '@src/modules/authentication';
import { MigrationMapper } from '../mapper/migration.mapper';
import { OauthMigrationDto } from '../uc/dto/oauth-migration.dto';
import { LegacySchoolUc } from '../uc';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Controller, Delete, Param } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { ICurrentUser, Authenticate, CurrentUser } from '@src/modules/authentication';
import { LessonUC } from '../uc';
import { LessonUrlParams } from './dto';

Expand Down
3 changes: 1 addition & 2 deletions apps/server/src/modules/news/controller/news.controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { PaginationParams } from '@shared/controller';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { ICurrentUser, Authenticate, CurrentUser } from '@src/modules/authentication';
import { NewsMapper } from '../mapper/news.mapper';
import { NewsUc } from '../uc/news.uc';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { Controller, Get, Param, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { ICurrentUser } from '@src/modules/authentication';

import { ICurrentUser, Authenticate, CurrentUser } from '@src/modules/authentication';
import { PaginationParams } from '@shared/controller';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';

import { NewsMapper } from '../mapper/news.mapper';
import { NewsUc } from '../uc';
import { FilterNewsParams, NewsListResponse, TeamUrlParams } from './dto';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { Configuration } from '@hpi-schul-cloud/commons/lib';
import { Configuration } from '@hpi-schul-cloud/commons';
import { Body, Controller, Delete, Get, Param, Patch, Post, Put, Query } from '@nestjs/common';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { OauthProviderLogoutFlowUc } from '@src/modules/oauth-provider/uc/oauth-provider.logout-flow.uc';
import { OauthProviderLoginFlowUc } from '@src/modules/oauth-provider/uc/oauth-provider.login-flow.uc';
import { OauthProviderResponseMapper } from '@src/modules/oauth-provider/mapper/oauth-provider-response.mapper';
import { OauthProviderConsentFlowUc } from '@src/modules/oauth-provider/uc/oauth-provider.consent-flow.uc';
import { ICurrentUser, Authenticate, CurrentUser } from '@src/modules/authentication';
// import should be @shared/infra/oauth-provider
import {
ProviderConsentResponse,
ProviderLoginResponse,
ProviderOauthClient,
ProviderRedirectResponse,
ProviderConsentSessionResponse,
} from '@shared/infra/oauth-provider/dto';
import { ConsentResponse } from '@src/modules/oauth-provider/controller/dto/response/consent.response';
import { ICurrentUser } from '@src/modules/authentication';
import { OauthProviderClientCrudUc } from '@src/modules/oauth-provider/uc/oauth-provider.client-crud.uc';
import { RedirectResponse } from '@src/modules/oauth-provider/controller/dto/response/redirect.response';
import { ProviderConsentSessionResponse } from '@shared/infra/oauth-provider/dto/response/consent-session.response';
import { ApiTags } from '@nestjs/swagger';
import { OauthProviderLogoutFlowUc } from '../uc/oauth-provider.logout-flow.uc';
import { OauthProviderLoginFlowUc } from '../uc/oauth-provider.login-flow.uc';
import { OauthProviderResponseMapper } from '../mapper/oauth-provider-response.mapper';
import { OauthProviderConsentFlowUc } from '../uc/oauth-provider.consent-flow.uc';
import { ConsentResponse } from './dto/response/consent.response';
import { OauthProviderClientCrudUc } from '../uc/oauth-provider.client-crud.uc';
import { RedirectResponse } from './dto/response/redirect.response';
import { OauthProviderUc } from '../uc/oauth-provider.uc';
import {
AcceptQuery,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ import {
import { ApiOkResponse, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ISession } from '@shared/domain/types/session';
import { LegacyLogger } from '@src/core/logger';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser, JWT } from '@src/modules/authentication/decorator/auth.decorator';
import { UserMigrationResponse } from '@src/modules/oauth/controller/dto/user-migration.response';
import { HydraOauthUc } from '@src/modules/oauth/uc/hydra-oauth.uc';
import { ICurrentUser, Authenticate, CurrentUser, JWT } from '@src/modules/authentication';
import { OAuthMigrationError } from '@src/modules/user-login-migration/error/oauth-migration.error';
import { MigrationDto } from '@src/modules/user-login-migration/service/dto';
import { CookieOptions, Request, Response } from 'express';
import { HydraOauthUc } from '../uc/hydra-oauth.uc';
import { UserMigrationResponse } from './dto/user-migration.response';
import { OAuthSSOError } from '../loggable/oauth-sso.error';
import { OAuthTokenDto } from '../interface';
import { OauthLoginStateMapper } from '../mapper/oauth-login-state.mapper';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {
ApiUnauthorizedResponse,
} from '@nestjs/swagger';
import { Pseudonym } from '@shared/domain';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser, ICurrentUser } from '@src/modules/authentication';
import { PseudonymMapper } from '../mapper/pseudonym.mapper';
import { PseudonymUc } from '../uc';
import { PseudonymResponse } from './dto';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import {
} from '@nestjs/common';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiValidationError, RequestTimeout } from '@shared/common';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { Authenticate, CurrentUser, ICurrentUser } from '@src/modules/authentication';
import { CopyApiResponse, CopyMapper } from '@src/modules/copy-helper';
// invalid import can produce dependency cycles
import { serverConfig } from '@src/modules/server/server.config';
import { ShareTokenInfoResponseMapper, ShareTokenResponseMapper } from '../mapper';
import { ShareTokenUC } from '../uc';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Controller, Delete, Get, Param } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { ICurrentUser } from '@src/modules/authentication';
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator';
import { Authenticate, CurrentUser, ICurrentUser } from '@src/modules/authentication';
import { SubmissionMapper } from '../mapper';
import { SubmissionUc } from '../uc';
import { SubmissionStatusListResponse, SubmissionUrlParams, TaskUrlParams } from './dto';
Expand Down
Loading

0 comments on commit 0ab2dfb

Please sign in to comment.