mirror of
https://codeberg.org/keyoxide/keyoxide-web.git
synced 2024-12-22 14:59:29 -07:00
feat: escape parameters
This commit is contained in:
parent
785647bbb8
commit
255e99af39
1 changed files with 97 additions and 74 deletions
|
@ -28,6 +28,7 @@ if any, to sign a "copyright disclaimer" for the program, if necessary. For
|
||||||
more information on this, and how to apply and follow the GNU AGPL, see <https://www.gnu.org/licenses/>.
|
more information on this, and how to apply and follow the GNU AGPL, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import express from 'express'
|
import express from 'express'
|
||||||
|
import { param } from 'express-validator'
|
||||||
import bodyParserImport from 'body-parser'
|
import bodyParserImport from 'body-parser'
|
||||||
import { rateLimit } from 'express-rate-limit'
|
import { rateLimit } from 'express-rate-limit'
|
||||||
import { generateSignatureProfile, utils, generateWKDProfile, generateHKPProfile, generateAutoProfile, generateKeybaseProfile } from '../server/index.js'
|
import { generateSignatureProfile, utils, generateWKDProfile, generateHKPProfile, generateAutoProfile, generateKeybaseProfile } from '../server/index.js'
|
||||||
|
@ -60,90 +61,112 @@ if (process.env.ENABLE_EXPERIMENTAL_RATE_LIMITER) {
|
||||||
{ component: 'profile_rate_limiter', action: 'start' })
|
{ component: 'profile_rate_limiter', action: 'start' })
|
||||||
}
|
}
|
||||||
|
|
||||||
router.get('/sig', profileRateLimiter, (req, res) => {
|
router.get('/sig',
|
||||||
res.render('profile', { isSignature: true, signature: null, meta: getMetaFromReq(req) })
|
profileRateLimiter,
|
||||||
})
|
(req, res) => {
|
||||||
|
res.render('profile', { isSignature: true, signature: null, meta: getMetaFromReq(req) })
|
||||||
router.post('/sig', profileRateLimiter, bodyParser, async (req, res) => {
|
|
||||||
const data = await generateSignatureProfile(req.body.signature)
|
|
||||||
const title = utils.generatePageTitle('profile', data)
|
|
||||||
res.set('ariadne-identity-proof', data.identifier)
|
|
||||||
res.render('profile', {
|
|
||||||
title,
|
|
||||||
data: data instanceof Profile ? data.toJSON() : data,
|
|
||||||
isSignature: true,
|
|
||||||
signature: req.body.signature,
|
|
||||||
enable_message_encryption: false,
|
|
||||||
enable_signature_verification: false,
|
|
||||||
meta: getMetaFromReq(req)
|
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
router.get('/wkd/:id', profileRateLimiter, async (req, res) => {
|
router.post('/sig',
|
||||||
const data = await generateWKDProfile(req.params.id)
|
profileRateLimiter,
|
||||||
const title = utils.generatePageTitle('profile', data)
|
bodyParser,
|
||||||
res.set('ariadne-identity-proof', data.identifier)
|
async (req, res) => {
|
||||||
res.render('profile', {
|
const data = await generateSignatureProfile(req.body.signature)
|
||||||
title,
|
const title = utils.generatePageTitle('profile', data)
|
||||||
data: data instanceof Profile ? data.toJSON() : data,
|
res.set('ariadne-identity-proof', data.identifier)
|
||||||
enable_message_encryption: false,
|
res.render('profile', {
|
||||||
enable_signature_verification: false,
|
title,
|
||||||
meta: getMetaFromReq(req)
|
data: data instanceof Profile ? data.toJSON() : data,
|
||||||
|
isSignature: true,
|
||||||
|
signature: req.body.signature,
|
||||||
|
enable_message_encryption: false,
|
||||||
|
enable_signature_verification: false,
|
||||||
|
meta: getMetaFromReq(req)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
router.get('/hkp/:id', profileRateLimiter, async (req, res) => {
|
router.get('/wkd/:id',
|
||||||
const data = await generateHKPProfile(req.params.id)
|
profileRateLimiter,
|
||||||
const title = utils.generatePageTitle('profile', data)
|
param('id').escape(),
|
||||||
res.set('ariadne-identity-proof', data.identifier)
|
async (req, res) => {
|
||||||
res.render('profile', {
|
const data = await generateWKDProfile(req.params.id)
|
||||||
title,
|
const title = utils.generatePageTitle('profile', data)
|
||||||
data: data instanceof Profile ? data.toJSON() : data,
|
res.set('ariadne-identity-proof', data.identifier)
|
||||||
enable_message_encryption: false,
|
res.render('profile', {
|
||||||
enable_signature_verification: false,
|
title,
|
||||||
meta: getMetaFromReq(req)
|
data: data instanceof Profile ? data.toJSON() : data,
|
||||||
|
enable_message_encryption: false,
|
||||||
|
enable_signature_verification: false,
|
||||||
|
meta: getMetaFromReq(req)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
router.get('/hkp/:server/:id', profileRateLimiter, async (req, res) => {
|
router.get('/hkp/:id',
|
||||||
const data = await generateHKPProfile(req.params.id, req.params.server)
|
profileRateLimiter,
|
||||||
const title = utils.generatePageTitle('profile', data)
|
param('id').escape(),
|
||||||
res.set('ariadne-identity-proof', data.identifier)
|
async (req, res) => {
|
||||||
res.render('profile', {
|
const data = await generateHKPProfile(req.params.id)
|
||||||
title,
|
const title = utils.generatePageTitle('profile', data)
|
||||||
data: data instanceof Profile ? data.toJSON() : data,
|
res.set('ariadne-identity-proof', data.identifier)
|
||||||
enable_message_encryption: false,
|
res.render('profile', {
|
||||||
enable_signature_verification: false,
|
title,
|
||||||
meta: getMetaFromReq(req)
|
data: data instanceof Profile ? data.toJSON() : data,
|
||||||
|
enable_message_encryption: false,
|
||||||
|
enable_signature_verification: false,
|
||||||
|
meta: getMetaFromReq(req)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
router.get('/keybase/:username/:fingerprint', profileRateLimiter, async (req, res) => {
|
router.get('/hkp/:server/:id',
|
||||||
const data = await generateKeybaseProfile(req.params.username, req.params.fingerprint)
|
profileRateLimiter,
|
||||||
const title = utils.generatePageTitle('profile', data)
|
param('server').escape(),
|
||||||
res.set('ariadne-identity-proof', data.identifier)
|
param('id').escape(),
|
||||||
res.render('profile', {
|
async (req, res) => {
|
||||||
title,
|
const data = await generateHKPProfile(req.params.id, req.params.server)
|
||||||
data: data instanceof Profile ? data.toJSON() : data,
|
const title = utils.generatePageTitle('profile', data)
|
||||||
enable_message_encryption: false,
|
res.set('ariadne-identity-proof', data.identifier)
|
||||||
enable_signature_verification: false,
|
res.render('profile', {
|
||||||
meta: getMetaFromReq(req)
|
title,
|
||||||
|
data: data instanceof Profile ? data.toJSON() : data,
|
||||||
|
enable_message_encryption: false,
|
||||||
|
enable_signature_verification: false,
|
||||||
|
meta: getMetaFromReq(req)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
router.get('/:id', profileRateLimiter, async (req, res) => {
|
router.get('/keybase/:username/:fingerprint',
|
||||||
const data = await generateAutoProfile(req.params.id)
|
profileRateLimiter,
|
||||||
const theme = generateProfileTheme(data)
|
param('username').escape(),
|
||||||
const title = utils.generatePageTitle('profile', data)
|
param('fingerprint').escape(),
|
||||||
res.set('ariadne-identity-proof', data.identifier)
|
async (req, res) => {
|
||||||
res.render('profile', {
|
const data = await generateKeybaseProfile(req.params.username, req.params.fingerprint)
|
||||||
title,
|
const title = utils.generatePageTitle('profile', data)
|
||||||
data: data instanceof Profile ? data.toJSON() : data,
|
res.set('ariadne-identity-proof', data.identifier)
|
||||||
enable_message_encryption: false,
|
res.render('profile', {
|
||||||
enable_signature_verification: false,
|
title,
|
||||||
theme,
|
data: data instanceof Profile ? data.toJSON() : data,
|
||||||
meta: getMetaFromReq(req)
|
enable_message_encryption: false,
|
||||||
|
enable_signature_verification: false,
|
||||||
|
meta: getMetaFromReq(req)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
router.get('/:id',
|
||||||
|
profileRateLimiter,
|
||||||
|
param('id').escape(),
|
||||||
|
async (req, res) => {
|
||||||
|
const data = await generateAutoProfile(req.params.id)
|
||||||
|
const theme = generateProfileTheme(data)
|
||||||
|
const title = utils.generatePageTitle('profile', data)
|
||||||
|
res.set('ariadne-identity-proof', data.identifier)
|
||||||
|
res.render('profile', {
|
||||||
|
title,
|
||||||
|
data: data instanceof Profile ? data.toJSON() : data,
|
||||||
|
enable_message_encryption: false,
|
||||||
|
enable_signature_verification: false,
|
||||||
|
theme,
|
||||||
|
meta: getMetaFromReq(req)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
|
|
Loading…
Reference in a new issue