From 136d895d155f28c2e75b3af206549acaa2a354ed Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Mon, 15 Feb 2021 09:42:51 +0100 Subject: Linter: Fix all lint errors Signed-off-by: Philip Molares --- lib/web/auth/saml/index.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'lib/web/auth/saml') diff --git a/lib/web/auth/saml/index.js b/lib/web/auth/saml/index.js index c48b93e2..deb04007 100644 --- a/lib/web/auth/saml/index.js +++ b/lib/web/auth/saml/index.js @@ -10,19 +10,21 @@ const { urlencodedParser } = require('../../utils') const fs = require('fs') const intersection = function (array1, array2) { return array1.filter((n) => array2.includes(n)) } -let samlAuth = module.exports = Router() +const samlAuth = module.exports = Router() passport.use(new SamlStrategy({ callbackUrl: config.serverURL + '/auth/saml/callback', entryPoint: config.saml.idpSsoUrl, issuer: config.saml.issuer || config.serverURL, - privateCert: config.saml.clientCert === undefined ? undefined : (function () { - try { - return fs.readFileSync(config.saml.clientCert, 'utf-8') - } catch (e) { - logger.error(`SAML client certificate: ${e.message}`) - } - }()), + privateCert: config.saml.clientCert === undefined + ? undefined + : (function () { + try { + return fs.readFileSync(config.saml.clientCert, 'utf-8') + } catch (e) { + logger.error(`SAML client certificate: ${e.message}`) + } + }()), cert: (function () { try { return fs.readFileSync(config.saml.idpCert, 'utf-8') @@ -36,7 +38,7 @@ passport.use(new SamlStrategy({ }, function (user, done) { // check authorization if needed if (config.saml.externalGroups && config.saml.groupAttribute) { - var externalGroups = intersection(config.saml.externalGroups, user[config.saml.groupAttribute]) + const externalGroups = intersection(config.saml.externalGroups, user[config.saml.groupAttribute]) if (externalGroups.length > 0) { logger.error('saml permission denied: ' + externalGroups.join(', ')) return done('Permission denied', null) @@ -49,8 +51,8 @@ passport.use(new SamlStrategy({ } } // user creation - var uuid = user[config.saml.attribute.id] || user.nameID - var profile = { + const uuid = user[config.saml.attribute.id] || user.nameID + const profile = { provider: 'saml', id: 'SAML-' + uuid, username: user[config.saml.attribute.username] || user.nameID, @@ -59,7 +61,7 @@ passport.use(new SamlStrategy({ if (profile.emails.length === 0 && config.saml.identifierFormat === 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress') { profile.emails.push(user.nameID) } - var stringifiedProfile = JSON.stringify(profile) + const stringifiedProfile = JSON.stringify(profile) models.User.findOrCreate({ where: { profileid: profile.id.toString() @@ -69,7 +71,7 @@ passport.use(new SamlStrategy({ } }).spread(function (user, created) { if (user) { - var needSave = false + let needSave = false if (user.profile !== stringifiedProfile) { user.profile = stringifiedProfile needSave = true -- cgit v1.2.3