aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server.ts2
-rw-r--r--server/controllers/index.ts1
-rw-r--r--server/controllers/webfinger.ts44
-rw-r--r--server/controllers/well-known.ts31
4 files changed, 30 insertions, 48 deletions
diff --git a/server.ts b/server.ts
index f6a153fb7..d1ac2d092 100644
--- a/server.ts
+++ b/server.ts
@@ -109,7 +109,6 @@ import {
109 servicesRouter, 109 servicesRouter,
110 objectStorageProxyRouter, 110 objectStorageProxyRouter,
111 pluginsRouter, 111 pluginsRouter,
112 webfingerRouter,
113 trackerRouter, 112 trackerRouter,
114 createWebsocketTrackerServer, 113 createWebsocketTrackerServer,
115 botsRouter, 114 botsRouter,
@@ -231,7 +230,6 @@ app.use('/', pluginsRouter)
231 230
232app.use('/', activityPubRouter) 231app.use('/', activityPubRouter)
233app.use('/', feedsRouter) 232app.use('/', feedsRouter)
234app.use('/', webfingerRouter)
235app.use('/', trackerRouter) 233app.use('/', trackerRouter)
236app.use('/', botsRouter) 234app.use('/', botsRouter)
237 235
diff --git a/server/controllers/index.ts b/server/controllers/index.ts
index eaa2dd7c8..09d657aca 100644
--- a/server/controllers/index.ts
+++ b/server/controllers/index.ts
@@ -11,5 +11,4 @@ export * from './plugins'
11export * from './services' 11export * from './services'
12export * from './static' 12export * from './static'
13export * from './tracker' 13export * from './tracker'
14export * from './webfinger'
15export * from './well-known' 14export * from './well-known'
diff --git a/server/controllers/webfinger.ts b/server/controllers/webfinger.ts
deleted file mode 100644
index 29ce01166..000000000
--- a/server/controllers/webfinger.ts
+++ /dev/null
@@ -1,44 +0,0 @@
1import cors from 'cors'
2import express from 'express'
3import { WEBSERVER } from '@server/initializers/constants'
4import { asyncMiddleware } from '../middlewares'
5import { webfingerValidator } from '../middlewares/validators'
6
7const webfingerRouter = express.Router()
8
9webfingerRouter.use(cors())
10
11webfingerRouter.get('/.well-known/webfinger',
12 asyncMiddleware(webfingerValidator),
13 webfingerController
14)
15
16// ---------------------------------------------------------------------------
17
18export {
19 webfingerRouter
20}
21
22// ---------------------------------------------------------------------------
23
24function webfingerController (req: express.Request, res: express.Response) {
25 const actor = res.locals.actorUrl
26
27 const json = {
28 subject: req.query.resource,
29 aliases: [ actor.url ],
30 links: [
31 {
32 rel: 'self',
33 type: 'application/activity+json',
34 href: actor.url
35 },
36 {
37 rel: 'http://ostatus.org/schema/1.0/subscribe',
38 template: WEBSERVER.URL + '/remote-interaction?uri={uri}'
39 }
40 ]
41 }
42
43 return res.json(json)
44}
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}