mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-20 18:25:21 -04:00
Linter: Fix all lint errors
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
b0a45bdf9c
commit
136d895d15
51 changed files with 2245 additions and 1539 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue