Update builder and authorized middleware to be more strict towards unauthenticated (#9774)
* Update builder and authorized middleware to be more strict towards unauthenticated * Remove unnecessary variable
This commit is contained in:
parent
ca90993d44
commit
6c7d6a3caa
|
@ -79,10 +79,6 @@ export default (
|
||||||
return ctx.throw(403, "No user info found")
|
return ctx.throw(403, "No user info found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// check general builder stuff, this middleware is a good way
|
|
||||||
// to find API endpoints which are builder focused
|
|
||||||
await builderMiddleware(ctx, permType)
|
|
||||||
|
|
||||||
// get the resource roles
|
// get the resource roles
|
||||||
let resourceRoles: any = []
|
let resourceRoles: any = []
|
||||||
let otherLevelRoles: any = []
|
let otherLevelRoles: any = []
|
||||||
|
@ -112,6 +108,12 @@ export default (
|
||||||
return ctx.throw(403, "Session not authenticated")
|
return ctx.throw(403, "Session not authenticated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check general builder stuff, this middleware is a good way
|
||||||
|
// to find API endpoints which are builder focused
|
||||||
|
if (permType === permissions.PermissionType.BUILDER) {
|
||||||
|
await builderMiddleware(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// check authorized
|
// check authorized
|
||||||
await checkAuthorized(ctx, resourceRoles, permType, permLevel)
|
await checkAuthorized(ctx, resourceRoles, permType, permLevel)
|
||||||
|
|
|
@ -64,13 +64,18 @@ async function updateAppUpdatedAt(ctx: BBContext) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function builder(ctx: BBContext, permType: string) {
|
export default async function builder(ctx: BBContext) {
|
||||||
const appId = ctx.appId
|
const appId = ctx.appId
|
||||||
// this only functions within an app context
|
// this only functions within an app context
|
||||||
if (!appId) {
|
if (!appId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const isBuilderApi = permType === permissions.PermissionType.BUILDER
|
|
||||||
|
// check authenticated
|
||||||
|
if (!ctx.isAuthenticated) {
|
||||||
|
return ctx.throw(403, "Session not authenticated")
|
||||||
|
}
|
||||||
|
|
||||||
const referer = ctx.headers["referer"]
|
const referer = ctx.headers["referer"]
|
||||||
|
|
||||||
const overviewPath = "/builder/portal/overview/"
|
const overviewPath = "/builder/portal/overview/"
|
||||||
|
@ -82,7 +87,7 @@ export default async function builder(ctx: BBContext, permType: string) {
|
||||||
const hasAppId = !referer ? false : referer.includes(appId)
|
const hasAppId = !referer ? false : referer.includes(appId)
|
||||||
const editingApp = referer ? hasAppId : false
|
const editingApp = referer ? hasAppId : false
|
||||||
// check this is a builder call and editing
|
// check this is a builder call and editing
|
||||||
if (!isBuilderApi || !editingApp) {
|
if (!editingApp) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// check locks
|
// check locks
|
||||||
|
|
Loading…
Reference in New Issue