1
0
Fork 0

Move webfinger controller in well known router

This commit is contained in:
Chocobozzz 2023-02-15 16:36:04 +01:00
parent 2a950cde89
commit 5bfe684e76
No known key found for this signature in database
GPG key ID: 583A612D890159BE
4 changed files with 30 additions and 48 deletions

View file

@ -109,7 +109,6 @@ import {
servicesRouter,
objectStorageProxyRouter,
pluginsRouter,
webfingerRouter,
trackerRouter,
createWebsocketTrackerServer,
botsRouter,
@ -231,7 +230,6 @@ app.use('/', pluginsRouter)
app.use('/', activityPubRouter)
app.use('/', feedsRouter)
app.use('/', webfingerRouter)
app.use('/', trackerRouter)
app.use('/', botsRouter)

View file

@ -11,5 +11,4 @@ export * from './plugins'
export * from './services'
export * from './static'
export * from './tracker'
export * from './webfinger'
export * from './well-known'

View file

@ -1,44 +0,0 @@
import cors from 'cors'
import express from 'express'
import { WEBSERVER } from '@server/initializers/constants'
import { asyncMiddleware } from '../middlewares'
import { webfingerValidator } from '../middlewares/validators'
const webfingerRouter = express.Router()
webfingerRouter.use(cors())
webfingerRouter.get('/.well-known/webfinger',
asyncMiddleware(webfingerValidator),
webfingerController
)
// ---------------------------------------------------------------------------
export {
webfingerRouter
}
// ---------------------------------------------------------------------------
function webfingerController (req: express.Request, res: express.Response) {
const actor = res.locals.actorUrl
const json = {
subject: req.query.resource,
aliases: [ actor.url ],
links: [
{
rel: 'self',
type: 'application/activity+json',
href: actor.url
},
{
rel: 'http://ostatus.org/schema/1.0/subscribe',
template: WEBSERVER.URL + '/remote-interaction?uri={uri}'
}
]
}
return res.json(json)
}

View file

@ -1,16 +1,21 @@
import cors from 'cors'
import express from 'express'
import { join } from 'path'
import { asyncMiddleware, handleStaticError, webfingerValidator } from '@server/middlewares'
import { root } from '@shared/core-utils'
import { CONFIG } from '../initializers/config'
import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
import { cacheRoute } from '../middlewares/cache/cache'
import { handleStaticError } from '@server/middlewares'
const wellKnownRouter = express.Router()
wellKnownRouter.use(cors())
wellKnownRouter.get('/.well-known/webfinger',
asyncMiddleware(webfingerValidator),
webfingerController
)
wellKnownRouter.get('/.well-known/security.txt',
cacheRoute(ROUTE_CACHE_LIFETIME.SECURITYTXT),
(_, res: express.Response) => {
@ -81,3 +86,27 @@ wellKnownRouter.use('/.well-known/',
export {
wellKnownRouter
}
// ---------------------------------------------------------------------------
function webfingerController (req: express.Request, res: express.Response) {
const actor = res.locals.actorUrl
const json = {
subject: req.query.resource,
aliases: [ actor.url ],
links: [
{
rel: 'self',
type: 'application/activity+json',
href: actor.url
},
{
rel: 'http://ostatus.org/schema/1.0/subscribe',
template: WEBSERVER.URL + '/remote-interaction?uri={uri}'
}
]
}
return res.json(json)
}