Skip to content

Commit

Permalink
Change log level from info to debug in authorization middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeknovy committed Dec 10, 2024
1 parent b3e27d2 commit e914265
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/server/middleware/authorization-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { isUserAuthorizedForProject } from "../queries/user-project-access"
export const authorizationMiddleware = (allowedRoles: AllowedRoles[]) => {
return async (request, response, next) => {
const user = request.user
logger.info(`User ${user.userId} with role ${user.role} accessing a resource with allowed roles: ${allowedRoles}`)
logger.debug(`User ${user.userId} with role ${user.role} accessing a resource with allowed roles: ${allowedRoles}`)
// check project authorization
const { projectName } = request.params
if (projectName && user?.userId && user?.role !== AllowedRoles.Admin) {
logger.info(`User ${user.userId} with role ${user.role} accessing a resource within ${projectName} project`)
logger.debug(`User ${user.userId} with role ${user.role} accessing a resource within ${projectName} project`)
const userAuthorizedForProject = await db.oneOrNone(isUserAuthorizedForProject(projectName, user.userId))
if (!userAuthorizedForProject && user.role) {
logger.info(`User ${user.userId} has no access to project ${projectName}`)
logger.debug(`User ${user.userId} has no access to project ${projectName}`)
return next(boom.forbidden(`You dont have permission to access`))
}
// user is authorized, we can proceed
Expand Down

0 comments on commit e914265

Please sign in to comment.