Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use 403 for authorization errors [HUB-158] #742

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions server/src/routes/v1/apps/handlers/createApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = {
},
handler: async (request, h) => {
if (!canCreateApp(request, h)) {
throw Boom.unauthorized()
throw Boom.forbidden()
}
const { notificationService } = request.services(true)

Expand Down Expand Up @@ -75,7 +75,7 @@ module.exports = {
db
)
if (!isMember && !isManager) {
throw Boom.unauthorized(
throw Boom.forbidden(
`You don't have permission to upload apps to that organisation`
)
}
Expand Down Expand Up @@ -106,7 +106,7 @@ module.exports = {

isCoreApp = manifest.core_app
if (isCoreApp && !isManager) {
throw Boom.unauthorized(
throw Boom.forbidden(
`You don't have permission to upload core apps`
)
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/v1/apps/handlers/createAppVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = {
isManager || userApps.map(app => app.app_id).indexOf(appId) !== -1

if (!userCanEditApp) {
throw Boom.unauthorized()
throw Boom.forbidden()
}

const versionPayload = request.payload.version
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/v1/apps/handlers/deleteApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
debug(`deleteApp : ${request.params.appId}`)

if (!canDeleteApp(request, h)) {
throw Boom.unauthorized()
throw Boom.forbidden()
}
//todo: validate

Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/v1/apps/handlers/deleteAppVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = {
throw Boom.internal(err)
}
} else {
throw Boom.unauthorized()
throw Boom.forbidden()
}

//What the old v1 api responds with on this endpoint if all works out
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/v1/apps/handlers/deleteImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = {
throw Boom.internal(err)
}
} else {
throw Boom.unauthorized()
throw Boom.forbidden()
}

//What the old v1 api responds with on this endpoint if all works out
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/v1/apps/handlers/editApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module.exports = {
throw Boom.internal(err)
}
} else {
throw Boom.unauthorized()
throw Boom.forbidden()
}

//What the old v1 api responds with on this endpoint if all works out
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/v1/apps/handlers/editAppVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ module.exports = {
}
}

throw Boom.unauthorized()
throw Boom.forbidden()
},
}
2 changes: 1 addition & 1 deletion server/src/routes/v1/apps/handlers/editImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module.exports = {
throw Boom.internal(err)
}
} else {
throw Boom.unauthorized()
throw Boom.forbidden()
}

//What the old v1 api responds with on this endpoint if all works out
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/v1/apps/handlers/getAllApps.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
},
handler: async (request, h) => {
if (!canSeeAllApps(request, h)) {
throw Boom.unauthorized()
throw Boom.forbidden()
}

try {
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/v1/apps/handlers/setApprovalStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
//request.logger.info('In handler %s', request.path)

if (!canChangeAppStatus(request, h)) {
throw Boom.unauthorized()
throw Boom.forbidden()
}

const { status } = request.query
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/v1/apps/handlers/uploadImageToApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = {
if (!canUploadMedia) {
return h
.response({ message: `You don't have access to edit that app` })
.code(401)
.code(403)
}

const imageFile = request.payload.file
Expand Down
4 changes: 2 additions & 2 deletions server/src/routes/v2/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ module.exports = [
},
handler: async (request, h) => {
if (!canCreateApp(request, h)) {
throw Boom.unauthorized()
throw Boom.forbidden()
}

const { db } = h.context
Expand Down Expand Up @@ -139,7 +139,7 @@ module.exports = [
db
)
if (!isMember && !isManager) {
throw Boom.unauthorized(
throw Boom.forbidden(
`You don't have permission to upload apps to that organisation`
)
}
Expand Down
6 changes: 3 additions & 3 deletions server/src/routes/v2/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = [
request.logger.info('In handler %s', request.path)

if (!currentUserIsManager(request)) {
throw Boom.unauthorized()
throw Boom.forbidden()
}

const { name } = request.payload
Expand Down Expand Up @@ -79,7 +79,7 @@ module.exports = [
console.log(request.auth)

if (!currentUserIsManager(request)) {
throw Boom.unauthorized()
throw Boom.forbidden()
}

const { name } = request.payload
Expand Down Expand Up @@ -146,7 +146,7 @@ module.exports = [

if (!currentUserIsManager(request)) {
debug('unauthorized')
throw Boom.unauthorized()
throw Boom.forbidden()
}

const { uuid } = request.params
Expand Down
Loading