Update authentication routes to use internal API base path

This commit is contained in:
juancarmore 2025-03-31 20:26:03 +02:00
parent fb0bf4b1e3
commit d308850705
3 changed files with 20 additions and 11 deletions

View File

@ -6,7 +6,7 @@ import { LoggerService } from '../services/logger.service.js';
import {
ACCESS_TOKEN_COOKIE_NAME,
MEET_ACCESS_TOKEN_EXPIRATION,
MEET_API_BASE_PATH_V1,
MEET_INTERNAL_API_BASE_PATH_V1,
MEET_REFRESH_TOKEN_EXPIRATION,
REFRESH_TOKEN_COOKIE_NAME
} from '../environment.js';
@ -35,7 +35,7 @@ export const login = async (req: Request, res: Response) => {
res.cookie(
REFRESH_TOKEN_COOKIE_NAME,
refreshToken,
getCookieOptions(`${MEET_API_BASE_PATH_V1}/auth`, MEET_REFRESH_TOKEN_EXPIRATION)
getCookieOptions(`${MEET_INTERNAL_API_BASE_PATH_V1}/auth`, MEET_REFRESH_TOKEN_EXPIRATION)
);
logger.info(`Login succeeded for user ${username}`);
return res.status(200).json({ message: 'Login succeeded' });
@ -48,7 +48,7 @@ export const login = async (req: Request, res: Response) => {
export const logout = (_req: Request, res: Response) => {
res.clearCookie(ACCESS_TOKEN_COOKIE_NAME);
res.clearCookie(REFRESH_TOKEN_COOKIE_NAME, {
path: `${MEET_API_BASE_PATH_V1}/auth`
path: `${MEET_INTERNAL_API_BASE_PATH_V1}/auth`
});
return res.status(200).json({ message: 'Logout successful' });
};

View File

@ -9,7 +9,13 @@ import {
MEET_API_BASE_PATH_V1,
MEET_INTERNAL_API_BASE_PATH_V1
} from './environment.js';
import { publicApiHtmlFilePath, indexHtmlPath, publicFilesPath, webcomponentBundlePath, internalApiHtmlFilePath } from './utils/path-utils.js';
import {
publicApiHtmlFilePath,
indexHtmlPath,
publicFilesPath,
webcomponentBundlePath,
internalApiHtmlFilePath
} from './utils/path-utils.js';
import {
authRouter,
internalRecordingRouter,
@ -41,14 +47,17 @@ const createApp = () => {
app.use(express.json());
app.use(cookieParser());
// Public API routes
app.use(`${MEET_API_BASE_PATH_V1}/docs`, (_req: Request, res: Response) => res.sendFile(publicApiHtmlFilePath));
app.use(`${MEET_INTERNAL_API_BASE_PATH_V1}/docs`, (_req: Request, res: Response) => res.sendFile(internalApiHtmlFilePath));
app.use(`${MEET_API_BASE_PATH_V1}/rooms`, /*mediaTypeValidatorMiddleware,*/ roomRouter);
app.use(`${MEET_API_BASE_PATH_V1}/recordings`, /*mediaTypeValidatorMiddleware,*/ recordingRouter);
app.use(`${MEET_API_BASE_PATH_V1}/auth`, /*mediaTypeValidatorMiddleware,*/ authRouter);
app.use(`${MEET_API_BASE_PATH_V1}/preferences`, /*mediaTypeValidatorMiddleware,*/ preferencesRouter);
// Internal routes
// Internal API routes
app.use(`${MEET_INTERNAL_API_BASE_PATH_V1}/docs`, (_req: Request, res: Response) =>
res.sendFile(internalApiHtmlFilePath)
);
app.use(`${MEET_INTERNAL_API_BASE_PATH_V1}/auth`, authRouter);
app.use(`${MEET_INTERNAL_API_BASE_PATH_V1}/rooms`, internalRoomRouter);
app.use(`${MEET_INTERNAL_API_BASE_PATH_V1}/participants`, internalParticipantsRouter);
app.use(`${MEET_INTERNAL_API_BASE_PATH_V1}/recordings`, internalRecordingRouter);

View File

@ -96,19 +96,19 @@ export class HttpService {
}
login(body: { username: string; password: string }): Promise<{ message: string }> {
return this.postRequest(`${this.API_PATH_PREFIX}/${this.API_V1_VERSION}/auth/login`, body);
return this.postRequest(`${this.INTERNAL_API_PATH_PREFIX}/${this.API_V1_VERSION}/auth/login`, body);
}
logout(): Promise<{ message: string }> {
return this.postRequest(`${this.API_PATH_PREFIX}/${this.API_V1_VERSION}/auth/logout`);
return this.postRequest(`${this.INTERNAL_API_PATH_PREFIX}/${this.API_V1_VERSION}/auth/logout`);
}
refreshToken(): Promise<{ message: string }> {
return this.postRequest(`${this.API_PATH_PREFIX}/${this.API_V1_VERSION}/auth/refresh`);
return this.postRequest(`${this.INTERNAL_API_PATH_PREFIX}/${this.API_V1_VERSION}/auth/refresh`);
}
getProfile(): Promise<User> {
return this.getRequest(`${this.API_PATH_PREFIX}/${this.API_V1_VERSION}/auth/profile`);
return this.getRequest(`${this.INTERNAL_API_PATH_PREFIX}/${this.API_V1_VERSION}/auth/profile`);
}
getRecordings(continuationToken?: string): Promise<{ recordings: RecordingInfo[]; continuationToken: string }> {