From b24f8b0a76665a65f9437de646ef8f2e0ae4f1c9 Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Tue, 17 Dec 2024 15:27:01 +0100 Subject: [PATCH] refactor(auth): rename identity-module to auth-module Signed-off-by: Erik Michelson --- backend/src/api-token/api-token.service.spec.ts | 2 +- backend/src/api/private/alias/alias.controller.ts | 4 ++-- backend/src/api/private/auth/auth.controller.ts | 13 +++++-------- .../src/api/private/auth/ldap/ldap.controller.ts | 10 +++++----- .../src/api/private/auth/local/local.controller.ts | 12 ++++++------ .../src/api/private/auth/oidc/oidc.controller.ts | 8 ++++---- backend/src/api/private/groups/groups.controller.ts | 4 ++-- .../api/private/me/history/history.controller.ts | 4 ++-- backend/src/api/private/me/me.controller.ts | 2 +- backend/src/api/private/media/media.controller.ts | 2 +- backend/src/api/private/notes/notes.controller.ts | 4 ++-- backend/src/api/private/private-api.module.ts | 4 ++-- .../src/api/private/tokens/api-tokens.controller.ts | 4 ++-- backend/src/app.module.ts | 4 ++-- .../identity.module.ts => auth/auth.module.ts} | 2 +- backend/src/{identity => auth}/identity.entity.ts | 0 backend/src/{identity => auth}/identity.service.ts | 0 .../src/{identity => auth}/ldap/ldap-login.dto.ts | 2 +- backend/src/{identity => auth}/ldap/ldap.service.ts | 0 .../src/{identity => auth}/local/local.service.ts | 0 backend/src/{identity => auth}/local/login.dto.ts | 2 +- .../src/{identity => auth}/local/register.dto.ts | 2 +- .../{identity => auth}/local/update-password.dto.ts | 2 +- backend/src/{identity => auth}/oidc/oidc.service.ts | 0 .../pending-user-confirmation.dto.ts | 0 .../src/{identity => auth}/provider-type.enum.ts | 0 backend/src/{identity => auth}/session.guard.ts | 0 backend/src/frontend-config/frontend-config.dto.ts | 2 +- .../frontend-config/frontend-config.service.spec.ts | 2 +- .../src/frontend-config/frontend-config.service.ts | 2 +- backend/src/history/history.service.spec.ts | 4 ++-- backend/src/media/media.service.spec.ts | 2 +- backend/src/notes/alias.service.spec.ts | 2 +- backend/src/notes/notes.service.spec.ts | 2 +- backend/src/permissions/permissions.service.spec.ts | 4 ++-- .../realtime/websocket/websocket.gateway.spec.ts | 4 ++-- backend/src/revisions/revisions.service.spec.ts | 4 ++-- backend/src/seed.ts | 4 ++-- backend/src/sessions/session.service.ts | 2 +- backend/src/users/user.entity.ts | 2 +- backend/src/users/users.module.ts | 4 ++-- backend/test/private-api/auth.e2e-spec.ts | 8 ++++---- backend/test/private-api/groups.e2e-spec.ts | 4 ++-- backend/test/private-api/history.e2e-spec.ts | 2 +- .../test/private-api/register-and-login.e2e-spec.ts | 6 +++--- backend/test/test-setup.ts | 12 ++++++------ 46 files changed, 78 insertions(+), 81 deletions(-) rename backend/src/{identity/identity.module.ts => auth/auth.module.ts} (96%) rename backend/src/{identity => auth}/identity.entity.ts (100%) rename backend/src/{identity => auth}/identity.service.ts (100%) rename backend/src/{identity => auth}/ldap/ldap-login.dto.ts (81%) rename backend/src/{identity => auth}/ldap/ldap.service.ts (100%) rename backend/src/{identity => auth}/local/local.service.ts (100%) rename backend/src/{identity => auth}/local/login.dto.ts (84%) rename backend/src/{identity => auth}/local/register.dto.ts (85%) rename backend/src/{identity => auth}/local/update-password.dto.ts (77%) rename backend/src/{identity => auth}/oidc/oidc.service.ts (100%) rename backend/src/{identity => auth}/pending-user-confirmation.dto.ts (100%) rename backend/src/{identity => auth}/provider-type.enum.ts (100%) rename backend/src/{identity => auth}/session.guard.ts (100%) diff --git a/backend/src/api-token/api-token.service.spec.ts b/backend/src/api-token/api-token.service.spec.ts index d063e5736..cac6f8097 100644 --- a/backend/src/api-token/api-token.service.spec.ts +++ b/backend/src/api-token/api-token.service.spec.ts @@ -10,6 +10,7 @@ import { getRepositoryToken } from '@nestjs/typeorm'; import crypto from 'crypto'; import { Repository } from 'typeorm'; +import { Identity } from '../auth/identity.entity'; import appConfigMock from '../config/mock/app.config.mock'; import authConfigMock from '../config/mock/auth.config.mock'; import { @@ -17,7 +18,6 @@ import { TokenNotValidError, TooManyTokensError, } from '../errors/errors'; -import { Identity } from '../identity/identity.entity'; import { LoggerModule } from '../logger/logger.module'; import { Session } from '../sessions/session.entity'; import { User } from '../users/user.entity'; diff --git a/backend/src/api/private/alias/alias.controller.ts b/backend/src/api/private/alias/alias.controller.ts index dff7ca7a1..3bf49db5f 100644 --- a/backend/src/api/private/alias/alias.controller.ts +++ b/backend/src/api/private/alias/alias.controller.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -16,7 +16,7 @@ import { } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { SessionGuard } from '../../../identity/session.guard'; +import { SessionGuard } from '../../../auth/session.guard'; import { ConsoleLoggerService } from '../../../logger/console-logger.service'; import { AliasCreateDto } from '../../../notes/alias-create.dto'; import { AliasUpdateDto } from '../../../notes/alias-update.dto'; diff --git a/backend/src/api/private/auth/auth.controller.ts b/backend/src/api/private/auth/auth.controller.ts index a80bc4f0c..945023440 100644 --- a/backend/src/api/private/auth/auth.controller.ts +++ b/backend/src/api/private/auth/auth.controller.ts @@ -15,14 +15,11 @@ import { } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { IdentityService } from '../../../identity/identity.service'; -import { OidcService } from '../../../identity/oidc/oidc.service'; -import { PendingUserConfirmationDto } from '../../../identity/pending-user-confirmation.dto'; -import { ProviderType } from '../../../identity/provider-type.enum'; -import { - RequestWithSession, - SessionGuard, -} from '../../../identity/session.guard'; +import { IdentityService } from '../../../auth/identity.service'; +import { OidcService } from '../../../auth/oidc/oidc.service'; +import { PendingUserConfirmationDto } from '../../../auth/pending-user-confirmation.dto'; +import { ProviderType } from '../../../auth/provider-type.enum'; +import { RequestWithSession, SessionGuard } from '../../../auth/session.guard'; import { ConsoleLoggerService } from '../../../logger/console-logger.service'; import { FullUserInfoDto } from '../../../users/user-info.dto'; import { OpenApi } from '../../utils/openapi.decorator'; diff --git a/backend/src/api/private/auth/ldap/ldap.controller.ts b/backend/src/api/private/auth/ldap/ldap.controller.ts index 3100c90fa..e025885a8 100644 --- a/backend/src/api/private/auth/ldap/ldap.controller.ts +++ b/backend/src/api/private/auth/ldap/ldap.controller.ts @@ -13,12 +13,12 @@ import { } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; +import { IdentityService } from '../../../../auth/identity.service'; +import { LdapLoginDto } from '../../../../auth/ldap/ldap-login.dto'; +import { LdapService } from '../../../../auth/ldap/ldap.service'; +import { ProviderType } from '../../../../auth/provider-type.enum'; +import { RequestWithSession } from '../../../../auth/session.guard'; import { NotInDBError } from '../../../../errors/errors'; -import { IdentityService } from '../../../../identity/identity.service'; -import { LdapLoginDto } from '../../../../identity/ldap/ldap-login.dto'; -import { LdapService } from '../../../../identity/ldap/ldap.service'; -import { ProviderType } from '../../../../identity/provider-type.enum'; -import { RequestWithSession } from '../../../../identity/session.guard'; import { ConsoleLoggerService } from '../../../../logger/console-logger.service'; import { UsersService } from '../../../../users/users.service'; import { makeUsernameLowercase } from '../../../../utils/username'; diff --git a/backend/src/api/private/auth/local/local.controller.ts b/backend/src/api/private/auth/local/local.controller.ts index 324125306..67821b974 100644 --- a/backend/src/api/private/auth/local/local.controller.ts +++ b/backend/src/api/private/auth/local/local.controller.ts @@ -14,15 +14,15 @@ import { } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { LocalService } from '../../../../identity/local/local.service'; -import { LoginDto } from '../../../../identity/local/login.dto'; -import { RegisterDto } from '../../../../identity/local/register.dto'; -import { UpdatePasswordDto } from '../../../../identity/local/update-password.dto'; -import { ProviderType } from '../../../../identity/provider-type.enum'; +import { LocalService } from '../../../../auth/local/local.service'; +import { LoginDto } from '../../../../auth/local/login.dto'; +import { RegisterDto } from '../../../../auth/local/register.dto'; +import { UpdatePasswordDto } from '../../../../auth/local/update-password.dto'; +import { ProviderType } from '../../../../auth/provider-type.enum'; import { RequestWithSession, SessionGuard, -} from '../../../../identity/session.guard'; +} from '../../../../auth/session.guard'; import { ConsoleLoggerService } from '../../../../logger/console-logger.service'; import { User } from '../../../../users/user.entity'; import { UsersService } from '../../../../users/users.service'; diff --git a/backend/src/api/private/auth/oidc/oidc.controller.ts b/backend/src/api/private/auth/oidc/oidc.controller.ts index 286173f2e..0b558d982 100644 --- a/backend/src/api/private/auth/oidc/oidc.controller.ts +++ b/backend/src/api/private/auth/oidc/oidc.controller.ts @@ -15,10 +15,10 @@ import { import { HttpException } from '@nestjs/common/exceptions/http.exception'; import { ApiTags } from '@nestjs/swagger'; -import { IdentityService } from '../../../../identity/identity.service'; -import { OidcService } from '../../../../identity/oidc/oidc.service'; -import { ProviderType } from '../../../../identity/provider-type.enum'; -import { RequestWithSession } from '../../../../identity/session.guard'; +import { IdentityService } from '../../../../auth/identity.service'; +import { OidcService } from '../../../../auth/oidc/oidc.service'; +import { ProviderType } from '../../../../auth/provider-type.enum'; +import { RequestWithSession } from '../../../../auth/session.guard'; import { ConsoleLoggerService } from '../../../../logger/console-logger.service'; import { UsersService } from '../../../../users/users.service'; import { OpenApi } from '../../../utils/openapi.decorator'; diff --git a/backend/src/api/private/groups/groups.controller.ts b/backend/src/api/private/groups/groups.controller.ts index c9d43edf5..7b8631320 100644 --- a/backend/src/api/private/groups/groups.controller.ts +++ b/backend/src/api/private/groups/groups.controller.ts @@ -1,14 +1,14 @@ /* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ import { Controller, Get, Param, UseGuards } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; +import { SessionGuard } from '../../../auth/session.guard'; import { GroupInfoDto } from '../../../groups/group-info.dto'; import { GroupsService } from '../../../groups/groups.service'; -import { SessionGuard } from '../../../identity/session.guard'; import { ConsoleLoggerService } from '../../../logger/console-logger.service'; import { OpenApi } from '../../utils/openapi.decorator'; diff --git a/backend/src/api/private/me/history/history.controller.ts b/backend/src/api/private/me/history/history.controller.ts index c8e0d8d03..c35306a23 100644 --- a/backend/src/api/private/me/history/history.controller.ts +++ b/backend/src/api/private/me/history/history.controller.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -15,11 +15,11 @@ import { } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; +import { SessionGuard } from '../../../../auth/session.guard'; import { HistoryEntryImportListDto } from '../../../../history/history-entry-import.dto'; import { HistoryEntryUpdateDto } from '../../../../history/history-entry-update.dto'; import { HistoryEntryDto } from '../../../../history/history-entry.dto'; import { HistoryService } from '../../../../history/history.service'; -import { SessionGuard } from '../../../../identity/session.guard'; import { ConsoleLoggerService } from '../../../../logger/console-logger.service'; import { Note } from '../../../../notes/note.entity'; import { User } from '../../../../users/user.entity'; diff --git a/backend/src/api/private/me/me.controller.ts b/backend/src/api/private/me/me.controller.ts index 6d27a9c46..d5660dd9f 100644 --- a/backend/src/api/private/me/me.controller.ts +++ b/backend/src/api/private/me/me.controller.ts @@ -6,7 +6,7 @@ import { Body, Controller, Delete, Get, Post, UseGuards } from '@nestjs/common'; import { ApiBody, ApiTags } from '@nestjs/swagger'; -import { SessionGuard } from '../../../identity/session.guard'; +import { SessionGuard } from '../../../auth/session.guard'; import { ConsoleLoggerService } from '../../../logger/console-logger.service'; import { MediaUploadDto } from '../../../media/media-upload.dto'; import { MediaService } from '../../../media/media.service'; diff --git a/backend/src/api/private/media/media.controller.ts b/backend/src/api/private/media/media.controller.ts index f54f0bd23..fe624bb77 100644 --- a/backend/src/api/private/media/media.controller.ts +++ b/backend/src/api/private/media/media.controller.ts @@ -19,8 +19,8 @@ import { FileInterceptor } from '@nestjs/platform-express'; import { ApiBody, ApiConsumes, ApiHeader, ApiTags } from '@nestjs/swagger'; import { Response } from 'express'; +import { SessionGuard } from '../../../auth/session.guard'; import { PermissionError } from '../../../errors/errors'; -import { SessionGuard } from '../../../identity/session.guard'; import { ConsoleLoggerService } from '../../../logger/console-logger.service'; import { MediaUploadDto } from '../../../media/media-upload.dto'; import { MediaService } from '../../../media/media.service'; diff --git a/backend/src/api/private/notes/notes.controller.ts b/backend/src/api/private/notes/notes.controller.ts index fa64c4f23..b650d7b7a 100644 --- a/backend/src/api/private/notes/notes.controller.ts +++ b/backend/src/api/private/notes/notes.controller.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -17,10 +17,10 @@ import { } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; +import { SessionGuard } from '../../../auth/session.guard'; import { NotInDBError } from '../../../errors/errors'; import { GroupsService } from '../../../groups/groups.service'; import { HistoryService } from '../../../history/history.service'; -import { SessionGuard } from '../../../identity/session.guard'; import { ConsoleLoggerService } from '../../../logger/console-logger.service'; import { MediaUploadDto } from '../../../media/media-upload.dto'; import { MediaService } from '../../../media/media.service'; diff --git a/backend/src/api/private/private-api.module.ts b/backend/src/api/private/private-api.module.ts index 9215f1089..169ec3ec6 100644 --- a/backend/src/api/private/private-api.module.ts +++ b/backend/src/api/private/private-api.module.ts @@ -6,10 +6,10 @@ import { Module } from '@nestjs/common'; import { ApiTokenModule } from '../../api-token/api-token.module'; +import { AuthModule } from '../../auth/auth.module'; import { FrontendConfigModule } from '../../frontend-config/frontend-config.module'; import { GroupsModule } from '../../groups/groups.module'; import { HistoryModule } from '../../history/history.module'; -import { IdentityModule } from '../../identity/identity.module'; import { LoggerModule } from '../../logger/logger.module'; import { MediaModule } from '../../media/media.module'; import { NotesModule } from '../../notes/notes.module'; @@ -41,7 +41,7 @@ import { UsersController } from './users/users.controller'; NotesModule, MediaModule, RevisionsModule, - IdentityModule, + AuthModule, GroupsModule, ], controllers: [ diff --git a/backend/src/api/private/tokens/api-tokens.controller.ts b/backend/src/api/private/tokens/api-tokens.controller.ts index 9d6fa989d..e9e22e847 100644 --- a/backend/src/api/private/tokens/api-tokens.controller.ts +++ b/backend/src/api/private/tokens/api-tokens.controller.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -21,7 +21,7 @@ import { ApiTokenWithSecretDto, } from '../../../api-token/api-token.dto'; import { ApiTokenService } from '../../../api-token/api-token.service'; -import { SessionGuard } from '../../../identity/session.guard'; +import { SessionGuard } from '../../../auth/session.guard'; import { ConsoleLoggerService } from '../../../logger/console-logger.service'; import { User } from '../../../users/user.entity'; import { OpenApi } from '../../utils/openapi.decorator'; diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index a970f7044..96e241fc2 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -13,6 +13,7 @@ import { TypeOrmModule } from '@nestjs/typeorm'; import { ApiTokenModule } from './api-token/api-token.module'; import { PrivateApiModule } from './api/private/private-api.module'; import { PublicApiModule } from './api/public/public-api.module'; +import { AuthModule } from './auth/auth.module'; import { AuthorsModule } from './authors/authors.module'; import appConfig from './config/app.config'; import authConfig from './config/auth.config'; @@ -27,7 +28,6 @@ import { FrontendConfigModule } from './frontend-config/frontend-config.module'; import { FrontendConfigService } from './frontend-config/frontend-config.service'; import { GroupsModule } from './groups/groups.module'; import { HistoryModule } from './history/history.module'; -import { IdentityModule } from './identity/identity.module'; import { LoggerModule } from './logger/logger.module'; import { TypeormLoggerService } from './logger/typeorm-logger.service'; import { MediaRedirectModule } from './media-redirect/media-redirect.module'; @@ -115,7 +115,7 @@ const routes: Routes = [ ApiTokenModule, FrontendConfigModule, WebsocketModule, - IdentityModule, + AuthModule, SessionModule, MediaRedirectModule, ], diff --git a/backend/src/identity/identity.module.ts b/backend/src/auth/auth.module.ts similarity index 96% rename from backend/src/identity/identity.module.ts rename to backend/src/auth/auth.module.ts index 728a47a98..2bef49471 100644 --- a/backend/src/identity/identity.module.ts +++ b/backend/src/auth/auth.module.ts @@ -25,4 +25,4 @@ import { OidcService } from './oidc/oidc.service'; providers: [IdentityService, LdapService, LocalService, OidcService], exports: [IdentityService, LdapService, LocalService, OidcService], }) -export class IdentityModule {} +export class AuthModule {} diff --git a/backend/src/identity/identity.entity.ts b/backend/src/auth/identity.entity.ts similarity index 100% rename from backend/src/identity/identity.entity.ts rename to backend/src/auth/identity.entity.ts diff --git a/backend/src/identity/identity.service.ts b/backend/src/auth/identity.service.ts similarity index 100% rename from backend/src/identity/identity.service.ts rename to backend/src/auth/identity.service.ts diff --git a/backend/src/identity/ldap/ldap-login.dto.ts b/backend/src/auth/ldap/ldap-login.dto.ts similarity index 81% rename from backend/src/identity/ldap/ldap-login.dto.ts rename to backend/src/auth/ldap/ldap-login.dto.ts index 6926921f7..9c28af41d 100644 --- a/backend/src/identity/ldap/ldap-login.dto.ts +++ b/backend/src/auth/ldap/ldap-login.dto.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ diff --git a/backend/src/identity/ldap/ldap.service.ts b/backend/src/auth/ldap/ldap.service.ts similarity index 100% rename from backend/src/identity/ldap/ldap.service.ts rename to backend/src/auth/ldap/ldap.service.ts diff --git a/backend/src/identity/local/local.service.ts b/backend/src/auth/local/local.service.ts similarity index 100% rename from backend/src/identity/local/local.service.ts rename to backend/src/auth/local/local.service.ts diff --git a/backend/src/identity/local/login.dto.ts b/backend/src/auth/local/login.dto.ts similarity index 84% rename from backend/src/identity/local/login.dto.ts rename to backend/src/auth/local/login.dto.ts index 7ec9af2a7..cb3ed66ad 100644 --- a/backend/src/identity/local/login.dto.ts +++ b/backend/src/auth/local/login.dto.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ diff --git a/backend/src/identity/local/register.dto.ts b/backend/src/auth/local/register.dto.ts similarity index 85% rename from backend/src/identity/local/register.dto.ts rename to backend/src/auth/local/register.dto.ts index 7a375b8c0..a6eec0351 100644 --- a/backend/src/identity/local/register.dto.ts +++ b/backend/src/auth/local/register.dto.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ diff --git a/backend/src/identity/local/update-password.dto.ts b/backend/src/auth/local/update-password.dto.ts similarity index 77% rename from backend/src/identity/local/update-password.dto.ts rename to backend/src/auth/local/update-password.dto.ts index abc379276..8f3edc276 100644 --- a/backend/src/identity/local/update-password.dto.ts +++ b/backend/src/auth/local/update-password.dto.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ diff --git a/backend/src/identity/oidc/oidc.service.ts b/backend/src/auth/oidc/oidc.service.ts similarity index 100% rename from backend/src/identity/oidc/oidc.service.ts rename to backend/src/auth/oidc/oidc.service.ts diff --git a/backend/src/identity/pending-user-confirmation.dto.ts b/backend/src/auth/pending-user-confirmation.dto.ts similarity index 100% rename from backend/src/identity/pending-user-confirmation.dto.ts rename to backend/src/auth/pending-user-confirmation.dto.ts diff --git a/backend/src/identity/provider-type.enum.ts b/backend/src/auth/provider-type.enum.ts similarity index 100% rename from backend/src/identity/provider-type.enum.ts rename to backend/src/auth/provider-type.enum.ts diff --git a/backend/src/identity/session.guard.ts b/backend/src/auth/session.guard.ts similarity index 100% rename from backend/src/identity/session.guard.ts rename to backend/src/auth/session.guard.ts diff --git a/backend/src/frontend-config/frontend-config.dto.ts b/backend/src/frontend-config/frontend-config.dto.ts index 05c2be0cc..4805084d9 100644 --- a/backend/src/frontend-config/frontend-config.dto.ts +++ b/backend/src/frontend-config/frontend-config.dto.ts @@ -15,8 +15,8 @@ import { } from 'class-validator'; import { URL } from 'url'; +import { ProviderType } from '../auth/provider-type.enum'; import { GuestAccess } from '../config/guest_access.enum'; -import { ProviderType } from '../identity/provider-type.enum'; import { ServerVersion } from '../monitoring/server-status.dto'; import { BaseDto } from '../utils/base.dto.'; diff --git a/backend/src/frontend-config/frontend-config.service.spec.ts b/backend/src/frontend-config/frontend-config.service.spec.ts index 3ea587e0a..dec298439 100644 --- a/backend/src/frontend-config/frontend-config.service.spec.ts +++ b/backend/src/frontend-config/frontend-config.service.spec.ts @@ -7,6 +7,7 @@ import { ConfigModule, registerAs } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; import { URL } from 'url'; +import { ProviderType } from '../auth/provider-type.enum'; import { AppConfig } from '../config/app.config'; import { AuthConfig } from '../config/auth.config'; import { CustomizationConfig } from '../config/customization.config'; @@ -15,7 +16,6 @@ import { ExternalServicesConfig } from '../config/external-services.config'; import { GuestAccess } from '../config/guest_access.enum'; import { Loglevel } from '../config/loglevel.enum'; import { NoteConfig } from '../config/note.config'; -import { ProviderType } from '../identity/provider-type.enum'; import { LoggerModule } from '../logger/logger.module'; import { getServerVersionFromPackageJson } from '../utils/serverVersion'; import { FrontendConfigService } from './frontend-config.service'; diff --git a/backend/src/frontend-config/frontend-config.service.ts b/backend/src/frontend-config/frontend-config.service.ts index b880c1352..5242c4ed9 100644 --- a/backend/src/frontend-config/frontend-config.service.ts +++ b/backend/src/frontend-config/frontend-config.service.ts @@ -6,6 +6,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { URL } from 'url'; +import { ProviderType } from '../auth/provider-type.enum'; import appConfiguration, { AppConfig } from '../config/app.config'; import authConfiguration, { AuthConfig } from '../config/auth.config'; import customizationConfiguration, { @@ -15,7 +16,6 @@ import externalServicesConfiguration, { ExternalServicesConfig, } from '../config/external-services.config'; import noteConfiguration, { NoteConfig } from '../config/note.config'; -import { ProviderType } from '../identity/provider-type.enum'; import { ConsoleLoggerService } from '../logger/console-logger.service'; import { getServerVersionFromPackageJson } from '../utils/serverVersion'; import { diff --git a/backend/src/history/history.service.spec.ts b/backend/src/history/history.service.spec.ts index 623d48fba..5ca219d94 100644 --- a/backend/src/history/history.service.spec.ts +++ b/backend/src/history/history.service.spec.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -12,6 +12,7 @@ import { Mock } from 'ts-mockery'; import { DataSource, EntityManager, Repository } from 'typeorm'; import { ApiToken } from '../api-token/api-token.entity'; +import { Identity } from '../auth/identity.entity'; import { Author } from '../authors/author.entity'; import appConfigMock from '../config/mock/app.config.mock'; import authConfigMock from '../config/mock/auth.config.mock'; @@ -20,7 +21,6 @@ import noteConfigMock from '../config/mock/note.config.mock'; import { NotInDBError } from '../errors/errors'; import { eventModuleConfig } from '../events'; import { Group } from '../groups/group.entity'; -import { Identity } from '../identity/identity.entity'; import { LoggerModule } from '../logger/logger.module'; import { Alias } from '../notes/alias.entity'; import { Note } from '../notes/note.entity'; diff --git a/backend/src/media/media.service.spec.ts b/backend/src/media/media.service.spec.ts index a9192a853..c04c4e373 100644 --- a/backend/src/media/media.service.spec.ts +++ b/backend/src/media/media.service.spec.ts @@ -12,6 +12,7 @@ import { Repository } from 'typeorm'; import appConfigMock from '../../src/config/mock/app.config.mock'; import { ApiToken } from '../api-token/api-token.entity'; +import { Identity } from '../auth/identity.entity'; import { Author } from '../authors/author.entity'; import authConfigMock from '../config/mock/auth.config.mock'; import databaseConfigMock from '../config/mock/database.config.mock'; @@ -20,7 +21,6 @@ import noteConfigMock from '../config/mock/note.config.mock'; import { ClientError, NotInDBError } from '../errors/errors'; import { eventModuleConfig } from '../events'; import { Group } from '../groups/group.entity'; -import { Identity } from '../identity/identity.entity'; import { LoggerModule } from '../logger/logger.module'; import { Alias } from '../notes/alias.entity'; import { Note } from '../notes/note.entity'; diff --git a/backend/src/notes/alias.service.spec.ts b/backend/src/notes/alias.service.spec.ts index b87c1d3ad..ed3d7acaa 100644 --- a/backend/src/notes/alias.service.spec.ts +++ b/backend/src/notes/alias.service.spec.ts @@ -11,6 +11,7 @@ import { Mock } from 'ts-mockery'; import { DataSource, EntityManager, Repository } from 'typeorm'; import { ApiToken } from '../api-token/api-token.entity'; +import { Identity } from '../auth/identity.entity'; import { Author } from '../authors/author.entity'; import appConfigMock from '../config/mock/app.config.mock'; import authConfigMock from '../config/mock/auth.config.mock'; @@ -25,7 +26,6 @@ import { import { eventModuleConfig } from '../events'; import { Group } from '../groups/group.entity'; import { GroupsModule } from '../groups/groups.module'; -import { Identity } from '../identity/identity.entity'; import { LoggerModule } from '../logger/logger.module'; import { NoteGroupPermission } from '../permissions/note-group-permission.entity'; import { NoteUserPermission } from '../permissions/note-user-permission.entity'; diff --git a/backend/src/notes/notes.service.spec.ts b/backend/src/notes/notes.service.spec.ts index af6f53855..7159430a7 100644 --- a/backend/src/notes/notes.service.spec.ts +++ b/backend/src/notes/notes.service.spec.ts @@ -16,6 +16,7 @@ import { } from 'typeorm'; import { ApiToken } from '../api-token/api-token.entity'; +import { Identity } from '../auth/identity.entity'; import { Author } from '../authors/author.entity'; import { DefaultAccessLevel } from '../config/default-access-level.enum'; import appConfigMock from '../config/mock/app.config.mock'; @@ -36,7 +37,6 @@ import { eventModuleConfig, NoteEvent } from '../events'; import { Group } from '../groups/group.entity'; import { GroupsModule } from '../groups/groups.module'; import { SpecialGroup } from '../groups/groups.special'; -import { Identity } from '../identity/identity.entity'; import { LoggerModule } from '../logger/logger.module'; import { NoteGroupPermission } from '../permissions/note-group-permission.entity'; import { NoteUserPermission } from '../permissions/note-user-permission.entity'; diff --git a/backend/src/permissions/permissions.service.spec.ts b/backend/src/permissions/permissions.service.spec.ts index fb00dd3c9..5e20804d5 100644 --- a/backend/src/permissions/permissions.service.spec.ts +++ b/backend/src/permissions/permissions.service.spec.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -11,6 +11,7 @@ import { Mock } from 'ts-mockery'; import { DataSource, EntityManager, Repository } from 'typeorm'; import { ApiToken } from '../api-token/api-token.entity'; +import { Identity } from '../auth/identity.entity'; import { Author } from '../authors/author.entity'; import { DefaultAccessLevel } from '../config/default-access-level.enum'; import { GuestAccess } from '../config/guest_access.enum'; @@ -27,7 +28,6 @@ import { eventModuleConfig, NoteEvent } from '../events'; import { Group } from '../groups/group.entity'; import { GroupsModule } from '../groups/groups.module'; import { GroupsService } from '../groups/groups.service'; -import { Identity } from '../identity/identity.entity'; import { LoggerModule } from '../logger/logger.module'; import { MediaUpload } from '../media/media-upload.entity'; import { Alias } from '../notes/alias.entity'; diff --git a/backend/src/realtime/websocket/websocket.gateway.spec.ts b/backend/src/realtime/websocket/websocket.gateway.spec.ts index 87be86a0b..2fda7879c 100644 --- a/backend/src/realtime/websocket/websocket.gateway.spec.ts +++ b/backend/src/realtime/websocket/websocket.gateway.spec.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -14,6 +14,7 @@ import { Repository } from 'typeorm'; import WebSocket from 'ws'; import { ApiToken } from '../../api-token/api-token.entity'; +import { Identity } from '../../auth/identity.entity'; import { Author } from '../../authors/author.entity'; import appConfigMock from '../../config/mock/app.config.mock'; import authConfigMock from '../../config/mock/auth.config.mock'; @@ -21,7 +22,6 @@ import databaseConfigMock from '../../config/mock/database.config.mock'; import noteConfigMock from '../../config/mock/note.config.mock'; import { eventModuleConfig } from '../../events'; import { Group } from '../../groups/group.entity'; -import { Identity } from '../../identity/identity.entity'; import { LoggerModule } from '../../logger/logger.module'; import { Alias } from '../../notes/alias.entity'; import { Note } from '../../notes/note.entity'; diff --git a/backend/src/revisions/revisions.service.spec.ts b/backend/src/revisions/revisions.service.spec.ts index 36589560f..9537ba4e2 100644 --- a/backend/src/revisions/revisions.service.spec.ts +++ b/backend/src/revisions/revisions.service.spec.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -12,6 +12,7 @@ import { Mock } from 'ts-mockery'; import { DataSource, EntityManager, Repository } from 'typeorm'; import { ApiToken } from '../api-token/api-token.entity'; +import { Identity } from '../auth/identity.entity'; import { Author } from '../authors/author.entity'; import appConfigMock from '../config/mock/app.config.mock'; import authConfigMock from '../config/mock/auth.config.mock'; @@ -25,7 +26,6 @@ import { NoteConfig } from '../config/note.config'; import { NotInDBError } from '../errors/errors'; import { eventModuleConfig } from '../events'; import { Group } from '../groups/group.entity'; -import { Identity } from '../identity/identity.entity'; import { LoggerModule } from '../logger/logger.module'; import { Alias } from '../notes/alias.entity'; import { Note } from '../notes/note.entity'; diff --git a/backend/src/seed.ts b/backend/src/seed.ts index 1316e6dbe..d5ec98c07 100644 --- a/backend/src/seed.ts +++ b/backend/src/seed.ts @@ -6,11 +6,11 @@ import { DataSource } from 'typeorm'; import { ApiToken } from './api-token/api-token.entity'; +import { Identity } from './auth/identity.entity'; +import { ProviderType } from './auth/provider-type.enum'; import { Author } from './authors/author.entity'; import { Group } from './groups/group.entity'; import { HistoryEntry } from './history/history-entry.entity'; -import { Identity } from './identity/identity.entity'; -import { ProviderType } from './identity/provider-type.enum'; import { MediaUpload } from './media/media-upload.entity'; import { Alias } from './notes/alias.entity'; import { Note } from './notes/note.entity'; diff --git a/backend/src/sessions/session.service.ts b/backend/src/sessions/session.service.ts index 1a73cb474..252342023 100644 --- a/backend/src/sessions/session.service.ts +++ b/backend/src/sessions/session.service.ts @@ -12,12 +12,12 @@ import { unsign } from 'cookie-signature'; import { IncomingMessage } from 'http'; import { Repository } from 'typeorm'; +import { ProviderType } from '../auth/provider-type.enum'; import authConfiguration, { AuthConfig } from '../config/auth.config'; import { DatabaseType } from '../config/database-type.enum'; import databaseConfiguration, { DatabaseConfig, } from '../config/database.config'; -import { ProviderType } from '../identity/provider-type.enum'; import { ConsoleLoggerService } from '../logger/console-logger.service'; import { FullUserInfoDto } from '../users/user-info.dto'; import { HEDGEDOC_SESSION } from '../utils/session'; diff --git a/backend/src/users/user.entity.ts b/backend/src/users/user.entity.ts index 1b683451d..1003a995e 100644 --- a/backend/src/users/user.entity.ts +++ b/backend/src/users/user.entity.ts @@ -14,10 +14,10 @@ import { } from 'typeorm'; import { ApiToken } from '../api-token/api-token.entity'; +import { Identity } from '../auth/identity.entity'; import { Author } from '../authors/author.entity'; import { Group } from '../groups/group.entity'; import { HistoryEntry } from '../history/history-entry.entity'; -import { Identity } from '../identity/identity.entity'; import { MediaUpload } from '../media/media-upload.entity'; import { Note } from '../notes/note.entity'; import { Username } from '../utils/username'; diff --git a/backend/src/users/users.module.ts b/backend/src/users/users.module.ts index 4229214e1..050859ec6 100644 --- a/backend/src/users/users.module.ts +++ b/backend/src/users/users.module.ts @@ -1,12 +1,12 @@ /* - * SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; -import { Identity } from '../identity/identity.entity'; +import { Identity } from '../auth/identity.entity'; import { LoggerModule } from '../logger/logger.module'; import { Session } from '../sessions/session.entity'; import { User } from './user.entity'; diff --git a/backend/test/private-api/auth.e2e-spec.ts b/backend/test/private-api/auth.e2e-spec.ts index 804b08a69..c2ec53463 100644 --- a/backend/test/private-api/auth.e2e-spec.ts +++ b/backend/test/private-api/auth.e2e-spec.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -10,10 +10,10 @@ */ import request from 'supertest'; +import { LoginDto } from '../../src/auth/local/login.dto'; +import { RegisterDto } from '../../src/auth/local/register.dto'; +import { UpdatePasswordDto } from '../../src/auth/local/update-password.dto'; import { NotInDBError } from '../../src/errors/errors'; -import { LoginDto } from '../../src/identity/local/login.dto'; -import { RegisterDto } from '../../src/identity/local/register.dto'; -import { UpdatePasswordDto } from '../../src/identity/local/update-password.dto'; import { UserRelationEnum } from '../../src/users/user-relation.enum'; import { checkPassword } from '../../src/utils/password'; import { Username } from '../../src/utils/username'; diff --git a/backend/test/private-api/groups.e2e-spec.ts b/backend/test/private-api/groups.e2e-spec.ts index e719a08a7..e8093be8a 100644 --- a/backend/test/private-api/groups.e2e-spec.ts +++ b/backend/test/private-api/groups.e2e-spec.ts @@ -1,14 +1,14 @@ /* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ import request from 'supertest'; +import { LoginDto } from '../../src/auth/local/login.dto'; import { GuestAccess } from '../../src/config/guest_access.enum'; import { createDefaultMockNoteConfig } from '../../src/config/mock/note.config.mock'; import { NoteConfig } from '../../src/config/note.config'; -import { LoginDto } from '../../src/identity/local/login.dto'; import { password1, TestSetup, diff --git a/backend/test/private-api/history.e2e-spec.ts b/backend/test/private-api/history.e2e-spec.ts index 27bf460db..4d0a1a9b3 100644 --- a/backend/test/private-api/history.e2e-spec.ts +++ b/backend/test/private-api/history.e2e-spec.ts @@ -5,10 +5,10 @@ */ import request from 'supertest'; +import { LocalService } from '../../src/auth/local/local.service'; import { HistoryEntryImportDto } from '../../src/history/history-entry-import.dto'; import { HistoryEntry } from '../../src/history/history-entry.entity'; import { HistoryService } from '../../src/history/history.service'; -import { LocalService } from '../../src/identity/local/local.service'; import { Note } from '../../src/notes/note.entity'; import { NotesService } from '../../src/notes/notes.service'; import { User } from '../../src/users/user.entity'; diff --git a/backend/test/private-api/register-and-login.e2e-spec.ts b/backend/test/private-api/register-and-login.e2e-spec.ts index 28428ebb2..7c967353c 100644 --- a/backend/test/private-api/register-and-login.e2e-spec.ts +++ b/backend/test/private-api/register-and-login.e2e-spec.ts @@ -1,12 +1,12 @@ /* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ import request from 'supertest'; -import { LoginDto } from '../../src/identity/local/login.dto'; -import { RegisterDto } from '../../src/identity/local/register.dto'; +import { LoginDto } from '../../src/auth/local/login.dto'; +import { RegisterDto } from '../../src/auth/local/register.dto'; import { TestSetup, TestSetupBuilder } from '../test-setup'; describe('Register and Login', () => { diff --git a/backend/test/test-setup.ts b/backend/test/test-setup.ts index 82b36e6b4..441eb30de 100644 --- a/backend/test/test-setup.ts +++ b/backend/test/test-setup.ts @@ -19,6 +19,11 @@ import { MockApiTokenGuard } from '../src/api-token/mock-api-token.guard'; import { PrivateApiModule } from '../src/api/private/private-api.module'; import { PublicApiModule } from '../src/api/public/public-api.module'; import { setupApp } from '../src/app-init'; +import { AuthModule } from '../src/auth/auth.module'; +import { IdentityService } from '../src/auth/identity.service'; +import { LdapService } from '../src/auth/ldap/ldap.service'; +import { LocalService } from '../src/auth/local/local.service'; +import { OidcService } from '../src/auth/oidc/oidc.service'; import { AuthorsModule } from '../src/authors/authors.module'; import { AppConfig } from '../src/config/app.config'; import { AuthConfig } from '../src/config/auth.config'; @@ -62,11 +67,6 @@ import { GroupsModule } from '../src/groups/groups.module'; import { GroupsService } from '../src/groups/groups.service'; import { HistoryModule } from '../src/history/history.module'; import { HistoryService } from '../src/history/history.service'; -import { IdentityModule } from '../src/identity/identity.module'; -import { IdentityService } from '../src/identity/identity.service'; -import { LdapService } from '../src/identity/ldap/ldap.service'; -import { LocalService } from '../src/identity/local/local.service'; -import { OidcService } from '../src/identity/oidc/oidc.service'; import { ConsoleLoggerService } from '../src/logger/console-logger.service'; import { LoggerModule } from '../src/logger/logger.module'; import { MediaModule } from '../src/media/media.module'; @@ -296,7 +296,7 @@ export class TestSetupBuilder { MediaModule, ApiTokenModule, FrontendConfigModule, - IdentityModule, + AuthModule, SessionModule, EventEmitterModule.forRoot(eventModuleConfig), ],