Skip to content

Commit

Permalink
Minor update: Update to route protection
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAnhNguyenFOKUSFAME committed Feb 19, 2025
2 parents 583cd99 + 4965c0a commit df25b71
Show file tree
Hide file tree
Showing 12 changed files with 734 additions and 350 deletions.
9 changes: 6 additions & 3 deletions .env.default
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ PORT=3001
# URL WHERE THE REVERSE PROXY OF THE CLM-MICROSERVICES IS
DEPLOY_URL=http://localhost:3001

# ADMIN LTI TOOL
UES_BASIC_LAUNCH_RESSOURCE=/basic_launch/adminService

# MARIADB CONFIGURATION mapps to
MARIA_CONFIG=localhost|3306|clm|root|12345

# CLM_ROOT_USER
[email protected]

# CLM_ROOT_PASSWORD
CLM_ROOT_PASSWORD=ABC123

# SMTP HOST/CREDENTIALS/CONFIGS FOR RECEIVING EMAILS WHEN REGISTERING. Do not leave blank in production!
SMTP_HOST=
SMTP_PORT=
Expand Down
7 changes: 6 additions & 1 deletion dist/server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ROOT_DIR = void 0;
/* -----------------------------------------------------------------------------
* Copyright (c) 2023, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
*
Expand Down Expand Up @@ -75,7 +80,7 @@ app.set('view engine', 'ejs');
app.use(basePath, EntryPointController_1.default);
app.use(ErrorHandler_1.default);
(0, configureDeps_1.default)(app, EXCLUDED_PATHS).then(() => app.listen(PORT, () => {
console.info('Listening for core');
console.info(`Listening for core on port ${PORT}`);
})).catch((err) => {
console.error(JSON.stringify(err));
});
2 changes: 1 addition & 1 deletion dist/src/config/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ export declare const CONFIG: {
TOKEN_SECRET: string;
REDIS_CONFIG: string;
OIDC_PROVIDERS: any;
ODIC_CLIENTS: any;
API_TOKEN: string;
};
//# sourceMappingURL=config.d.ts.map
2 changes: 1 addition & 1 deletion dist/src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ exports.CONFIG = {
TOKEN_SECRET: process.env.TOKEN_SECRET || 'secret',
REDIS_CONFIG: process.env.REDIS_CONFIG || 'localhost|6379',
OIDC_PROVIDERS: JSON.parse(process.env.OIDC_PROVIDERS || `[]`),
ODIC_CLIENTS: JSON.parse(process.env.OIDC_CLIENTS || `[]`),
API_TOKEN: process.env.API_TOKEN || 'MGMT_SERVICE'
};
2 changes: 1 addition & 1 deletion dist/src/config/configureDeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function configureDependencies(app, excludedPaths) {
strength: 3,
immutable: true
}));
yield PathBDTO_1.pathBDTOInstance.registerRoutes(app, excludedPaths, 'MGMT_SERVICE', rootUser);
yield PathBDTO_1.pathBDTOInstance.registerRoutes(app, excludedPaths, config_1.CONFIG.API_TOKEN, rootUser);
let user = (yield UserDAO_1.default.findByAttributes({ email: rootUser }))[0];
if (!user)
UserDAO_1.default.insert(new UserModel_1.UserModel({
Expand Down
10 changes: 4 additions & 6 deletions dist/src/controllers/AuthController.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const axios_1 = __importDefault(require("axios"));
const express_1 = __importDefault(require("express"));
const passport_1 = __importDefault(require("../passport/passport"));
const jwtService_1 = require("../services/jwtService");
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
const UserDAO_1 = __importDefault(require("../models/User/UserDAO"));
const config_1 = require("../config/config");
const axios_1 = __importDefault(require("axios"));
const UserDAO_1 = __importDefault(require("../models/User/UserDAO"));
const passport_1 = __importDefault(require("../passport/passport"));
const jwtService_1 = require("../services/jwtService");
const OIDC_PROVIDERS = config_1.CONFIG.OIDC_PROVIDERS;
const basePath = config_1.CONFIG.BASE_PATH || '/core';
const baseLocation = `${basePath}/authentication`;
class AuthController {
constructor() {
this.authenticateUser = (req, res, next) => {
Expand Down
9 changes: 5 additions & 4 deletions dist/src/controllers/EntryPointController.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = __importDefault(require("express"));
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
const swagger_jsdoc_1 = __importDefault(require("swagger-jsdoc"));
const config_1 = require("../config/config");
const CoreLib_1 = require("../lib/CoreLib");
const UserDAO_1 = __importDefault(require("../models/User/UserDAO"));
const AuthController_1 = __importDefault(require("./AuthController"));
const MgmtRoleController_1 = __importDefault(require("./MgmtRoleController"));
const MgtmAPITokenController_1 = __importDefault(require("./MgtmAPITokenController"));
const MgtmGroupController_1 = __importDefault(require("./MgtmGroupController"));
const MgtmUserController_1 = __importDefault(require("./MgtmUserController"));
Expand Down Expand Up @@ -146,13 +151,9 @@ const EXCLUDED_PATHS = [
`${basePath}/roles/:id`,
`${basePath}/users/verifyToken/:tokenId`,
`${basePath}/mgmt/consumers/:id/confirm`,
`${basePath}/sso/oidc`,
`${basePath}/sso/success`,
`${basePath}/sso/oidc/backend/login`,
`${basePath}/sso/oidc/access_token_by_code`,
`/health`
];
EntryPointController.use('/sso/oidc', OIDCController_1.default.router);
EntryPointController.use(CoreLib_1.AuthGuard.requireAPIToken(EXCLUDED_PATHS));
EntryPointController.use('/resources', ResourceController_1.default.router);
// CONFIG.DISABLE_LEGACCY_FINDOO = true
Expand Down
23 changes: 0 additions & 23 deletions dist/src/controllers/OIDCController.d.ts

This file was deleted.

Loading

0 comments on commit df25b71

Please sign in to comment.