diff --git a/backend/src/middlewares/participant.middleware.ts b/backend/src/middlewares/participant.middleware.ts index ab326af..96f0e43 100644 --- a/backend/src/middlewares/participant.middleware.ts +++ b/backend/src/middlewares/participant.middleware.ts @@ -4,6 +4,13 @@ import { container } from '../config/dependency-injector.config.js'; import { GlobalPreferencesService, LoggerService, RoomService } from '../services/index.js'; import { allowAnonymous, tokenAndRoleValidator, withAuth } from './auth.middleware.js'; +/** + * Middleware to configure authentication based on participant role and authentication mode for entering a room. + * + * - If the authentication mode is MODERATORS_ONLY and the participant role is MODERATOR, configure user authentication. + * - If the authentication mode is ALL_USERS, configure user authentication. + * - Otherwise, allow anonymous access. + */ export const configureTokenAuth = async (req: Request, res: Response, next: NextFunction) => { const logger = container.get(LoggerService); const globalPrefService = container.get(GlobalPreferencesService); diff --git a/backend/src/middlewares/room.middleware.ts b/backend/src/middlewares/room.middleware.ts index ed97a66..47253b2 100644 --- a/backend/src/middlewares/room.middleware.ts +++ b/backend/src/middlewares/room.middleware.ts @@ -5,6 +5,13 @@ import { GlobalPreferencesService } from '../services/index.js'; import { allowAnonymous, apiKeyValidator, tokenAndRoleValidator, withAuth } from './auth.middleware.js'; import { AuthMode, ParticipantRole, UserRole } from '@typings-ce'; +/** + * Middleware that configures authentication for creating a room based on global settings. + * + * - Admin role and API key authentication methods are always allowed. + * - If room creation is allowed and requires authentication, the user must have a valid token. + * - If room creation is allowed and does not require authentication, anonymous users are allowed. + */ export const configureCreateRoomAuth = async (req: Request, res: Response, next: NextFunction) => { const logger = container.get(LoggerService); const globalPrefService = container.get(GlobalPreferencesService);