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