aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/well-known.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/well-known.ts')
-rw-r--r--server/controllers/well-known.ts31
1 files changed, 30 insertions, 1 deletions
diff --git a/server/controllers/well-known.ts b/server/controllers/well-known.ts
index ce5883571..bb9acfb37 100644
--- a/server/controllers/well-known.ts
+++ b/server/controllers/well-known.ts
@@ -1,16 +1,21 @@
1import cors from 'cors' 1import cors from 'cors'
2import express from 'express' 2import express from 'express'
3import { join } from 'path' 3import { join } from 'path'
4import { asyncMiddleware, handleStaticError, webfingerValidator } from '@server/middlewares'
4import { root } from '@shared/core-utils' 5import { root } from '@shared/core-utils'
5import { CONFIG } from '../initializers/config' 6import { CONFIG } from '../initializers/config'
6import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' 7import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
7import { cacheRoute } from '../middlewares/cache/cache' 8import { cacheRoute } from '../middlewares/cache/cache'
8import { handleStaticError } from '@server/middlewares'
9 9
10const wellKnownRouter = express.Router() 10const wellKnownRouter = express.Router()
11 11
12wellKnownRouter.use(cors()) 12wellKnownRouter.use(cors())
13 13
14wellKnownRouter.get('/.well-known/webfinger',
15 asyncMiddleware(webfingerValidator),
16 webfingerController
17)
18
14wellKnownRouter.get('/.well-known/security.txt', 19wellKnownRouter.get('/.well-known/security.txt',
15 cacheRoute(ROUTE_CACHE_LIFETIME.SECURITYTXT), 20 cacheRoute(ROUTE_CACHE_LIFETIME.SECURITYTXT),
16 (_, res: express.Response) => { 21 (_, res: express.Response) => {
@@ -81,3 +86,27 @@ wellKnownRouter.use('/.well-known/',
81export { 86export {
82 wellKnownRouter 87 wellKnownRouter
83} 88}
89
90// ---------------------------------------------------------------------------
91
92function webfingerController (req: express.Request, res: express.Response) {
93 const actor = res.locals.actorUrl
94
95 const json = {
96 subject: req.query.resource,
97 aliases: [ actor.url ],
98 links: [
99 {
100 rel: 'self',
101 type: 'application/activity+json',
102 href: actor.url
103 },
104 {
105 rel: 'http://ostatus.org/schema/1.0/subscribe',
106 template: WEBSERVER.URL + '/remote-interaction?uri={uri}'
107 }
108 ]
109 }
110
111 return res.json(json)
112}