aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-02-15 16:36:04 +0100
committerChocobozzz <me@florianbigard.com>2023-02-15 16:36:04 +0100
commit5bfe684e76d32a7745671635f8a75f932bd522e4 (patch)
tree2da9c6607d1032c288417765ccb5145c9dc13ca7 /server/controllers
parent2a950cde896fdf8baa804ce2349f4db21cae5034 (diff)
downloadPeerTube-5bfe684e76d32a7745671635f8a75f932bd522e4.tar.gz
PeerTube-5bfe684e76d32a7745671635f8a75f932bd522e4.tar.zst
PeerTube-5bfe684e76d32a7745671635f8a75f932bd522e4.zip
Move webfinger controller in well known router
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/index.ts1
-rw-r--r--server/controllers/webfinger.ts44
-rw-r--r--server/controllers/well-known.ts31
3 files changed, 30 insertions, 46 deletions
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}