in api/v1/src/lib/auth.js [23:42]
async function verifyProject(req, res, next) {
const projectId = req.header('x-gcp-project-id');
const currentProjectId = await runtimeConfig.getCurrentProjectId();
if (projectId) {
const managedProjects = await runtimeConfig.getManagedProjects();
const isDefined = managedProjects != null && managedProjects.length > 0;
if (isDefined === true && !managedProjects.includes(projectId)) {
console.warn(`Invalid unmanaged project called: ${projectId}`);
return res
.status(401)
.send({ error: 'You are not authorized to make this project request' });
} else if (isDefined === false && projectId !== currentProjectId) {
console.warn(`Invalid project called: ${projectId}, currentProjectId: ${currentProjectId}`);
return res
.status(401)
.send({ error: 'You are not authorized to make this project request' });
}
}
return next();
}