diff --git a/backend/src/app.ts b/backend/src/app.ts index deb22095..defed5b2 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -11,8 +11,8 @@ import submissionRouter from './routes/submission.js'; import classRouter from './routes/class.js'; import questionRouter from './routes/question.js'; import authRouter from './routes/auth.js'; -import {authenticateUser} from "./middleware/auth/auth"; -import cors from "./middleware/cors"; +import {authenticateUser} from "./middleware/auth/auth.js"; +import cors from "./middleware/cors.js"; const app: Express = express(); const port: string | number = getNumericEnvVar(EnvVars.Port); diff --git a/backend/src/controllers/auth.ts b/backend/src/controllers/auth.ts index 800c3b99..14c614a5 100644 --- a/backend/src/controllers/auth.ts +++ b/backend/src/controllers/auth.ts @@ -1,9 +1,4 @@ -import {EnvVars, getEnvVar} from "../util/envvars"; - -type FrontendAuthConfig = { - student: FrontendIdpConfig, - teacher: FrontendIdpConfig -} +import {EnvVars, getEnvVar} from "../util/envvars.js"; type FrontendIdpConfig = { authority: string, @@ -12,6 +7,11 @@ type FrontendIdpConfig = { responseType: string } +type FrontendAuthConfig = { + student: FrontendIdpConfig, + teacher: FrontendIdpConfig +} + const SCOPE = "openid profile email"; const RESPONSE_TYPE = "code"; diff --git a/backend/src/middleware/auth/auth.ts b/backend/src/middleware/auth/auth.ts index d06e6df2..ca564d8b 100644 --- a/backend/src/middleware/auth/auth.ts +++ b/backend/src/middleware/auth/auth.ts @@ -5,7 +5,7 @@ import jwksClient from 'jwks-rsa'; import * as express from "express"; import * as jwt from "jsonwebtoken"; import {AuthenticatedRequest} from "./authenticated-request.js"; -import {AuthenticationInfo} from "./authentication-info"; +import {AuthenticationInfo} from "./authentication-info.js"; function createJwksClient(uri: string): jwksClient.JwksClient { return jwksClient({ diff --git a/backend/src/middleware/auth/authenticated-request.ts b/backend/src/middleware/auth/authenticated-request.ts index b29cfbac..275b2d19 100644 --- a/backend/src/middleware/auth/authenticated-request.ts +++ b/backend/src/middleware/auth/authenticated-request.ts @@ -1,6 +1,6 @@ import { Request } from "express"; import { JwtPayload } from "jsonwebtoken"; -import {AuthenticationInfo} from "./authentication-info"; +import {AuthenticationInfo} from "./authentication-info.js"; export interface AuthenticatedRequest extends Request { // Properties are optional since the user is not necessarily authenticated. diff --git a/backend/src/middleware/cors.ts b/backend/src/middleware/cors.ts index 6f59f600..88104fb5 100644 --- a/backend/src/middleware/cors.ts +++ b/backend/src/middleware/cors.ts @@ -1,5 +1,5 @@ import cors from "cors"; -import {EnvVars, getEnvVar} from "../util/envvars"; +import {EnvVars, getEnvVar} from "../util/envvars.js"; export default cors({ origin: getEnvVar(EnvVars.CorsAllowedOrigins).split(','), diff --git a/backend/src/routes/auth.ts b/backend/src/routes/auth.ts index 14f9364b..57af3a7d 100644 --- a/backend/src/routes/auth.ts +++ b/backend/src/routes/auth.ts @@ -1,6 +1,6 @@ import express from 'express' -import {getFrontendAuthConfig} from "../controllers/auth"; -import {authenticatedOnly, studentsOnly, teachersOnly} from "../middleware/auth/auth"; +import {getFrontendAuthConfig} from "../controllers/auth.js"; +import {authenticatedOnly, studentsOnly, teachersOnly} from "../middleware/auth/auth.js"; const router = express.Router(); // returns auth configuration for frontend