diff --git a/config.json b/config.json index 83bf03fab2a75a5bf2f5bbf2b205c2596a643caa..cecc4e9197b64d385444383bab73f375dab73744 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "ldap": { - "server": "ldap://frankiz.eleves.polytechnique.fr:636", + "server": "ldap://frankiz.eleves.polytechnique.fr:389", "searchBase": "ou=eleves,dc=frankiz,dc=net", "searchFilter": "(uid={{username}})" }, diff --git a/src/css/style.css b/src/css/style.css index 6d221f40c5dbfc53357d8384995e700f2ca55023..4d2b77afeb7530103ce6a5cb6b2996e77a502644 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -9,6 +9,7 @@ body { form { margin-bottom: 1em; + margin-top: 1em; } .form-group { diff --git a/src/ldap_auth/ldap_auth.js b/src/ldap_auth/ldap_auth.js index a9015f2447832ad68b3cc7f73b717a90936d0022..9fd2fea69f5bb90c42890a31262a5815c3760549 100644 --- a/src/ldap_auth/ldap_auth.js +++ b/src/ldap_auth/ldap_auth.js @@ -1,24 +1,25 @@ /** * @file ldap_auth - * @summary Setup de l'auth ldap avec passport-ldapauth + * @summary Configuration de l'authentification LDAP du backend via passport-ldap */ - import passport from 'passport'; import LdapStrategy from 'passport-ldapauth'; import session from 'express-session'; import fs from 'fs'; +let config = JSON.parse(fs.readFileSync('config.json', 'utf8')); + +passport.use(new LdapStrategy({ + server: { + url: config.ldap.server, + searchBase: config.ldap.searchBase, + searchFilter: config.ldap.searchFilter + } +})); + function setupLdapAuth(server) { - var config = JSON.parse(fs.readFileSync('config.json', 'utf8')); - passport.use(new LdapStrategy({ - server: { - url: config.ldap.server, - searchBase: config.ldap.searchBase, - searchFilter: config.ldap.searchFilter - } - })); - + // Define new login strategy server.use(session({ secret: config.sessionSecret, //store: a modifier avant de lancer en prod diff --git a/src/server.js b/src/server.js index 9317a63003340e39cd939893329aab27875f5b44..3ddcb19af1585654b6a16d43edcdb8d01e32a4b6 100644 --- a/src/server.js +++ b/src/server.js @@ -45,6 +45,7 @@ const typeDefs = ` type Group { name: String! id: ID! + website: String updatedAt: String! description: String school: String! @@ -62,8 +63,10 @@ const schema = makeExecutableSchema({ resolvers }); +// Charge le middleware express pour GraphQL server.use('/graphql', bodyParser.json(), graphqlExpress({schema})); +// GraphiQL est une console interactive pour faire des requêtes au schéma GraphQL server.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql'})); diff --git a/src/views/home.pug b/src/views/home.pug index e0b402e12dbbe063f98bb2ea06a5116453b8b2e3..1f7ed3bc18f37bbb854c17736228cabab8188267 100644 --- a/src/views/home.pug +++ b/src/views/home.pug @@ -2,8 +2,9 @@ extends layout.pug block content h1 Welcome to API server + h2 Query the database p Hello, world! This is server talking to you live on port #{port}! - p "Interface BDD" du back + p You can use the REST API to query the database using the form below. form(action="/db", method="get") div.form-group label(for="table") Table @@ -13,7 +14,11 @@ block content input.form-control(type="search", name="columns") button.form-control(type="submit") Search | - a(href="/graphql") Check GraphQL + h2 GraphiQL + p + | GraphiQL is an interactive environment to make GraphQL + | requests to the database. + a(href="/graphiql") Check it out. | form(action="/logout", method="post") - button.form-control(type="submit") Se deconnecter + button.form-control(type="submit") Logout diff --git a/src/views/login.pug b/src/views/login.pug index 18abbff1ba0bd8030f074582611646d221c91001..c1b6c7cf86f0b543d6d9fe5ef4eaec8c9a6dfe11 100644 --- a/src/views/login.pug +++ b/src/views/login.pug @@ -1,9 +1,9 @@ extends layout.pug block content - h1 Welcome to API server - p Hello, world! This is server talking to you live on port #{port}! - p Vous devez vous connecter pour acceder aux BDD ("interface admin"). + h1 Sigma backend API + p Veuillez vous connecter. + p Please log in. form(action="/loginAttempt", method="post") div.form-group label(for="username") Frankiz ID