diff --git a/src/lib/setup_endpoints.js b/src/lib/setup_endpoints.js index 8eb50763..fe81d87c 100644 --- a/src/lib/setup_endpoints.js +++ b/src/lib/setup_endpoints.js @@ -5,8 +5,6 @@ var routes = require('./routes'); var identity_check = require('./identity_check'); function setup_endpoints(app) { - var base_endpoint = '/authentication'; - /** * @apiDefine UserSession * @apiHeader {String} Cookie Cookie containing 'connect.sid', the user @@ -52,7 +50,7 @@ function setup_endpoints(app) { * @apiDescription Create a user session and serve the login page along with * a cookie. */ - app.get (base_endpoint + '/login', routes.login); + app.get ('/login', routes.login); /** * @api {get} /authentication/logout Server logout page @@ -65,7 +63,7 @@ function setup_endpoints(app) { * * @apiDescription Deauthenticate the user and redirect him. */ - app.get (base_endpoint + '/logout', routes.logout); + app.get ('/logout', routes.logout); /** * @api {post} /authentication/totp-register Request TOTP registration @@ -87,7 +85,7 @@ function setup_endpoints(app) { * @apiDescription Serves the TOTP registration page that displays the secret. * The secret is a QRCode and a base32 secret. */ - identity_check(app, base_endpoint + '/totp-register', routes.totp_register.icheck_interface); + identity_check(app, '/totp-register', routes.totp_register.icheck_interface); /** @@ -109,7 +107,7 @@ function setup_endpoints(app) { * @apiDescription Serves the U2F registration page that asks the user to * touch the token of the U2F device. */ - identity_check(app, base_endpoint + '/u2f-register', routes.u2f_register.icheck_interface); + identity_check(app, '/u2f-register', routes.u2f_register.icheck_interface); /** * @api {post} /authentication/reset-password Request for password reset @@ -130,9 +128,9 @@ function setup_endpoints(app) { * @apiDescription Serves password reset form that allow the user to provide * the new password. */ - identity_check(app, base_endpoint + '/reset-password', routes.reset_password.icheck_interface); + identity_check(app, '/reset-password', routes.reset_password.icheck_interface); - app.get (base_endpoint + '/reset-password-form', function(req, res) { res.render('reset-password-form'); }); + app.get ('/reset-password-form', function(req, res) { res.render('reset-password-form'); }); /** * @api {post} /authentication/new-password Set LDAP password @@ -145,7 +143,7 @@ function setup_endpoints(app) { * * @apiDescription Set a new password for the user. */ - app.post (base_endpoint + '/new-password', routes.reset_password.post); + app.post ('/new-password', routes.reset_password.post); /** * @api {post} /authentication/new-totp-secret Generate TOTP secret @@ -164,7 +162,7 @@ function setup_endpoints(app) { * * @apiDescription Generate a new TOTP secret and returns it. */ - app.post (base_endpoint + '/new-totp-secret', routes.totp_register.post); + app.post ('/new-totp-secret', routes.totp_register.post); /** * @api {get} /authentication/verify Verify user authentication @@ -179,7 +177,7 @@ function setup_endpoints(app) { * @apiDescription Verify that the user is authenticated, i.e., the two * factors have been validated */ - app.get (base_endpoint + '/verify', routes.verify); + app.get ('/verify', routes.verify); /** * @api {post} /authentication/1stfactor LDAP authentication @@ -199,7 +197,7 @@ function setup_endpoints(app) { * * @apiDescription Verify credentials against the LDAP. */ - app.post (base_endpoint + '/1stfactor', routes.first_factor); + app.post ('/1stfactor', routes.first_factor); /** * @api {post} /authentication/2ndfactor/totp TOTP authentication @@ -216,7 +214,7 @@ function setup_endpoints(app) { * * @apiDescription Verify TOTP token. The user is authenticated upon success. */ - app.post (base_endpoint + '/2ndfactor/totp', routes.second_factor.totp); + app.post ('/2ndfactor/totp', routes.second_factor.totp); /** * @api {get} /authentication/2ndfactor/u2f/sign_request U2F Start authentication @@ -231,7 +229,7 @@ function setup_endpoints(app) { * * @apiDescription Initiate an authentication request using a U2F device. */ - app.get (base_endpoint + '/2ndfactor/u2f/sign_request', routes.second_factor.u2f.sign_request); + app.get ('/2ndfactor/u2f/sign_request', routes.second_factor.u2f.sign_request); /** * @api {post} /authentication/2ndfactor/u2f/sign U2F Complete authentication @@ -246,7 +244,7 @@ function setup_endpoints(app) { * * @apiDescription Complete authentication request of the U2F device. */ - app.post (base_endpoint + '/2ndfactor/u2f/sign', routes.second_factor.u2f.sign); + app.post ('/2ndfactor/u2f/sign', routes.second_factor.u2f.sign); /** * @api {get} /authentication/2ndfactor/u2f/register_request U2F Start device registration @@ -261,7 +259,7 @@ function setup_endpoints(app) { * * @apiDescription Initiate a U2F device registration request. */ - app.get (base_endpoint + '/2ndfactor/u2f/register_request', routes.second_factor.u2f.register_request); + app.get ('/2ndfactor/u2f/register_request', routes.second_factor.u2f.register_request); /** * @api {post} /authentication/2ndfactor/u2f/register U2F Complete device registration @@ -277,6 +275,6 @@ function setup_endpoints(app) { * * @apiDescription Complete U2F registration request. */ - app.post (base_endpoint + '/2ndfactor/u2f/register', routes.second_factor.u2f.register); + app.post ('/2ndfactor/u2f/register', routes.second_factor.u2f.register); }