2019-05-29 05:21:06 -04:00
|
|
|
const AdminController = require('./Features/ServerAdmin/AdminController')
|
|
|
|
const ErrorController = require('./Features/Errors/ErrorController')
|
|
|
|
const ProjectController = require('./Features/Project/ProjectController')
|
|
|
|
const ProjectApiController = require('./Features/Project/ProjectApiController')
|
|
|
|
const SpellingController = require('./Features/Spelling/SpellingController')
|
|
|
|
const EditorRouter = require('./Features/Editor/EditorRouter')
|
2021-07-07 05:38:56 -04:00
|
|
|
const Settings = require('@overleaf/settings')
|
2019-05-29 05:21:06 -04:00
|
|
|
const TpdsController = require('./Features/ThirdPartyDataStore/TpdsController')
|
|
|
|
const SubscriptionRouter = require('./Features/Subscription/SubscriptionRouter')
|
|
|
|
const UploadsRouter = require('./Features/Uploads/UploadsRouter')
|
2020-10-30 04:10:50 -04:00
|
|
|
const metrics = require('@overleaf/metrics')
|
2019-05-29 05:21:06 -04:00
|
|
|
const ReferalController = require('./Features/Referal/ReferalController')
|
|
|
|
const AuthenticationController = require('./Features/Authentication/AuthenticationController')
|
2021-07-28 04:51:20 -04:00
|
|
|
const SessionManager = require('./Features/Authentication/SessionManager')
|
2019-05-29 05:21:06 -04:00
|
|
|
const TagsController = require('./Features/Tags/TagsController')
|
|
|
|
const NotificationsController = require('./Features/Notifications/NotificationsController')
|
|
|
|
const CollaboratorsRouter = require('./Features/Collaborators/CollaboratorsRouter')
|
|
|
|
const UserInfoController = require('./Features/User/UserInfoController')
|
|
|
|
const UserController = require('./Features/User/UserController')
|
|
|
|
const UserEmailsController = require('./Features/User/UserEmailsController')
|
|
|
|
const UserPagesController = require('./Features/User/UserPagesController')
|
|
|
|
const DocumentController = require('./Features/Documents/DocumentController')
|
|
|
|
const CompileManager = require('./Features/Compile/CompileManager')
|
|
|
|
const CompileController = require('./Features/Compile/CompileController')
|
|
|
|
const ClsiCookieManager = require('./Features/Compile/ClsiCookieManager')(
|
|
|
|
Settings.apis.clsi != null ? Settings.apis.clsi.backendGroupName : undefined
|
|
|
|
)
|
|
|
|
const HealthCheckController = require('./Features/HealthCheck/HealthCheckController')
|
|
|
|
const ProjectDownloadsController = require('./Features/Downloads/ProjectDownloadsController')
|
|
|
|
const FileStoreController = require('./Features/FileStore/FileStoreController')
|
|
|
|
const HistoryController = require('./Features/History/HistoryController')
|
|
|
|
const ExportsController = require('./Features/Exports/ExportsController')
|
|
|
|
const PasswordResetRouter = require('./Features/PasswordReset/PasswordResetRouter')
|
|
|
|
const StaticPagesRouter = require('./Features/StaticPages/StaticPagesRouter')
|
|
|
|
const ChatController = require('./Features/Chat/ChatController')
|
|
|
|
const Modules = require('./infrastructure/Modules')
|
|
|
|
const RateLimiterMiddleware = require('./Features/Security/RateLimiterMiddleware')
|
|
|
|
const InactiveProjectController = require('./Features/InactiveData/InactiveProjectController')
|
|
|
|
const ContactRouter = require('./Features/Contacts/ContactRouter')
|
|
|
|
const ReferencesController = require('./Features/References/ReferencesController')
|
|
|
|
const AuthorizationMiddleware = require('./Features/Authorization/AuthorizationMiddleware')
|
|
|
|
const BetaProgramController = require('./Features/BetaProgram/BetaProgramController')
|
|
|
|
const AnalyticsRouter = require('./Features/Analytics/AnalyticsRouter')
|
|
|
|
const MetaController = require('./Features/Metadata/MetaController')
|
|
|
|
const TokenAccessController = require('./Features/TokenAccess/TokenAccessController')
|
|
|
|
const Features = require('./infrastructure/Features')
|
|
|
|
const LinkedFilesRouter = require('./Features/LinkedFiles/LinkedFilesRouter')
|
|
|
|
const TemplatesRouter = require('./Features/Templates/TemplatesRouter')
|
|
|
|
const InstitutionsController = require('./Features/Institutions/InstitutionsController')
|
|
|
|
const UserMembershipRouter = require('./Features/UserMembership/UserMembershipRouter')
|
2020-02-26 06:55:28 -05:00
|
|
|
const SystemMessageController = require('./Features/SystemMessages/SystemMessageController')
|
2021-06-10 04:04:11 -04:00
|
|
|
const AnalyticsRegistrationSourceMiddleware = require('./Features/Analytics/AnalyticsRegistrationSourceMiddleware')
|
2021-11-08 10:09:29 -05:00
|
|
|
const AnalyticsUTMTrackingMiddleware = require('./Features/Analytics/AnalyticsUTMTrackingMiddleware')
|
2021-12-02 05:13:50 -05:00
|
|
|
const SplitTestMiddleware = require('./Features/SplitTests/SplitTestMiddleware')
|
2022-01-26 06:15:19 -05:00
|
|
|
const CaptchaMiddleware = require('./Features/Captcha/CaptchaMiddleware')
|
2021-01-21 07:20:55 -05:00
|
|
|
const { Joi, validate } = require('./infrastructure/Validation')
|
2021-04-16 04:36:46 -04:00
|
|
|
const {
|
2021-04-28 04:48:58 -04:00
|
|
|
renderUnsupportedBrowserPage,
|
2021-04-27 03:52:58 -04:00
|
|
|
unsupportedBrowserMiddleware,
|
2021-04-16 04:36:46 -04:00
|
|
|
} = require('./infrastructure/UnsupportedBrowserMiddleware')
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2021-11-10 08:40:18 -05:00
|
|
|
const logger = require('@overleaf/logger')
|
2019-05-29 05:21:06 -04:00
|
|
|
const _ = require('underscore')
|
2021-12-02 05:13:50 -05:00
|
|
|
const { expressify } = require('./util/promises')
|
2022-01-17 05:19:53 -05:00
|
|
|
const { plainTextResponse } = require('./infrastructure/Response')
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-08-06 08:20:52 -04:00
|
|
|
module.exports = { initialize }
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-08-06 08:20:52 -04:00
|
|
|
function initialize(webRouter, privateApiRouter, publicApiRouter) {
|
2021-09-08 08:14:25 -04:00
|
|
|
webRouter.use(unsupportedBrowserMiddleware)
|
|
|
|
|
2019-08-06 08:20:52 -04:00
|
|
|
if (!Settings.allowPublicAccess) {
|
|
|
|
webRouter.all('*', AuthenticationController.requireGlobalLogin)
|
|
|
|
}
|
2019-07-18 10:19:10 -04:00
|
|
|
|
2021-06-21 10:02:43 -04:00
|
|
|
webRouter.get('*', AnalyticsRegistrationSourceMiddleware.setInbound())
|
2021-11-08 10:09:29 -05:00
|
|
|
webRouter.get('*', AnalyticsUTMTrackingMiddleware.recordUTMTags())
|
2021-12-02 05:13:50 -05:00
|
|
|
webRouter.get(
|
|
|
|
'*',
|
2021-12-02 05:14:44 -05:00
|
|
|
expressify(
|
|
|
|
SplitTestMiddleware.loadAssignmentsInLocals(['unified-navigation'])
|
|
|
|
)
|
2021-12-02 05:13:50 -05:00
|
|
|
)
|
2021-06-21 10:02:43 -04:00
|
|
|
|
2022-01-26 06:15:19 -05:00
|
|
|
// Mount onto /login in order to get the deviceHistory cookie.
|
|
|
|
webRouter.post(
|
|
|
|
'/login/can-skip-captcha',
|
|
|
|
// Keep in sync with the overleaf-login options.
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'can-skip-captcha',
|
|
|
|
maxRequests: 20,
|
|
|
|
timeInterval: 60,
|
|
|
|
}),
|
|
|
|
CaptchaMiddleware.canSkipCaptcha
|
|
|
|
)
|
|
|
|
|
2019-08-06 08:20:52 -04:00
|
|
|
webRouter.get('/login', UserPagesController.loginPage)
|
|
|
|
AuthenticationController.addEndpointToLoginWhitelist('/login')
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2022-01-26 06:15:19 -05:00
|
|
|
webRouter.post(
|
|
|
|
'/login',
|
|
|
|
CaptchaMiddleware.validateCaptcha('login'),
|
|
|
|
AuthenticationController.passportLogin
|
|
|
|
)
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2021-07-20 05:26:03 -04:00
|
|
|
if (Settings.enableLegacyLogin) {
|
|
|
|
AuthenticationController.addEndpointToLoginWhitelist('/login/legacy')
|
|
|
|
webRouter.get('/login/legacy', UserPagesController.loginPage)
|
|
|
|
webRouter.post('/login/legacy', AuthenticationController.passportLogin)
|
|
|
|
}
|
|
|
|
|
2019-08-06 08:20:52 -04:00
|
|
|
webRouter.get(
|
|
|
|
'/read-only/one-time-login',
|
|
|
|
UserPagesController.oneTimeLoginPage
|
|
|
|
)
|
|
|
|
AuthenticationController.addEndpointToLoginWhitelist(
|
|
|
|
'/read-only/one-time-login'
|
|
|
|
)
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-08-06 08:20:52 -04:00
|
|
|
webRouter.get('/logout', UserPagesController.logoutPage)
|
|
|
|
webRouter.post('/logout', UserController.logout)
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-08-06 08:20:52 -04:00
|
|
|
webRouter.get('/restricted', AuthorizationMiddleware.restricted)
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2021-07-20 05:26:23 -04:00
|
|
|
if (Features.hasFeature('registration-page')) {
|
2019-08-06 08:20:52 -04:00
|
|
|
webRouter.get('/register', UserPagesController.registerPage)
|
|
|
|
AuthenticationController.addEndpointToLoginWhitelist('/register')
|
|
|
|
}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-08-06 08:20:52 -04:00
|
|
|
EditorRouter.apply(webRouter, privateApiRouter)
|
|
|
|
CollaboratorsRouter.apply(webRouter, privateApiRouter)
|
|
|
|
SubscriptionRouter.apply(webRouter, privateApiRouter, publicApiRouter)
|
|
|
|
UploadsRouter.apply(webRouter, privateApiRouter)
|
|
|
|
PasswordResetRouter.apply(webRouter, privateApiRouter)
|
|
|
|
StaticPagesRouter.apply(webRouter, privateApiRouter)
|
|
|
|
ContactRouter.apply(webRouter, privateApiRouter)
|
|
|
|
AnalyticsRouter.apply(webRouter, privateApiRouter, publicApiRouter)
|
|
|
|
LinkedFilesRouter.apply(webRouter, privateApiRouter, publicApiRouter)
|
|
|
|
TemplatesRouter.apply(webRouter)
|
|
|
|
UserMembershipRouter.apply(webRouter)
|
|
|
|
|
|
|
|
Modules.applyRouter(webRouter, privateApiRouter, publicApiRouter)
|
|
|
|
|
|
|
|
if (Settings.enableSubscriptions) {
|
2019-05-29 05:21:06 -04:00
|
|
|
webRouter.get(
|
2019-08-06 08:20:52 -04:00
|
|
|
'/user/bonus',
|
2019-05-29 05:21:06 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
2019-08-06 08:20:52 -04:00
|
|
|
ReferalController.bonus
|
2019-05-29 05:21:06 -04:00
|
|
|
)
|
2019-08-06 08:20:52 -04:00
|
|
|
}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2020-07-24 04:54:55 -04:00
|
|
|
// .getMessages will generate an empty response for anonymous users.
|
|
|
|
webRouter.get('/system/messages', SystemMessageController.getMessages)
|
2020-02-26 06:55:28 -05:00
|
|
|
|
2019-08-06 08:20:52 -04:00
|
|
|
webRouter.get(
|
|
|
|
'/user/settings',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
UserPagesController.settingsPage
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/user/settings',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
UserController.updateUserSettings
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/user/password/update',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'change-password',
|
|
|
|
maxRequests: 10,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
|
|
|
UserController.changePassword
|
|
|
|
)
|
|
|
|
webRouter.get(
|
|
|
|
'/user/emails',
|
|
|
|
AuthenticationController.requireLogin(),
|
2020-03-11 09:21:44 -04:00
|
|
|
UserController.promises.ensureAffiliationMiddleware,
|
2019-08-06 08:20:52 -04:00
|
|
|
UserEmailsController.list
|
|
|
|
)
|
|
|
|
webRouter.get('/user/emails/confirm', UserEmailsController.showConfirm)
|
|
|
|
webRouter.post(
|
|
|
|
'/user/emails/confirm',
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'confirm-email',
|
|
|
|
maxRequests: 10,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
|
|
|
UserEmailsController.confirm
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/user/emails/resend_confirmation',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'resend-confirmation',
|
|
|
|
maxRequests: 10,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
|
|
|
UserEmailsController.resendConfirmation
|
|
|
|
)
|
|
|
|
|
|
|
|
if (Features.hasFeature('affiliations')) {
|
2019-05-29 05:21:06 -04:00
|
|
|
webRouter.post(
|
2019-08-06 08:20:52 -04:00
|
|
|
'/user/emails',
|
2019-05-29 05:21:06 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
2019-08-06 08:20:52 -04:00
|
|
|
endpointName: 'add-email',
|
2019-05-29 05:21:06 -04:00
|
|
|
maxRequests: 10,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-05-29 05:21:06 -04:00
|
|
|
}),
|
2019-08-06 08:20:52 -04:00
|
|
|
UserEmailsController.add
|
2019-05-29 05:21:06 -04:00
|
|
|
)
|
|
|
|
webRouter.post(
|
2019-08-06 08:20:52 -04:00
|
|
|
'/user/emails/delete',
|
2019-05-29 05:21:06 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
2019-08-06 08:20:52 -04:00
|
|
|
endpointName: 'delete-email',
|
|
|
|
maxRequests: 10,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-05-29 05:21:06 -04:00
|
|
|
}),
|
2019-08-06 08:20:52 -04:00
|
|
|
UserEmailsController.remove
|
2019-05-29 05:21:06 -04:00
|
|
|
)
|
|
|
|
webRouter.post(
|
2019-08-06 08:20:52 -04:00
|
|
|
'/user/emails/default',
|
2019-05-29 05:21:06 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
2019-08-06 08:20:52 -04:00
|
|
|
UserEmailsController.setDefault
|
2019-05-29 05:21:06 -04:00
|
|
|
)
|
|
|
|
webRouter.post(
|
2019-08-06 08:20:52 -04:00
|
|
|
'/user/emails/endorse',
|
2019-05-29 05:21:06 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
2019-08-06 08:20:52 -04:00
|
|
|
endpointName: 'endorse-email',
|
2019-05-29 05:21:06 -04:00
|
|
|
maxRequests: 30,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-05-29 05:21:06 -04:00
|
|
|
}),
|
2019-08-06 08:20:52 -04:00
|
|
|
UserEmailsController.endorse
|
2019-05-29 05:21:06 -04:00
|
|
|
)
|
2019-08-06 08:20:52 -04:00
|
|
|
}
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-08-06 08:20:52 -04:00
|
|
|
webRouter.get(
|
|
|
|
'/user/sessions',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
UserPagesController.sessionsPage
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/user/sessions/clear',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
UserController.clearSessions
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.delete(
|
|
|
|
'/user/newsletter/unsubscribe',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
UserController.unsubscribe
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/user/delete',
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'delete-user',
|
|
|
|
maxRequests: 10,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
UserController.tryDeleteUser
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.get(
|
|
|
|
'/user/personal_info',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
UserInfoController.getLoggedInUsersPersonalInfo
|
|
|
|
)
|
|
|
|
privateApiRouter.get(
|
|
|
|
'/user/:user_id/personal_info',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
UserInfoController.getPersonalInfo
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.get(
|
|
|
|
'/user/reconfirm',
|
|
|
|
UserPagesController.renderReconfirmAccountPage
|
|
|
|
)
|
|
|
|
// for /user/reconfirm POST, see password router
|
|
|
|
|
2020-04-15 07:37:05 -04:00
|
|
|
webRouter.get(
|
|
|
|
'/user/tpds/queues',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
TpdsController.getQueues
|
|
|
|
)
|
|
|
|
|
2019-08-06 08:20:52 -04:00
|
|
|
webRouter.get(
|
|
|
|
'/user/projects',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
ProjectController.userProjectsJson
|
|
|
|
)
|
|
|
|
webRouter.get(
|
|
|
|
'/project/:Project_id/entities',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
ProjectController.projectEntitiesJson
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.get(
|
|
|
|
'/project',
|
|
|
|
AuthenticationController.requireLogin(),
|
2019-09-26 08:42:33 -04:00
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'open-dashboard',
|
|
|
|
maxRequests: 30,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-09-26 08:42:33 -04:00
|
|
|
}),
|
2019-08-06 08:20:52 -04:00
|
|
|
ProjectController.projectListPage
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/project/new',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'create-project',
|
|
|
|
maxRequests: 20,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
|
|
|
ProjectController.newProject
|
|
|
|
)
|
|
|
|
|
2021-11-19 06:08:57 -05:00
|
|
|
for (const route of [
|
|
|
|
// Keep the old route for continuous metrics
|
|
|
|
'/Project/:Project_id',
|
|
|
|
// New route for pdf-detach
|
|
|
|
'/Project/:Project_id/:detachRole(detacher|detached)',
|
|
|
|
]) {
|
|
|
|
webRouter.get(
|
|
|
|
route,
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'open-project',
|
|
|
|
params: ['Project_id'],
|
|
|
|
maxRequests: 15,
|
|
|
|
timeInterval: 60,
|
|
|
|
}),
|
|
|
|
AuthenticationController.validateUserSession(),
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
ProjectController.loadEditor
|
|
|
|
)
|
|
|
|
}
|
2019-08-06 08:20:52 -04:00
|
|
|
webRouter.head(
|
|
|
|
'/Project/:Project_id/file/:File_id',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
FileStoreController.getFileHead
|
|
|
|
)
|
|
|
|
webRouter.get(
|
|
|
|
'/Project/:Project_id/file/:File_id',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
FileStoreController.getFile
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/project/:Project_id/settings',
|
2021-09-13 09:43:46 -04:00
|
|
|
validate({ body: Joi.object() }),
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthorizationMiddleware.ensureUserCanWriteProjectSettings,
|
|
|
|
ProjectController.updateProjectSettings
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/project/:Project_id/settings/admin',
|
2019-09-30 09:21:49 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthorizationMiddleware.ensureUserCanAdminProject,
|
|
|
|
ProjectController.updateProjectAdminSettings
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.post(
|
|
|
|
'/project/:Project_id/compile',
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'compile-project-http',
|
|
|
|
params: ['Project_id'],
|
|
|
|
maxRequests: 800,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60 * 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
CompileController.compile
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.post(
|
|
|
|
'/project/:Project_id/compile/stop',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
CompileController.stopCompile
|
|
|
|
)
|
|
|
|
|
|
|
|
// LEGACY: Used by the web download buttons, adds filename header, TODO: remove at some future date
|
|
|
|
webRouter.get(
|
|
|
|
'/project/:Project_id/output/output.pdf',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
CompileController.downloadPdf
|
|
|
|
)
|
|
|
|
|
|
|
|
// PDF Download button
|
|
|
|
webRouter.get(
|
|
|
|
/^\/download\/project\/([^/]*)\/output\/output\.pdf$/,
|
2021-04-14 09:17:21 -04:00
|
|
|
function (req, res, next) {
|
2019-08-06 08:20:52 -04:00
|
|
|
const params = { Project_id: req.params[0] }
|
|
|
|
req.params = params
|
|
|
|
next()
|
|
|
|
},
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
CompileController.downloadPdf
|
|
|
|
)
|
|
|
|
|
|
|
|
// PDF Download button for specific build
|
|
|
|
webRouter.get(
|
|
|
|
/^\/download\/project\/([^/]*)\/build\/([0-9a-f-]+)\/output\/output\.pdf$/,
|
2021-04-14 09:17:21 -04:00
|
|
|
function (req, res, next) {
|
2019-08-06 08:20:52 -04:00
|
|
|
const params = {
|
|
|
|
Project_id: req.params[0],
|
2021-04-27 03:52:58 -04:00
|
|
|
build_id: req.params[1],
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-08-06 08:20:52 -04:00
|
|
|
req.params = params
|
|
|
|
next()
|
|
|
|
},
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
CompileController.downloadPdf
|
|
|
|
)
|
|
|
|
|
2020-11-26 07:55:22 -05:00
|
|
|
// Align with limits defined in CompileController.downloadPdf
|
|
|
|
const rateLimiterMiddlewareOutputFiles = RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'misc-output-download',
|
|
|
|
params: ['Project_id'],
|
|
|
|
maxRequests: 1000,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60 * 60,
|
2020-11-26 07:55:22 -05:00
|
|
|
})
|
|
|
|
|
2019-08-06 08:20:52 -04:00
|
|
|
// Used by the pdf viewers
|
|
|
|
webRouter.get(
|
|
|
|
/^\/project\/([^/]*)\/output\/(.*)$/,
|
2021-04-14 09:17:21 -04:00
|
|
|
function (req, res, next) {
|
2019-08-06 08:20:52 -04:00
|
|
|
const params = {
|
|
|
|
Project_id: req.params[0],
|
2021-04-27 03:52:58 -04:00
|
|
|
file: req.params[1],
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2019-08-06 08:20:52 -04:00
|
|
|
req.params = params
|
|
|
|
next()
|
|
|
|
},
|
2020-11-26 07:55:22 -05:00
|
|
|
rateLimiterMiddlewareOutputFiles,
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
CompileController.getFileFromClsi
|
|
|
|
)
|
|
|
|
// direct url access to output files for a specific build (query string not required)
|
|
|
|
webRouter.get(
|
|
|
|
/^\/project\/([^/]*)\/build\/([0-9a-f-]+)\/output\/(.*)$/,
|
2021-04-14 09:17:21 -04:00
|
|
|
function (req, res, next) {
|
2019-08-06 08:20:52 -04:00
|
|
|
const params = {
|
|
|
|
Project_id: req.params[0],
|
|
|
|
build_id: req.params[1],
|
2021-04-27 03:52:58 -04:00
|
|
|
file: req.params[2],
|
2019-08-06 08:20:52 -04:00
|
|
|
}
|
|
|
|
req.params = params
|
|
|
|
next()
|
|
|
|
},
|
2020-11-26 07:55:22 -05:00
|
|
|
rateLimiterMiddlewareOutputFiles,
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
CompileController.getFileFromClsi
|
|
|
|
)
|
|
|
|
|
|
|
|
// direct url access to output files for user but no build, to retrieve files when build fails
|
|
|
|
webRouter.get(
|
|
|
|
/^\/project\/([^/]*)\/user\/([0-9a-f-]+)\/output\/(.*)$/,
|
2021-04-14 09:17:21 -04:00
|
|
|
function (req, res, next) {
|
2019-08-06 08:20:52 -04:00
|
|
|
const params = {
|
|
|
|
Project_id: req.params[0],
|
|
|
|
user_id: req.params[1],
|
2021-04-27 03:52:58 -04:00
|
|
|
file: req.params[2],
|
2019-08-06 08:20:52 -04:00
|
|
|
}
|
|
|
|
req.params = params
|
|
|
|
next()
|
|
|
|
},
|
2020-11-26 07:55:22 -05:00
|
|
|
rateLimiterMiddlewareOutputFiles,
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
CompileController.getFileFromClsi
|
|
|
|
)
|
|
|
|
|
|
|
|
// direct url access to output files for a specific user and build (query string not required)
|
|
|
|
webRouter.get(
|
|
|
|
/^\/project\/([^/]*)\/user\/([0-9a-f]+)\/build\/([0-9a-f-]+)\/output\/(.*)$/,
|
2021-04-14 09:17:21 -04:00
|
|
|
function (req, res, next) {
|
2019-08-06 08:20:52 -04:00
|
|
|
const params = {
|
|
|
|
Project_id: req.params[0],
|
|
|
|
user_id: req.params[1],
|
|
|
|
build_id: req.params[2],
|
2021-04-27 03:52:58 -04:00
|
|
|
file: req.params[3],
|
2019-08-06 08:20:52 -04:00
|
|
|
}
|
|
|
|
req.params = params
|
|
|
|
next()
|
|
|
|
},
|
2020-11-26 07:55:22 -05:00
|
|
|
rateLimiterMiddlewareOutputFiles,
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
CompileController.getFileFromClsi
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.delete(
|
|
|
|
'/project/:Project_id/output',
|
2021-01-21 07:20:55 -05:00
|
|
|
validate({ query: { clsiserverid: Joi.string() } }),
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
CompileController.deleteAuxFiles
|
|
|
|
)
|
|
|
|
webRouter.get(
|
|
|
|
'/project/:Project_id/sync/code',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
CompileController.proxySyncCode
|
|
|
|
)
|
|
|
|
webRouter.get(
|
|
|
|
'/project/:Project_id/sync/pdf',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
CompileController.proxySyncPdf
|
|
|
|
)
|
|
|
|
webRouter.get(
|
|
|
|
'/project/:Project_id/wordcount',
|
2021-01-21 07:20:55 -05:00
|
|
|
validate({ query: { clsiserverid: Joi.string() } }),
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
CompileController.wordCount
|
|
|
|
)
|
|
|
|
|
2019-10-02 10:06:57 -04:00
|
|
|
webRouter.post(
|
|
|
|
'/Project/:Project_id/archive',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
ProjectController.archiveProject
|
|
|
|
)
|
|
|
|
webRouter.delete(
|
|
|
|
'/Project/:Project_id/archive',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
ProjectController.unarchiveProject
|
|
|
|
)
|
2019-09-26 08:42:15 -04:00
|
|
|
webRouter.post(
|
|
|
|
'/project/:project_id/trash',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
ProjectController.trashProject
|
|
|
|
)
|
|
|
|
webRouter.delete(
|
|
|
|
'/project/:project_id/trash',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
ProjectController.untrashProject
|
|
|
|
)
|
|
|
|
|
2019-08-06 08:20:52 -04:00
|
|
|
webRouter.delete(
|
|
|
|
'/Project/:Project_id',
|
2019-09-30 09:21:49 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthorizationMiddleware.ensureUserCanAdminProject,
|
|
|
|
ProjectController.deleteProject
|
|
|
|
)
|
2019-10-02 10:06:57 -04:00
|
|
|
|
2019-08-06 08:20:52 -04:00
|
|
|
webRouter.post(
|
|
|
|
'/Project/:Project_id/restore',
|
2019-09-30 09:21:49 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthorizationMiddleware.ensureUserCanAdminProject,
|
|
|
|
ProjectController.restoreProject
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/Project/:Project_id/clone',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
ProjectController.cloneProject
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.post(
|
|
|
|
'/project/:Project_id/rename',
|
2019-09-30 09:21:49 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthorizationMiddleware.ensureUserCanAdminProject,
|
|
|
|
ProjectController.renameProject
|
|
|
|
)
|
|
|
|
webRouter.get(
|
|
|
|
'/project/:Project_id/updates',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
HistoryController.selectHistoryApi,
|
|
|
|
HistoryController.proxyToHistoryApiAndInjectUserDetails
|
|
|
|
)
|
|
|
|
webRouter.get(
|
|
|
|
'/project/:Project_id/doc/:doc_id/diff',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
HistoryController.selectHistoryApi,
|
|
|
|
HistoryController.proxyToHistoryApi
|
|
|
|
)
|
|
|
|
webRouter.get(
|
|
|
|
'/project/:Project_id/diff',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
HistoryController.selectHistoryApi,
|
|
|
|
HistoryController.proxyToHistoryApiAndInjectUserDetails
|
|
|
|
)
|
|
|
|
webRouter.get(
|
|
|
|
'/project/:Project_id/filetree/diff',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
HistoryController.selectHistoryApi,
|
|
|
|
HistoryController.proxyToHistoryApi
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/project/:Project_id/doc/:doc_id/version/:version_id/restore',
|
|
|
|
AuthorizationMiddleware.ensureUserCanWriteProjectContent,
|
|
|
|
HistoryController.selectHistoryApi,
|
|
|
|
HistoryController.proxyToHistoryApi
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/project/:project_id/doc/:doc_id/restore',
|
|
|
|
AuthorizationMiddleware.ensureUserCanWriteProjectContent,
|
|
|
|
HistoryController.restoreDocFromDeletedDoc
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/project/:project_id/restore_file',
|
|
|
|
AuthorizationMiddleware.ensureUserCanWriteProjectContent,
|
|
|
|
HistoryController.restoreFileFromV2
|
|
|
|
)
|
|
|
|
webRouter.get(
|
|
|
|
'/project/:project_id/version/:version/zip',
|
2020-07-10 06:46:33 -04:00
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'download-project-revision',
|
|
|
|
maxRequests: 30,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60 * 60,
|
2020-07-10 06:46:33 -04:00
|
|
|
}),
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
HistoryController.downloadZipOfVersion
|
|
|
|
)
|
|
|
|
privateApiRouter.post(
|
|
|
|
'/project/:Project_id/history/resync',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
HistoryController.resyncProjectHistory
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.get(
|
|
|
|
'/project/:Project_id/labels',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
HistoryController.selectHistoryApi,
|
|
|
|
HistoryController.ensureProjectHistoryEnabled,
|
|
|
|
HistoryController.getLabels
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/project/:Project_id/labels',
|
|
|
|
AuthorizationMiddleware.ensureUserCanWriteProjectContent,
|
|
|
|
HistoryController.selectHistoryApi,
|
|
|
|
HistoryController.ensureProjectHistoryEnabled,
|
|
|
|
HistoryController.createLabel
|
|
|
|
)
|
|
|
|
webRouter.delete(
|
|
|
|
'/project/:Project_id/labels/:label_id',
|
|
|
|
AuthorizationMiddleware.ensureUserCanWriteProjectContent,
|
|
|
|
HistoryController.selectHistoryApi,
|
|
|
|
HistoryController.ensureProjectHistoryEnabled,
|
|
|
|
HistoryController.deleteLabel
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.post(
|
|
|
|
'/project/:project_id/export/:brand_variation_id',
|
|
|
|
AuthorizationMiddleware.ensureUserCanWriteProjectContent,
|
|
|
|
ExportsController.exportProject
|
|
|
|
)
|
|
|
|
webRouter.get(
|
|
|
|
'/project/:project_id/export/:export_id',
|
|
|
|
AuthorizationMiddleware.ensureUserCanWriteProjectContent,
|
|
|
|
ExportsController.exportStatus
|
|
|
|
)
|
|
|
|
webRouter.get(
|
|
|
|
'/project/:project_id/export/:export_id/:type',
|
|
|
|
AuthorizationMiddleware.ensureUserCanWriteProjectContent,
|
|
|
|
ExportsController.exportDownload
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.get(
|
|
|
|
'/Project/:Project_id/download/zip',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
ProjectDownloadsController.downloadProject
|
|
|
|
)
|
|
|
|
webRouter.get(
|
|
|
|
'/project/download/zip',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadMultipleProjects,
|
|
|
|
ProjectDownloadsController.downloadMultipleProjects
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.get(
|
|
|
|
'/project/:project_id/metadata',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
2020-10-27 06:53:44 -04:00
|
|
|
Settings.allowAnonymousReadAndWriteSharing
|
|
|
|
? (req, res, next) => {
|
|
|
|
next()
|
|
|
|
}
|
|
|
|
: AuthenticationController.requireLogin(),
|
2019-08-06 08:20:52 -04:00
|
|
|
MetaController.getMetadata
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/project/:project_id/doc/:doc_id/metadata',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
2020-10-27 06:53:44 -04:00
|
|
|
Settings.allowAnonymousReadAndWriteSharing
|
|
|
|
? (req, res, next) => {
|
|
|
|
next()
|
|
|
|
}
|
|
|
|
: AuthenticationController.requireLogin(),
|
2019-08-06 08:20:52 -04:00
|
|
|
MetaController.broadcastMetadataForDoc
|
|
|
|
)
|
|
|
|
privateApiRouter.post(
|
|
|
|
'/internal/expire-deleted-projects-after-duration',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
ProjectController.expireDeletedProjectsAfterDuration
|
|
|
|
)
|
|
|
|
privateApiRouter.post(
|
|
|
|
'/internal/expire-deleted-users-after-duration',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
UserController.expireDeletedUsersAfterDuration
|
|
|
|
)
|
|
|
|
privateApiRouter.post(
|
|
|
|
'/internal/project/:projectId/expire-deleted-project',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
ProjectController.expireDeletedProject
|
|
|
|
)
|
|
|
|
privateApiRouter.post(
|
|
|
|
'/internal/users/:userId/expire',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
UserController.expireDeletedUser
|
|
|
|
)
|
|
|
|
|
2020-03-24 06:20:06 -04:00
|
|
|
privateApiRouter.get(
|
|
|
|
'/user/:userId/tag',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2020-03-24 06:20:06 -04:00
|
|
|
TagsController.apiGetAllTags
|
|
|
|
)
|
2019-08-06 08:20:52 -04:00
|
|
|
webRouter.get(
|
|
|
|
'/tag',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
TagsController.getAllTags
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/tag',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'create-tag',
|
|
|
|
maxRequests: 30,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
|
|
|
TagsController.createTag
|
|
|
|
)
|
|
|
|
webRouter.post(
|
2020-03-24 06:20:06 -04:00
|
|
|
'/tag/:tagId/rename',
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'rename-tag',
|
|
|
|
maxRequests: 30,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
|
|
|
TagsController.renameTag
|
|
|
|
)
|
|
|
|
webRouter.delete(
|
2020-03-24 06:20:06 -04:00
|
|
|
'/tag/:tagId',
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'delete-tag',
|
|
|
|
maxRequests: 30,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
|
|
|
TagsController.deleteTag
|
|
|
|
)
|
|
|
|
webRouter.post(
|
2020-03-24 06:20:06 -04:00
|
|
|
'/tag/:tagId/project/:projectId',
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'add-project-to-tag',
|
|
|
|
maxRequests: 30,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
|
|
|
TagsController.addProjectToTag
|
|
|
|
)
|
|
|
|
webRouter.delete(
|
2020-03-24 06:20:06 -04:00
|
|
|
'/tag/:tagId/project/:projectId',
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'remove-project-from-tag',
|
|
|
|
maxRequests: 30,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
|
|
|
TagsController.removeProjectFromTag
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.get(
|
|
|
|
'/notifications',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
NotificationsController.getAllUnreadNotifications
|
|
|
|
)
|
|
|
|
webRouter.delete(
|
2021-05-05 09:20:32 -04:00
|
|
|
'/notifications/:notificationId',
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
NotificationsController.markNotificationAsRead
|
|
|
|
)
|
|
|
|
|
|
|
|
// Deprecated in favour of /internal/project/:project_id but still used by versioning
|
|
|
|
privateApiRouter.get(
|
|
|
|
'/project/:project_id/details',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
ProjectApiController.getProjectDetails
|
|
|
|
)
|
|
|
|
|
|
|
|
// New 'stable' /internal API end points
|
|
|
|
privateApiRouter.get(
|
|
|
|
'/internal/project/:project_id',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
ProjectApiController.getProjectDetails
|
|
|
|
)
|
|
|
|
privateApiRouter.get(
|
|
|
|
'/internal/project/:Project_id/zip',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
ProjectDownloadsController.downloadProject
|
|
|
|
)
|
|
|
|
privateApiRouter.get(
|
|
|
|
'/internal/project/:project_id/compile/pdf',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
CompileController.compileAndDownloadPdf
|
|
|
|
)
|
|
|
|
|
|
|
|
privateApiRouter.post(
|
|
|
|
'/internal/deactivateOldProjects',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
InactiveProjectController.deactivateOldProjects
|
|
|
|
)
|
|
|
|
privateApiRouter.post(
|
|
|
|
'/internal/project/:project_id/deactivate',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
InactiveProjectController.deactivateProject
|
|
|
|
)
|
|
|
|
|
2019-11-18 05:57:36 -05:00
|
|
|
privateApiRouter.get(
|
2019-08-06 08:20:52 -04:00
|
|
|
/^\/internal\/project\/([^/]*)\/output\/(.*)$/,
|
2021-04-14 09:17:21 -04:00
|
|
|
function (req, res, next) {
|
2019-08-06 08:20:52 -04:00
|
|
|
const params = {
|
|
|
|
Project_id: req.params[0],
|
2021-04-27 03:52:58 -04:00
|
|
|
file: req.params[1],
|
2019-08-06 08:20:52 -04:00
|
|
|
}
|
|
|
|
req.params = params
|
|
|
|
next()
|
|
|
|
},
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
CompileController.getFileFromClsi
|
|
|
|
)
|
|
|
|
|
|
|
|
privateApiRouter.get(
|
|
|
|
'/project/:Project_id/doc/:doc_id',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
DocumentController.getDocument
|
|
|
|
)
|
|
|
|
privateApiRouter.post(
|
|
|
|
'/project/:Project_id/doc/:doc_id',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
DocumentController.setDocument
|
|
|
|
)
|
|
|
|
|
|
|
|
privateApiRouter.post(
|
|
|
|
'/user/:user_id/update/*',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
TpdsController.mergeUpdate
|
|
|
|
)
|
|
|
|
privateApiRouter.delete(
|
|
|
|
'/user/:user_id/update/*',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
TpdsController.deleteUpdate
|
|
|
|
)
|
|
|
|
|
|
|
|
privateApiRouter.post(
|
|
|
|
'/project/:project_id/contents/*',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
TpdsController.updateProjectContents
|
|
|
|
)
|
|
|
|
privateApiRouter.delete(
|
|
|
|
'/project/:project_id/contents/*',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
TpdsController.deleteProjectContents
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.post(
|
|
|
|
'/spelling/check',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SpellingController.proxyRequestToSpellingApi
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/spelling/learn',
|
2022-01-06 05:41:31 -05:00
|
|
|
validate({
|
|
|
|
body: Joi.object({
|
|
|
|
word: Joi.string().required(),
|
|
|
|
}),
|
|
|
|
}),
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
2022-01-06 05:41:31 -05:00
|
|
|
SpellingController.learn
|
2019-08-06 08:20:52 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.get(
|
|
|
|
'/project/:project_id/messages',
|
2020-06-04 04:47:12 -04:00
|
|
|
AuthorizationMiddleware.blockRestrictedUserFromProject,
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
ChatController.getMessages
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/project/:project_id/messages',
|
2020-06-04 04:47:12 -04:00
|
|
|
AuthorizationMiddleware.blockRestrictedUserFromProject,
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'send-chat-message',
|
|
|
|
maxRequests: 100,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
|
|
|
ChatController.sendMessage
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.post(
|
|
|
|
'/project/:Project_id/references/index',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'index-project-references',
|
|
|
|
maxRequests: 30,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
|
|
|
ReferencesController.index
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/project/:Project_id/references/indexAll',
|
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'index-all-project-references',
|
|
|
|
maxRequests: 30,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
|
|
|
ReferencesController.indexAll
|
|
|
|
)
|
|
|
|
|
|
|
|
// disable beta program while v2 is in beta
|
|
|
|
webRouter.get(
|
|
|
|
'/beta/participate',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
BetaProgramController.optInPage
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/beta/opt-in',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
BetaProgramController.optIn
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/beta/opt-out',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
BetaProgramController.optOut
|
|
|
|
)
|
|
|
|
|
|
|
|
// New "api" endpoints. Started as a way for v1 to call over to v2 (for
|
|
|
|
// long-term features, as opposed to the nominally temporary ones in the
|
|
|
|
// overleaf-integration module), but may expand beyond that role.
|
|
|
|
publicApiRouter.post(
|
|
|
|
'/api/clsi/compile/:submission_id',
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
CompileController.compileSubmission
|
|
|
|
)
|
|
|
|
publicApiRouter.get(
|
|
|
|
/^\/api\/clsi\/compile\/([^/]*)\/build\/([0-9a-f-]+)\/output\/(.*)$/,
|
2021-04-14 09:17:21 -04:00
|
|
|
function (req, res, next) {
|
2019-08-06 08:20:52 -04:00
|
|
|
const params = {
|
|
|
|
submission_id: req.params[0],
|
|
|
|
build_id: req.params[1],
|
2021-04-27 03:52:58 -04:00
|
|
|
file: req.params[2],
|
2019-08-06 08:20:52 -04:00
|
|
|
}
|
|
|
|
req.params = params
|
|
|
|
next()
|
|
|
|
},
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
CompileController.getFileFromClsiWithoutUser
|
|
|
|
)
|
|
|
|
publicApiRouter.post(
|
|
|
|
'/api/institutions/confirm_university_domain',
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'confirm-university-domain',
|
|
|
|
maxRequests: 1,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
2021-05-31 04:30:04 -04:00
|
|
|
AuthenticationController.requirePrivateApiAuth(),
|
2019-08-06 08:20:52 -04:00
|
|
|
InstitutionsController.confirmDomain
|
|
|
|
)
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
webRouter.get('/chrome', function (req, res, next) {
|
2019-08-06 08:20:52 -04:00
|
|
|
// Match v1 behaviour - this is used for a Chrome web app
|
2021-07-28 04:51:20 -04:00
|
|
|
if (SessionManager.isUserLoggedIn(req.session)) {
|
2019-08-06 08:20:52 -04:00
|
|
|
res.redirect('/project')
|
|
|
|
} else {
|
|
|
|
res.redirect('/register')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
// Admin Stuff
|
|
|
|
webRouter.get(
|
|
|
|
'/admin',
|
|
|
|
AuthorizationMiddleware.ensureUserIsSiteAdmin,
|
|
|
|
AdminController.index
|
|
|
|
)
|
|
|
|
webRouter.get(
|
|
|
|
'/admin/user',
|
|
|
|
AuthorizationMiddleware.ensureUserIsSiteAdmin,
|
|
|
|
(req, res) => res.redirect('/admin/register')
|
|
|
|
) // this gets removed by admin-panel addon
|
|
|
|
webRouter.get(
|
|
|
|
'/admin/register',
|
|
|
|
AuthorizationMiddleware.ensureUserIsSiteAdmin,
|
|
|
|
AdminController.registerNewUser
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/admin/register',
|
|
|
|
AuthorizationMiddleware.ensureUserIsSiteAdmin,
|
|
|
|
UserController.register
|
|
|
|
)
|
2021-03-30 07:10:27 -04:00
|
|
|
if (!Features.hasFeature('saas')) {
|
|
|
|
webRouter.post(
|
|
|
|
'/admin/openEditor',
|
|
|
|
AuthorizationMiddleware.ensureUserIsSiteAdmin,
|
|
|
|
AdminController.openEditor
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/admin/closeEditor',
|
|
|
|
AuthorizationMiddleware.ensureUserIsSiteAdmin,
|
|
|
|
AdminController.closeEditor
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/admin/disconnectAllUsers',
|
|
|
|
AuthorizationMiddleware.ensureUserIsSiteAdmin,
|
|
|
|
AdminController.disconnectAllUsers
|
|
|
|
)
|
|
|
|
}
|
2019-08-06 08:20:52 -04:00
|
|
|
webRouter.post(
|
|
|
|
'/admin/flushProjectToTpds',
|
|
|
|
AuthorizationMiddleware.ensureUserIsSiteAdmin,
|
|
|
|
AdminController.flushProjectToTpds
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/admin/pollDropboxForUser',
|
|
|
|
AuthorizationMiddleware.ensureUserIsSiteAdmin,
|
|
|
|
AdminController.pollDropboxForUser
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/admin/messages',
|
|
|
|
AuthorizationMiddleware.ensureUserIsSiteAdmin,
|
|
|
|
AdminController.createMessage
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/admin/messages/clear',
|
|
|
|
AuthorizationMiddleware.ensureUserIsSiteAdmin,
|
|
|
|
AdminController.clearMessages
|
|
|
|
)
|
2021-06-16 04:14:18 -04:00
|
|
|
webRouter.post(
|
|
|
|
'/admin/unregisterServiceWorker',
|
|
|
|
AuthorizationMiddleware.ensureUserIsSiteAdmin,
|
|
|
|
AdminController.unregisterServiceWorker
|
|
|
|
)
|
2019-08-06 08:20:52 -04:00
|
|
|
|
2022-01-17 05:19:53 -05:00
|
|
|
privateApiRouter.get('/perfTest', (req, res) => {
|
|
|
|
plainTextResponse(res, 'hello')
|
|
|
|
})
|
2019-08-06 08:20:52 -04:00
|
|
|
|
2021-02-25 05:49:24 -05:00
|
|
|
publicApiRouter.get('/status', (req, res) => {
|
|
|
|
if (!Settings.siteIsOpen) {
|
2022-01-17 05:19:53 -05:00
|
|
|
plainTextResponse(res, 'web site is closed (web)')
|
2021-02-25 05:49:24 -05:00
|
|
|
} else if (!Settings.editorIsOpen) {
|
2022-01-17 05:19:53 -05:00
|
|
|
plainTextResponse(res, 'web editor is closed (web)')
|
2021-02-25 05:49:24 -05:00
|
|
|
} else {
|
2022-01-17 05:19:53 -05:00
|
|
|
plainTextResponse(res, 'web sharelatex is alive (web)')
|
2021-02-25 05:49:24 -05:00
|
|
|
}
|
|
|
|
})
|
2022-01-17 05:19:53 -05:00
|
|
|
privateApiRouter.get('/status', (req, res) => {
|
|
|
|
plainTextResponse(res, 'web sharelatex is alive (api)')
|
|
|
|
})
|
2019-08-06 08:20:52 -04:00
|
|
|
|
2019-11-04 06:43:28 -05:00
|
|
|
// used by kubernetes health-check and acceptance tests
|
2022-01-17 05:19:53 -05:00
|
|
|
webRouter.get('/dev/csrf', (req, res) => {
|
|
|
|
plainTextResponse(res, res.locals.csrfToken)
|
|
|
|
})
|
2019-08-06 08:20:52 -04:00
|
|
|
|
2020-07-09 09:28:46 -04:00
|
|
|
publicApiRouter.get(
|
|
|
|
'/health_check',
|
|
|
|
HealthCheckController.checkActiveHandles,
|
|
|
|
HealthCheckController.check
|
|
|
|
)
|
|
|
|
privateApiRouter.get(
|
|
|
|
'/health_check',
|
|
|
|
HealthCheckController.checkActiveHandles,
|
|
|
|
HealthCheckController.checkApi
|
|
|
|
)
|
2021-05-31 12:59:51 -04:00
|
|
|
publicApiRouter.get(
|
|
|
|
'/health_check/api',
|
|
|
|
HealthCheckController.checkActiveHandles,
|
|
|
|
HealthCheckController.checkApi
|
|
|
|
)
|
|
|
|
privateApiRouter.get(
|
|
|
|
'/health_check/api',
|
|
|
|
HealthCheckController.checkActiveHandles,
|
|
|
|
HealthCheckController.checkApi
|
|
|
|
)
|
2020-12-02 05:16:16 -05:00
|
|
|
publicApiRouter.get(
|
|
|
|
'/health_check/full',
|
|
|
|
HealthCheckController.checkActiveHandles,
|
|
|
|
HealthCheckController.check
|
|
|
|
)
|
|
|
|
privateApiRouter.get(
|
|
|
|
'/health_check/full',
|
|
|
|
HealthCheckController.checkActiveHandles,
|
|
|
|
HealthCheckController.check
|
|
|
|
)
|
2019-08-06 08:20:52 -04:00
|
|
|
|
|
|
|
publicApiRouter.get('/health_check/redis', HealthCheckController.checkRedis)
|
|
|
|
privateApiRouter.get('/health_check/redis', HealthCheckController.checkRedis)
|
|
|
|
|
|
|
|
publicApiRouter.get('/health_check/mongo', HealthCheckController.checkMongo)
|
|
|
|
privateApiRouter.get('/health_check/mongo', HealthCheckController.checkMongo)
|
|
|
|
|
|
|
|
webRouter.get(
|
|
|
|
'/status/compiler/:Project_id',
|
2020-05-20 10:19:28 -04:00
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'status-compiler',
|
|
|
|
maxRequests: 10,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2020-05-20 10:19:28 -04:00
|
|
|
}),
|
2019-08-06 08:20:52 -04:00
|
|
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
2021-04-14 09:17:21 -04:00
|
|
|
function (req, res) {
|
2019-08-06 08:20:52 -04:00
|
|
|
const projectId = req.params.Project_id
|
2021-04-14 09:17:21 -04:00
|
|
|
const sendRes = _.once(function (statusCode, message) {
|
2019-08-06 08:20:52 -04:00
|
|
|
res.status(statusCode)
|
2022-01-17 05:19:53 -05:00
|
|
|
plainTextResponse(res, message)
|
2019-08-06 08:20:52 -04:00
|
|
|
ClsiCookieManager.clearServerId(projectId)
|
|
|
|
}) // force every compile to a new server
|
|
|
|
// set a timeout
|
2021-10-26 04:08:56 -04:00
|
|
|
let handler = setTimeout(function () {
|
2019-08-06 08:20:52 -04:00
|
|
|
sendRes(500, 'Compiler timed out')
|
|
|
|
handler = null
|
|
|
|
}, 10000)
|
|
|
|
// use a valid user id for testing
|
|
|
|
const testUserId = '123456789012345678901234'
|
|
|
|
// run the compile
|
2021-04-14 09:17:21 -04:00
|
|
|
CompileManager.compile(
|
|
|
|
projectId,
|
|
|
|
testUserId,
|
|
|
|
{},
|
|
|
|
function (error, status) {
|
|
|
|
if (handler) {
|
|
|
|
clearTimeout(handler)
|
|
|
|
}
|
|
|
|
if (error) {
|
|
|
|
sendRes(500, `Compiler returned error ${error.message}`)
|
|
|
|
} else if (status === 'success') {
|
|
|
|
sendRes(200, 'Compiler returned in less than 10 seconds')
|
|
|
|
} else {
|
|
|
|
sendRes(500, `Compiler returned failure ${status}`)
|
|
|
|
}
|
2019-08-06 08:20:52 -04:00
|
|
|
}
|
2021-04-14 09:17:21 -04:00
|
|
|
)
|
2019-08-06 08:20:52 -04:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
webRouter.get('/no-cache', function (req, res, next) {
|
2019-08-06 08:20:52 -04:00
|
|
|
res.header('Cache-Control', 'max-age=0')
|
|
|
|
res.sendStatus(404)
|
|
|
|
})
|
|
|
|
|
|
|
|
webRouter.get('/oops-express', (req, res, next) =>
|
|
|
|
next(new Error('Test error'))
|
|
|
|
)
|
2021-04-14 09:17:21 -04:00
|
|
|
webRouter.get('/oops-internal', function (req, res, next) {
|
2019-08-06 08:20:52 -04:00
|
|
|
throw new Error('Test error')
|
|
|
|
})
|
|
|
|
webRouter.get('/oops-mongo', (req, res, next) =>
|
2021-04-14 09:17:21 -04:00
|
|
|
require('./models/Project').Project.findOne({}, function () {
|
2019-08-06 08:20:52 -04:00
|
|
|
throw new Error('Test error')
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
2019-08-06 08:20:52 -04:00
|
|
|
)
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
privateApiRouter.get('/opps-small', function (req, res, next) {
|
2019-08-06 08:20:52 -04:00
|
|
|
logger.err('test error occured')
|
2020-05-06 06:02:16 -04:00
|
|
|
res.sendStatus(200)
|
2019-08-06 08:20:52 -04:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
webRouter.post('/error/client', function (req, res, next) {
|
2019-08-06 08:20:52 -04:00
|
|
|
logger.warn(
|
|
|
|
{ err: req.body.error, meta: req.body.meta },
|
|
|
|
'client side error'
|
|
|
|
)
|
|
|
|
metrics.inc('client-side-error')
|
|
|
|
res.sendStatus(204)
|
|
|
|
})
|
|
|
|
|
|
|
|
webRouter.get(
|
2020-02-25 04:39:53 -05:00
|
|
|
`/read/:token(${TokenAccessController.READ_ONLY_TOKEN_PATTERN})`,
|
2019-08-06 08:20:52 -04:00
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'read-only-token',
|
|
|
|
maxRequests: 15,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
2021-09-23 05:02:39 -04:00
|
|
|
AnalyticsRegistrationSourceMiddleware.setSource(
|
|
|
|
'collaboration',
|
|
|
|
'link-sharing'
|
|
|
|
),
|
2021-06-10 04:04:11 -04:00
|
|
|
TokenAccessController.tokenAccessPage,
|
|
|
|
AnalyticsRegistrationSourceMiddleware.clearSource()
|
2019-08-06 08:20:52 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.get(
|
2020-02-25 04:39:53 -05:00
|
|
|
`/:token(${TokenAccessController.READ_AND_WRITE_TOKEN_PATTERN})`,
|
2019-08-06 08:20:52 -04:00
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'read-and-write-token',
|
|
|
|
maxRequests: 15,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-08-06 08:20:52 -04:00
|
|
|
}),
|
2021-09-23 05:02:39 -04:00
|
|
|
AnalyticsRegistrationSourceMiddleware.setSource(
|
|
|
|
'collaboration',
|
|
|
|
'link-sharing'
|
|
|
|
),
|
2021-06-10 04:04:11 -04:00
|
|
|
TokenAccessController.tokenAccessPage,
|
|
|
|
AnalyticsRegistrationSourceMiddleware.clearSource()
|
2020-02-25 04:39:53 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.post(
|
|
|
|
`/:token(${TokenAccessController.READ_AND_WRITE_TOKEN_PATTERN})/grant`,
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'grant-token-access-read-write',
|
|
|
|
maxRequests: 10,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2020-02-25 04:39:53 -05:00
|
|
|
}),
|
|
|
|
TokenAccessController.grantTokenAccessReadAndWrite
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.post(
|
|
|
|
`/read/:token(${TokenAccessController.READ_ONLY_TOKEN_PATTERN})/grant`,
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'grant-token-access-read-only',
|
|
|
|
maxRequests: 10,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2020-02-25 04:39:53 -05:00
|
|
|
}),
|
|
|
|
TokenAccessController.grantTokenAccessReadOnly
|
2019-08-06 08:20:52 -04:00
|
|
|
)
|
|
|
|
|
2021-04-28 04:48:58 -04:00
|
|
|
webRouter.get('/unsupported-browser', renderUnsupportedBrowserPage)
|
2021-04-16 04:36:46 -04:00
|
|
|
|
2019-08-06 08:20:52 -04:00
|
|
|
webRouter.get('*', ErrorController.notFound)
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|