X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fstatic.ts;h=75e30353c37a868df3398b482ae4abcf9ddb54d1;hb=be0f59b4eec3c2c4dcd151e2b174be39dff1568e;hp=3ccf624a76832c643dd37293db75351afa951631;hpb=a8bf1d826e379dec03d25840c7c49c1f30168380;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/static.ts b/server/controllers/static.ts index 3ccf624a7..75e30353c 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts @@ -1,6 +1,6 @@ import * as cors from 'cors' import * as express from 'express' -import { CONFIG, STATIC_DOWNLOAD_PATHS, STATIC_MAX_AGE, STATIC_PATHS, ROUTE_CACHE_LIFETIME } from '../initializers' +import { CONFIG, ROUTE_CACHE_LIFETIME, STATIC_DOWNLOAD_PATHS, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers' import { VideosPreviewCache } from '../lib/cache' import { cacheRoute } from '../middlewares/cache' import { asyncMiddleware, videosGetValidator } from '../middlewares' @@ -8,7 +8,9 @@ import { VideoModel } from '../models/video/video' import { VideosCaptionCache } from '../lib/cache/videos-caption-cache' import { UserModel } from '../models/account/user' import { VideoCommentModel } from '../models/video/video-comment' -import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../models/nodeinfo' +import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo' +import { join } from 'path' +import { root } from '../helpers/core-utils' const packageJSON = require('../../../package.json') const staticRouter = express.Router() @@ -78,6 +80,21 @@ staticRouter.get('/robots.txt', } ) +// security.txt service +staticRouter.get('/security.txt', + (_, res: express.Response) => { + return res.redirect(301, '/.well-known/security.txt') + } +) + +staticRouter.get('/.well-known/security.txt', + asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.SECURITYTXT)), + (_, res: express.Response) => { + res.type('text/plain') + return res.send(CONFIG.INSTANCE.SECURITYTXT + CONFIG.INSTANCE.SECURITYTXT_CONTACT) + } +) + // nodeinfo service staticRouter.use('/.well-known/nodeinfo', asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.NODEINFO)), @@ -93,10 +110,27 @@ staticRouter.use('/.well-known/nodeinfo', } ) staticRouter.use('/nodeinfo/:version.json', - // asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.NODEINFO)), + asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.NODEINFO)), asyncMiddleware(generateNodeinfo) ) +// dnt-policy.txt service (see https://www.eff.org/dnt-policy) +staticRouter.use('/.well-known/dnt-policy.txt', + asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.DNT_POLICY)), + (_, res: express.Response) => { + res.type('text/plain') + + return res.sendFile(join(root(), 'dist/server/static/dnt-policy/dnt-policy-1.0.txt')) + } +) + +// dnt service (see https://www.w3.org/TR/tracking-dnt/#status-resource) +staticRouter.use('/.well-known/dnt/', + (_, res: express.Response) => { + res.json({ tracking: 'N' }) + } +) + // --------------------------------------------------------------------------- export {