1
0
Fork 0
peertube/server/controllers/webfinger.ts
Lucien A 9878d1ac63
Fix CSP issue on WebFinger service (#2541)
* Fix CSP issue on WebFinger service

WebFinger RFC states that CSP should allow any origin to access WebFinger resources.

* Update webfinger.ts
2020-03-11 08:46:03 +01:00

39 lines
894 B
TypeScript

import * as cors from 'cors'
import * as express from 'express'
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
}
]
}
return res.json(json)
}