diff --git a/package-lock.json b/package-lock.json index fdd2f26e9..3a2b0e572 100644 --- a/package-lock.json +++ b/package-lock.json @@ -489,11 +489,6 @@ "precond": "0.2" } }, - "bagpipe": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/bagpipe/-/bagpipe-0.3.5.tgz", - "integrity": "sha1-40HRZPyyTN8E6n4Ft2XsEMiupqE=" - }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -877,11 +872,6 @@ } } }, - "connect-ensure-login": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/connect-ensure-login/-/connect-ensure-login-0.1.1.tgz", - "integrity": "sha1-F03MUSQ7nqwj+NmCFa62aU4uihI=" - }, "connect-lastmile": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/connect-lastmile/-/connect-lastmile-1.2.2.tgz", @@ -949,20 +939,6 @@ "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" }, - "cookie": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", - "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" - }, - "cookie-parser": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.4.tgz", - "integrity": "sha512-lo13tqF3JEtFO7FyA49CqbhaFkskRJ0u/UAiINgrIXeRCY41c88/zxtrECl8AKH3B0hj9q10+h3Kt8I7KlW4tw==", - "requires": { - "cookie": "0.3.1", - "cookie-signature": "1.0.6" - } - }, "cookie-session": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/cookie-session/-/cookie-session-1.4.0.tgz", @@ -1565,51 +1541,6 @@ } } }, - "express-session": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/express-session/-/express-session-1.17.0.tgz", - "integrity": "sha512-t4oX2z7uoSqATbMfsxWMbNjAL0T5zpvcJCk3Z9wnPPN7ibddhnmDZXHfEcoBMG2ojKXZoCyPMc5FbtK+G7SoDg==", - "requires": { - "cookie": "0.4.0", - "cookie-signature": "1.0.6", - "debug": "2.6.9", - "depd": "~2.0.0", - "on-headers": "~1.0.2", - "parseurl": "~1.3.3", - "safe-buffer": "5.2.0", - "uid-safe": "~2.1.5" - }, - "dependencies": { - "cookie": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", - "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "requires": { - "ms": "2.0.0" - } - }, - "depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "safe-buffer": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", - "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" - } - } - }, "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -1743,16 +1674,6 @@ "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" }, - "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -2544,14 +2465,6 @@ "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" }, - "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "requires": { - "graceful-fs": "^4.1.6" - } - }, "jsonparse": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", @@ -2602,11 +2515,6 @@ "tsscmp": "1.0.6" } }, - "kruptein": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/kruptein/-/kruptein-2.0.5.tgz", - "integrity": "sha512-1WRXAil8d5jZ6jNXC0/pOC2lJsu2GhL3zhzL7DDvtCsef+NC1JvZUXnyNnM6Kuv0aan54moM/hsPvUAkx3y7/w==" - }, "lcid": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", @@ -3411,35 +3319,11 @@ "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" }, - "oauth2orize": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/oauth2orize/-/oauth2orize-1.11.0.tgz", - "integrity": "sha1-eTzvJR1F696sMq5AqLaBT6qx1IM=", - "requires": { - "debug": "2.x.x", - "uid2": "0.0.x", - "utils-merge": "1.x.x" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - } - } - }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true }, "object-inspect": { "version": "1.7.0", @@ -3612,14 +3496,6 @@ "pause": "0.0.1" } }, - "passport-http": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/passport-http/-/passport-http-0.3.0.tgz", - "integrity": "sha1-juU9Q4C+nGDfIVGSUCmCb3cRVgM=", - "requires": { - "passport-strategy": "1.x.x" - } - }, "passport-http-bearer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/passport-http-bearer/-/passport-http-bearer-1.0.1.tgz", @@ -3636,14 +3512,6 @@ "passport-strategy": "1.x.x" } }, - "passport-oauth2-client-password": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/passport-oauth2-client-password/-/passport-oauth2-client-password-0.1.2.tgz", - "integrity": "sha1-TzeLZ4uS0W270jOmxwZSAJPlYbo=", - "requires": { - "passport-strategy": "1.x.x" - } - }, "passport-strategy": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz", @@ -4103,11 +3971,6 @@ "path-parse": "^1.0.6" } }, - "retry": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", - "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=" - }, "retry-request": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/retry-request/-/retry-request-4.1.1.tgz", @@ -4364,31 +4227,6 @@ "send": "0.17.1" } }, - "session-file-store": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/session-file-store/-/session-file-store-1.4.0.tgz", - "integrity": "sha512-jBeQwoHoHMOBoELxf+f/IDtMI94PqkFrwCP6O3DlvJlsCU6gY6pgWJGxUOtLWxauIdvAqmgoAbpJi7vJih9bvA==", - "requires": { - "bagpipe": "^0.3.5", - "fs-extra": "^8.0.1", - "kruptein": "^2.0.4", - "object-assign": "^4.1.1", - "retry": "^0.12.0", - "write-file-atomic": "1.3.1" - }, - "dependencies": { - "write-file-atomic": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.1.tgz", - "integrity": "sha1-fUW6MjFjKN0ex9kPYOvA2EW7dZo=", - "requires": { - "graceful-fs": "^4.1.11", - "imurmurhash": "^0.1.4", - "slide": "^1.1.5" - } - } - } - }, "set-blocking": { "version": "2.0.0", "resolved": false, @@ -4454,11 +4292,6 @@ "resolved": false, "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" }, - "slide": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/slide/-/slide-1.1.6.tgz", - "integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=" - }, "smtp-connection": { "version": "2.12.0", "resolved": "https://registry.npmjs.org/smtp-connection/-/smtp-connection-2.12.0.tgz", @@ -5025,11 +4858,6 @@ "random-bytes": "~1.0.0" } }, - "uid2": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/uid2/-/uid2-0.0.3.tgz", - "integrity": "sha1-SDEm4Rd03y9xuLY53NeZw3YWK4I=" - }, "underscore": { "version": "1.9.2", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.2.tgz", @@ -5043,11 +4871,6 @@ "crypto-random-string": "^1.0.0" } }, - "universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" - }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", diff --git a/package.json b/package.json index 11803ebdb..bd7c035d0 100644 --- a/package.json +++ b/package.json @@ -22,10 +22,8 @@ "body-parser": "^1.19.0", "cloudron-manifestformat": "^4.0.0", "connect": "^3.7.0", - "connect-ensure-login": "^0.1.1", "connect-lastmile": "^1.2.2", "connect-timeout": "^1.9.0", - "cookie-parser": "^1.4.4", "cookie-session": "^1.4.0", "cron": "^1.8.2", "db-migrate": "^0.11.6", @@ -35,7 +33,6 @@ "ejs": "^2.6.1", "ejs-cli": "^2.1.1", "express": "^4.17.1", - "express-session": "^1.17.0", "js-yaml": "^3.13.1", "json": "^9.0.6", "ldapjs": "^1.0.2", @@ -48,14 +45,11 @@ "mysql": "^2.18.1", "nodemailer": "^6.4.2", "nodemailer-smtp-transport": "^2.7.4", - "oauth2orize": "^1.11.0", "once": "^1.4.0", "parse-links": "^0.1.0", "passport": "^0.4.1", - "passport-http": "^0.3.0", "passport-http-bearer": "^1.0.1", "passport-local": "^1.0.0", - "passport-oauth2-client-password": "^0.1.2", "pretty-bytes": "^5.3.0", "progress-stream": "^2.0.0", "proxy-middleware": "^0.15.0", @@ -66,7 +60,6 @@ "s3-block-read-stream": "^0.5.0", "safetydance": "^1.0.0", "semver": "^6.1.1", - "session-file-store": "^1.4.0", "showdown": "^1.9.1", "speakeasy": "^2.0.0", "split": "^1.0.1", diff --git a/src/authcodedb.js b/src/authcodedb.js deleted file mode 100644 index f431b76b4..000000000 --- a/src/authcodedb.js +++ /dev/null @@ -1,78 +0,0 @@ -/* jslint node:true */ - -'use strict'; - -exports = module.exports = { - get: get, - add: add, - del: del, - delExpired: delExpired, - - _clear: clear -}; - -var assert = require('assert'), - BoxError = require('./boxerror.js'), - database = require('./database.js'); - -var AUTHCODES_FIELDS = [ 'authCode', 'userId', 'clientId', 'expiresAt' ].join(','); - -function get(authCode, callback) { - assert.strictEqual(typeof authCode, 'string'); - assert.strictEqual(typeof callback, 'function'); - - database.query('SELECT ' + AUTHCODES_FIELDS + ' FROM authcodes WHERE authCode = ? AND expiresAt > ?', [ authCode, Date.now() ], function (error, result) { - if (error) return callback(new BoxError(BoxError.DATABASE_ERROR, error)); - if (result.length === 0) return callback(new BoxError(BoxError.NOT_FOUND, 'Authcode not found')); - - callback(null, result[0]); - }); -} - -function add(authCode, clientId, userId, expiresAt, callback) { - assert.strictEqual(typeof authCode, 'string'); - assert.strictEqual(typeof clientId, 'string'); - assert.strictEqual(typeof userId, 'string'); - assert.strictEqual(typeof expiresAt, 'number'); - assert.strictEqual(typeof callback, 'function'); - - database.query('INSERT INTO authcodes (authCode, clientId, userId, expiresAt) VALUES (?, ?, ?, ?)', - [ authCode, clientId, userId, expiresAt ], function (error, result) { - if (error && error.code === 'ER_DUP_ENTRY') return callback(new BoxError(BoxError.ALREADY_EXISTS)); - if (error || result.affectedRows !== 1) return callback(new BoxError(BoxError.DATABASE_ERROR, error)); - - callback(null); - }); -} - -function del(authCode, callback) { - assert.strictEqual(typeof authCode, 'string'); - assert.strictEqual(typeof callback, 'function'); - - database.query('DELETE FROM authcodes WHERE authCode = ?', [ authCode ], function (error, result) { - if (error) return callback(new BoxError(BoxError.DATABASE_ERROR, error)); - if (result.affectedRows !== 1) return callback(new BoxError(BoxError.NOT_FOUND, 'Authcode not found')); - - callback(null); - }); -} - -function delExpired(callback) { - assert.strictEqual(typeof callback, 'function'); - - database.query('DELETE FROM authcodes WHERE expiresAt <= ?', [ Date.now() ], function (error, result) { - if (error) return callback(new BoxError(BoxError.DATABASE_ERROR, error)); - return callback(null, result.affectedRows); - }); -} - -function clear(callback) { - assert.strictEqual(typeof callback, 'function'); - - database.query('DELETE FROM authcodes', function (error) { - if (error) return callback(new BoxError(BoxError.DATABASE_ERROR, error)); - - callback(null); - }); -} - diff --git a/src/janitor.js b/src/janitor.js index 2c98d780c..ee2880b39 100644 --- a/src/janitor.js +++ b/src/janitor.js @@ -2,7 +2,6 @@ var assert = require('assert'), async = require('async'), - authcodedb = require('./authcodedb.js'), BoxError = require('./boxerror.js'), debug = require('debug')('box:janitor'), Docker = require('dockerode'), @@ -39,26 +38,13 @@ function cleanupExpiredTokens(callback) { }); } -function cleanupExpiredAuthCodes(callback) { - assert.strictEqual(typeof callback, 'function'); - - authcodedb.delExpired(function (error, result) { - if (error) return callback(error); - - debug('Cleaned up %s expired authcodes.', result); - - callback(null); - }); -} - function cleanupTokens(callback) { assert(!callback || typeof callback === 'function'); // callback is null when called from cronjob debug('Cleaning up expired tokens'); async.series([ - ignoreError(cleanupExpiredTokens), - ignoreError(cleanupExpiredAuthCodes) + ignoreError(cleanupExpiredTokens) ], callback); } diff --git a/src/middleware/index.js b/src/middleware/index.js index 6a6a9da6f..4aa7a86df 100644 --- a/src/middleware/index.js +++ b/src/middleware/index.js @@ -1,14 +1,12 @@ 'use strict'; exports = module.exports = { - cookieParser: require('cookie-parser'), cors: require('./cors'), json: require('body-parser').json, morgan: require('morgan'), proxy: require('proxy-middleware'), lastMile: require('connect-lastmile'), multipart: require('./multipart.js'), - session: require('express-session'), timeout: require('connect-timeout'), urlencoded: require('body-parser').urlencoded }; diff --git a/src/oauth2views/callback.ejs b/src/oauth2views/callback.ejs deleted file mode 100644 index 8198cdcac..000000000 --- a/src/oauth2views/callback.ejs +++ /dev/null @@ -1,45 +0,0 @@ - - - diff --git a/src/oauth2views/error.ejs b/src/oauth2views/error.ejs deleted file mode 100644 index c65ef66e9..000000000 --- a/src/oauth2views/error.ejs +++ /dev/null @@ -1,27 +0,0 @@ -<% include header %> - - - -