diff --git a/.env.auth b/.env.auth index 18c9a63..65fb680 100644 --- a/.env.auth +++ b/.env.auth @@ -1,5 +1,5 @@ # Type of Autorizarions -SIMPLE_LOGIN_ACTIVE=false +SIMPLE_LOGIN_ACTIVE=true OAUTH_ACTIVE=false OIDC_ACTIVE=false diff --git a/server/app.js b/server/app.js index 76053ba..88e8da4 100644 --- a/server/app.js +++ b/server/app.js @@ -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) diff --git a/server/config/auth.js b/server/config/auth.js index c1effd2..b675ce1 100644 --- a/server/config/auth.js +++ b/server/config/auth.js @@ -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 diff --git a/server/controllers/auth.js b/server/controllers/auth.js new file mode 100644 index 0000000..f468216 --- /dev/null +++ b/server/controllers/auth.js @@ -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; \ No newline at end of file diff --git a/server/routers/auth.js b/server/routers/auth.js new file mode 100644 index 0000000..7fce26c --- /dev/null +++ b/server/routers/auth.js @@ -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; \ No newline at end of file