diff --git a/.env.auth b/.env.auth new file mode 100644 index 0000000..f86d774 --- /dev/null +++ b/.env.auth @@ -0,0 +1,22 @@ +# Type of Autorizarions +SIMPLE_LOGIN_ACTIVE=false +OAUTH_ACTIVE=false +OIDC_ACTIVE=false + +# Configuration Simple Login +SESSION_SECRET=your_session_secret + +# Configuration OAuth +OAUTH_AUTHORIZATION_URL=https://www.testurl.com/oauth2/authorize +OAUTH_TOKEN_URL=https://www.testurl.com/oauth2/token +OAUTH_CLIENT_ID=your_oauth_client_id +OAUTH_CLIENT_SECRET=your_oauth_client_secret +OAUTH_CALLBACK_URL=https://localhost:3000/auth/provider/callback +OAUTH_ADD_SCOPE=scopes +OAUTH_ROLE_TEACHER_VALUE=teacher-claim-value + +# Configuration OIDC +OIDC_CLIENT_ID=your_oidc_client_id +OIDC_CLIENT_SECRET=your_oidc_client_secret +OIDC_ISSUER_URL=https://your-issuer.com +OIDC_CALLBACK_URL=http://localhost:3000/auth/oidc/callback diff --git a/docker-compose.yaml b/docker-compose.yaml index 284a46e..93e29f2 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -14,6 +14,8 @@ services: container_name: backend ports: - "3000:3000" + env_file: + - .env.auth environment: PORT: 3000 MONGO_URI: "mongodb://mongo:27017/evaluetonsavoir" diff --git a/server/config/auth.js b/server/config/auth.js new file mode 100644 index 0000000..167512e --- /dev/null +++ b/server/config/auth.js @@ -0,0 +1,30 @@ +require('dotenv').config({ path: './.env.auth' }); + +module.exports = { + // Activer ou désactiver les types d'authentifications + simpleLoginActive: process.env.SIMPLE_LOGIN_ACTIVE === 'true', + oauthActive: process.env.OAUTH_ACTIVE === 'true', + oidcActive: process.env.OIDC_ACTIVE === 'true', + + // Configuration Simple Login + sessionSecret: process.env.SESSION_SECRET || 'default_session_secret', + + // Configuration OAuth + oauth: { + authorizationURL: process.env.OAUTH_AUTHORIZATION_URL || '', + tokenURL: process.env.OAUTH_TOKEN_URL || '', + clientID: process.env.OAUTH_CLIENT_ID || '', + clientSecret: process.env.OAUTH_CLIENT_SECRET || '', + callbackURL: process.env.OAUTH_CALLBACK_URL || '', + scope: process.env.OAUTH_ADD_SCOPE || '', + teacherRoleClaim: process.env.OAUTH_ROLE_TEACHER_VALUE || '', + }, + + // Configuration OIDC + oidc: { + clientID: process.env.OIDC_CLIENT_ID || '', + clientSecret: process.env.OIDC_CLIENT_SECRET || '', + issuerURL: process.env.OIDC_ISSUER_URL || '', + callbackURL: process.env.OIDC_CALLBACK_URL || '', + } +};