Skip to content
Snippets Groups Projects
Commit 7355a43f authored by Guillaume WANG's avatar Guillaume WANG
Browse files

fix admin_router, favicon and assets

parent fb1792a1
No related branches found
No related tags found
No related merge requests found
assets/favicon.ico

1.37 KiB

...@@ -58,6 +58,5 @@ ...@@ -58,6 +58,5 @@
"admin": "memberUid", "admin": "memberUid",
"class": "objectClass" "class": "objectClass"
} }
}, }
"sessionSecret":"ozyNMHdT,WFTu|t"
} }
\ No newline at end of file
...@@ -33,10 +33,6 @@ import flash from 'connect-flash'; ...@@ -33,10 +33,6 @@ import flash from 'connect-flash';
// packages pour l'API REST et pour GraphQL Voyager // packages pour l'API REST et pour GraphQL Voyager
import knex from '../../db/knex_router'; import knex from '../../db/knex_router';
import { express as graphqlVoyager } from 'graphql-voyager/middleware'; import { express as graphqlVoyager } from 'graphql-voyager/middleware';
// packages pour pouvoir importer des fichiers de config
import path from 'path';
import { static as expressStatic } from 'express'; // pour pouvoir servir les fichiers statiques
import favicon from 'serve-favicon'; // tres tres important :p
const whitelist = [ const whitelist = [
"magi.karp", "magi.karp",
...@@ -58,10 +54,6 @@ const router = Router(); ...@@ -58,10 +54,6 @@ const router = Router();
router.use(flash()); router.use(flash());
console.log("Express router is running at", __dirname);
router.use(favicon(path.resolve(__dirname, 'favicon.ico')));
router.use('/assets', expressStatic(path.resolve(__dirname, '..', '..', 'assets')));
let port = process.env.PORT || 3000; let port = process.env.PORT || 3000;
/** /**
......
...@@ -60,6 +60,12 @@ const corsOptions = { ...@@ -60,6 +60,12 @@ const corsOptions = {
}; };
app.use(cors(corsOptions)); app.use(cors(corsOptions));
// respond to "GET /favicon.ico" requests
// favicon middleware is placed near the top of the middleware stack, to answer favicon requests faster, as they are relatively frequent
// (plus, they should not have to trigger any authentication middleware)
import favicon from 'serve-favicon'; // tres tres important :p
app.use(favicon(path.resolve(__dirname, 'adminview', 'favicon.ico')));
/** /**
* @desc Authentification de la requête contre le session-store (cookie) * @desc Authentification de la requête contre le session-store (cookie)
* ===================================================================== * =====================================================================
...@@ -228,13 +234,21 @@ server.applyMiddleware({ app }); ...@@ -228,13 +234,21 @@ server.applyMiddleware({ app });
* - à une API REST fait-maison (peut-être encore à débugger) * - à une API REST fait-maison (peut-être encore à débugger)
* - à GraphQL Voyager, un package qui permet d'afficher une représentation sous forme de graphe du schéma GraphQL. * - à GraphQL Voyager, un package qui permet d'afficher une représentation sous forme de graphe du schéma GraphQL.
*/ */
// servir les fichiers statiques (e.g. images) rendant l'interface jolie
app.use('/assets', express.static(path.resolve(__dirname, '../', 'assets')));
// setup the 'pug' view engine. the adminview "sub-app" will inherit this. https://expressjs.com/en/4x/api.html#app.set // setup the 'pug' view engine. the adminview "sub-app" will inherit this. https://expressjs.com/en/4x/api.html#app.set
//console.log("Express app is running at", __dirname); //console.log("Express app is running at (__dirname) ", __dirname);
//console.log("Express app is running at (full path) ", path.resolve(__dirname));let viewpath = path.resolve(__dirname, 'adminview', 'views');
let viewpath = path.resolve(__dirname, 'adminview', 'views'); let viewpath = path.resolve(__dirname, 'adminview', 'views');
app.set('views', viewpath); app.set('views', viewpath);
app.set('view engine', 'pug'); app.set('view engine', 'pug');
app.use('/adminview', router); // catches and resolves HTTP requests to paths '/adminview/*' app.use('/adminview', router); // catches and resolves HTTP requests to paths '/adminview/*'
// also redirect other HTTP GET requests to the adminview router
app.get('/', function (req, res) {
res.redirect('/adminview');
});
/** /**
* @desc Catch-all * @desc Catch-all
......
...@@ -37,11 +37,11 @@ import { ldapConfig } from './ldap/config'; ...@@ -37,11 +37,11 @@ import { ldapConfig } from './ldap/config';
// specifies options for 'ldapauth' strategy, to customize the behaviour of subsequent passport.authenticate('ldapauth') calls // specifies options for 'ldapauth' strategy, to customize the behaviour of subsequent passport.authenticate('ldapauth') calls
passport.use(new LdapStrategy({ passport.use(new LdapStrategy({
server: { server: {
url: ldapConfig.ldap.server, url: ldapConfig.server,
//bindDn: '.............', //bindDn: '.............',
//bindCredentials: '..........', //bindCredentials: '..........',
searchBase: ldapConfig.ldap.searchBase, // searchBase: ldapConfig.searchBase, TODO: this cannot be left empty.
searchFilter: ldapConfig.ldap.searchFilter, // searchFilter: ldapConfig.searchFilter, TODO: this cannot be left empty.
//searchAttributes: ['givenName', 'sn'], //searchAttributes: ['givenName', 'sn'],
//tlsOptions: '..........', //tlsOptions: '..........',
}, },
......
...@@ -7,8 +7,8 @@ import fs from 'fs'; ...@@ -7,8 +7,8 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
import colors from 'colors'; import colors from 'colors';
// Point central ; tous les champs de la BDD sont 'cachés' dans config.json et pas visibles directement // Point central ; tous les champs de la BDD sont 'cachés' dans config.json et pas visibles directement
let path_config = path.resolve('..','ldap_config.json') let path_config = path.resolve('ldap_config.json')
let path_credentials = path.resolve('..','ldap_credentials.json') let path_credentials = path.resolve('ldap_credentials.json')
console.log(colors.cyan("Loading LDAP config file from "+path_config)); console.log(colors.cyan("Loading LDAP config file from "+path_config));
console.log(colors.cyan("Loading LDAP credentials from "+path_credentials)); console.log(colors.cyan("Loading LDAP credentials from "+path_credentials));
export const ldapConfig = JSON.parse(fs.readFileSync(path_config).toString()); export const ldapConfig = JSON.parse(fs.readFileSync(path_config).toString());
......
...@@ -18,11 +18,12 @@ const config = { ...@@ -18,11 +18,12 @@ const config = {
}, },
target: 'node', target: 'node',
//node: { __dirname: false }, <-- TODO: check that this can be removed // allows using __dirname with the correct semantic (otherwise __dirname will return '/' regardless of file)
node: { __dirname: true },
// Choose a style of source mapping to enhance the debugging process // Choose a style of source mapping to enhance the debugging process
// https://webpack.js.org/configuration/devtool/ // https://webpack.js.org/configuration/devtool/
devtool: 'inline-source-map', //TODO: in production, remove this //devtool: 'inline-source-map', //TODO: in production, or if deemed too slow, remove this
// do not bundle node_modules, nor secret config files // do not bundle node_modules, nor secret config files
externals: [ externals: [
...@@ -77,11 +78,12 @@ const config = { ...@@ -77,11 +78,12 @@ const config = {
}] }]
}, { }, {
test: /\.(png|jpg|ico)$/, test: /\.(png|jpg|ico)$/,
use: [{ use: {
loader: 'url-loader?limit=8192', loader: 'url-loader?limit=8192'
// loads files as base64 encoded URL if filesize is < limit // loads files as base64 encoded URL if filesize is < limit
// default fallback: file-loader // default fallback: file-loader
}] }
//use: ['file-loader']
}] }]
}, },
......
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