Skip to content
Snippets Groups Projects
Commit 6c2164f8 authored by Wilson JALLET's avatar Wilson JALLET :money_with_wings:
Browse files

fix flash in server.ts, convert admin.router

parent 1862f72c
No related branches found
No related tags found
No related merge requests found
......@@ -41,6 +41,7 @@ L'API de Sigma nécessite de se connecter au LDAP Frankiz, à la fois pour obten
* La configuration LDAP de base se situe dans [ldap_config.json](ldap_config.json).
* Elle est importée dans l'application depuis [src/ldap/config.js](src/ldap/config.js). Ce fichier écrase la config de base selon les options suivantes :
| **Variable** | **Description** | **Défaut** (`ldap_config.json`) |
| ------ | ------ | ----- |
| LDAP_URI | URI vers le serveur LDAP. | <ldap://frankiz.eleves.polytechnique.fr:389> |
......
......@@ -201,6 +201,23 @@
"@types/node": "*"
}
},
"@types/connect-ensure-login": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/@types/connect-ensure-login/-/connect-ensure-login-0.1.4.tgz",
"integrity": "sha512-MLXOS6+5MnhkB7F34xE66wX9MEEfrUJRfNM9Uv0vEre8kH13tILO9j2b7fI4xwyLXSEn9k3uIE8U46MQ1CWByw==",
"dev": true,
"requires": {
"@types/express": "*"
}
},
"@types/connect-flash": {
"version": "0.0.34",
"resolved": "https://registry.npmjs.org/@types/connect-flash/-/connect-flash-0.0.34.tgz",
"integrity": "sha512-QC93TwnTZ0sk//bfT81o7U4GOedbOZAcgvqi0v1vJqCESC8tqIVnhzB1CHiAUBUWFjoxG5JQF0TYaNa6DMb6Ig==",
"requires": {
"@types/express": "*"
}
},
"@types/events": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@types/events/-/events-1.2.0.tgz",
......@@ -250,9 +267,10 @@
"integrity": "sha512-DOzWZKUnmFYG0KUOs+9HEBju2QhBU6oM2zeluunQNt0vnJvnkHvtDNlQPZDkTrkC5pZrNx1TPqeL137zciXZMQ=="
},
"@types/passport": {
"version": "0.3.5",
"resolved": "https://registry.npmjs.org/@types/passport/-/passport-0.3.5.tgz",
"integrity": "sha512-J7mdY1nnhjdbkXT84S3WsyrTtDf2KqUJ9JW3Y9vxA5GuXlejIuvwHw9A2TdNklAqPG2Q0TWqlsA2a2GIeV1jYA==",
"version": "0.4.6",
"resolved": "https://registry.npmjs.org/@types/passport/-/passport-0.4.6.tgz",
"integrity": "sha512-P7TxrdpAze3nvHghYPeLlHkYcFDiIkRBbp7xYz2ehX9zmi1yr/qWQMTpXsMxN5w3ESJpMzn917inK4giASaDcQ==",
"dev": true,
"requires": {
"@types/express": "*"
}
......@@ -7722,6 +7740,14 @@
"version": "7.0.56",
"resolved": "http://registry.npmjs.org/@types/node/-/node-7.0.56.tgz",
"integrity": "sha512-NgjN3xPyqbAXSIpznNAR5Cisx5uKqJWxcS9kefzSFEX/9J7O01/FHyfnvPI7SztBf9p6c8mqOn3olZWJx3ja6g=="
},
"@types/passport": {
"version": "0.3.5",
"resolved": "https://registry.npmjs.org/@types/passport/-/passport-0.3.5.tgz",
"integrity": "sha512-J7mdY1nnhjdbkXT84S3WsyrTtDf2KqUJ9JW3Y9vxA5GuXlejIuvwHw9A2TdNklAqPG2Q0TWqlsA2a2GIeV1jYA==",
"requires": {
"@types/express": "*"
}
}
}
},
......
......@@ -48,7 +48,10 @@
"url-loader": "^0.6.2"
},
"devDependencies": {
"@types/connect-ensure-login": "^0.1.4",
"@types/connect-flash": "0.0.34",
"@types/node": "^10.9.3",
"@types/passport": "^0.4.6",
"babel-eslint": "^8.2.6",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
......
......@@ -10,10 +10,13 @@
import { Router } from 'express';
import knex from '../../db/knex_router';
import passport from 'passport';
import flash from 'connect-flash';
import { ensureLoggedIn } from 'connect-ensure-login';
const router = Router();
router.use(flash());
let port = process.env.PORT || 3000;
......
......@@ -17,8 +17,6 @@
*/
import passport from 'passport';
import LdapStrategy from 'passport-ldapauth';
import fs from 'fs';
import path from 'path';
import { ldapConfig } from './ldap/config';
// specifies options for 'ldapauth' strategy, to customize the behaviour of subsequent passport.authenticate('ldapauth') calls
......
......@@ -45,11 +45,6 @@ app.use(bodyParser.urlencoded({ //parses bodies of media type "application/x-www
}));
app.use(cookieParser()); //parses Cookie header and populate req.cookies with an object keyed by the cookie names. was necessary for express-session before its v1.5.0. on peut probablement l'enlever desormais.
// Config de passport pour l'authentification ldap.
// Ne fait que *configurer* passport pour la strategie 'ldap' (pas d'incidence sur la strategie 'session' normalement)
import './config_passport';
/**
* @desc TRUCS DIVERS
......@@ -69,20 +64,22 @@ app.use('/assets', express.static(path.resolve('./', 'assets')));
*/
/**
* @desc AUTHENTIFICATION POUR LES REQUETES POSSEDANT UN COOKIE ET PROVENANT D'UN UTILISATEUR DEJA AUTHENTIFIE
* Remarque: introduit aussi les middlewares session et passport, qui sont aussi utiles pour l'authentification dans les autres cas.
*/
// WTF??? why is sessionSecret in ldap_config.json? it has nothing to do with ldap. TODO
/**
* WTF??? why is sessionSecret in ldap_config.json? it has nothing to do with ldap.
* @todo FIX
*/
// defines parameters for *session store*. (adds field req.session and do some magic stuff)
// basically, searches for a session matching the received cookie and, if found, adds field req.blasomethingbla containing serialized object representing user (i.e. similar to what passport.serializeUser() could produce)
// TODO: it is important to configure this right!!! please check out https://www.npmjs.com/package/express-session and make sure you understand the way session is stored. (en vrai c'est vraiment important...)
app.use(session({
/**
/* defines parameters for *session store*. (adds field req.session and do some magic stuff)
* basically, searches for a session matching the received cookie and, if found, adds field req.blasomethingbla containing serialized object representing user (i.e. similar to what passport.serializeUser() could produce)
* @todo it is important to configure this right!!! please check out https://www.npmjs.com/package/express-session and make sure you understand the way session is stored. (en vrai c'est vraiment important...)
*/
app.use(session({
secret: ldapConfig.sessionSecret,
resave: true,
saveUninitialized: false,
......@@ -106,13 +103,6 @@ app.use((req, res, next) => {
});
*/
/**
* FIN AUTHENTIFICATION POUR LES REQUETES POSSEDANT UN COOKIE ET PROVENANT D'UN UTILISATEUR DEJA AUTHENTIFIE
*/
/**
* @desc AUTHENTIFICATION POUR LES REQUETES DE CONNEXION VIA LDAP VENANT DU FRONT
......@@ -121,13 +111,12 @@ app.use((req, res, next) => {
* Remarque: configure aussi passport pour l'authentification ldap, ce qui est aussi utile pour les requetes de connexion via ldap venant de adminview
*/
const FRONTEND_SERVER_URL = 'change this to frontend server IP address';
const FRONTEND_SERVER_URL_LOCAL = 'http://localhost:8888';
const FRONTEND_SERVER_URL = process.env.FRONTEND_SERVER_URL || 'http://localhost:8888';
// Options de configuration pour le _middleware_ `cors`.
// CORS = Cross Origin Resource Sharing
const corsOptions = {
origin: FRONTEND_SERVER_URL_LOCAL, // Configures the Access-Control-Allow-Origin CORS header. i.e. specifies that sigma-back wants to make resources accessible to this site (and this site only)
origin: FRONTEND_SERVER_URL, // Configures the Access-Control-Allow-Origin CORS header. i.e. specifies that sigma-back wants to make resources accessible to this site (and this site only)
credentials: true // Configures the Access-Control-Allow-Credentials CORS header. i.e. allows cookies to be included on cross-origin requests
};
app.use(cors(corsOptions));
......
......@@ -8,5 +8,8 @@
"outDir": "build",
"resolveJsonModule": true,
},
"include": ["src/**/*"]
"include": [
"src/**/*",
"db/**/*"
]
}
\ No newline at end of file
......@@ -9,10 +9,10 @@ const config = {
node: {
__dirname: false
},
//devtool: 'inline-source-map',
externals: [nodeExternals()],
externals: [
nodeExternals()
],
module: {
rules: [{
......@@ -21,13 +21,11 @@ const config = {
},{
test: /\.ts$/,
use: ['ts-loader'],
exclude: /node_modules/
},{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},{
test: /\.(png|jpg|ico)$/,
exclude: /node_modules/,
loader: 'file-loader',
options: {
limit: 10000
......@@ -35,7 +33,7 @@ const config = {
}]
},
resolve: {
extensions: ['.ts', '.js', '.json']
extensions: ['.ts', '.js']
},
plugins: [
new CopyWebpackPlugin([{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment