Routes for Auth Backend

routes simple pour envoyer au frontend quel type de auth est disponible
This commit is contained in:
MathieuSevignyLavallee 2024-09-22 14:52:41 -04:00
parent e3de6853c7
commit 6dde0cca38
5 changed files with 36 additions and 4 deletions

View file

@ -1,5 +1,5 @@
# Type of Autorizarions
SIMPLE_LOGIN_ACTIVE=false
SIMPLE_LOGIN_ACTIVE=true
OAUTH_ACTIVE=false
OIDC_ACTIVE=false

View file

@ -12,6 +12,7 @@ const userRouter = require('./routers/users.js');
const folderRouter = require('./routers/folders.js');
const quizRouter = require('./routers/quiz.js');
const imagesRouter = require('./routers/images.js')
const authRouter = require('./routers/auth.js')
// Setup environement
dotenv.config();
@ -48,6 +49,7 @@ app.use('/api/user', userRouter);
app.use('/api/folder', folderRouter);
app.use('/api/quiz', quizRouter);
app.use('/api/image', imagesRouter);
app.use('/api/auth', authRouter);
app.use(errorHandler)

View file

@ -1,5 +1,3 @@
require('dotenv').config({ path: './.env.auth' });
module.exports = {
// Enable or disable the types of authentications
simpleLoginActive: process.env.SIMPLE_LOGIN_ACTIVE === 'true',
@ -18,7 +16,7 @@ module.exports = {
callbackURL: process.env.OAUTH_CALLBACK_URL || '',
scope: process.env.OAUTH_ADD_SCOPE || '',
teacherRoleClaim: process.env.OAUTH_ROLE_TEACHER_VALUE || '',
studentRoleClaim: process.env.OAUTH_ROLE_STUDENT_VALUE || '', // Added based on env file
studentRoleClaim: process.env.OAUTH_ROLE_STUDENT_VALUE || '',
},
// OIDC Configuration

View file

@ -0,0 +1,23 @@
const authConfig = require('../config/auth.js');
class authController {
async getActive(req, res, next) {
try {
console.log(authConfig);
const authServices = {
simpleLoginActive: authConfig.simpleLoginActive,
oauthActive: authConfig.oauthActive,
oidcActive: authConfig.oidcActive
};
res.json(authServices);
}
catch (error) {
return next(error);
}
}
}
module.exports = new authController;

9
server/routers/auth.js Normal file
View file

@ -0,0 +1,9 @@
const express = require('express');
const router = express.Router();
const jwt = require('../middleware/jwtToken.js');
const authController = require('../controllers/auth.js')
router.get("/getActiveAuth", authController.getActive);
module.exports = router;