budibase/packages/worker/src/middleware/check-key.js

12 lines
312 B
JavaScript
Raw Normal View History

const env = require("../environment")
module.exports = async (ctx, next) => {
const selfHostKey =
2021-01-14 18:02:05 +01:00
ctx.request.headers["x-budibase-auth"] || ctx.request.body.selfHostKey
if (!selfHostKey || env.SELF_HOST_KEY !== selfHostKey) {
ctx.throw(401, "Request unauthorised")
} else {
await next()
}
}