Use consistent error codes for authorization errors from transaction (#10040)

Signed-off-by: Nikolay Marchuk <nikolay.marchuk@hardcoreeng.com>
This commit is contained in:
Nikolay Marchuk
2025-10-08 01:01:29 +07:00
committed by GitHub
parent 8ea9944354
commit bdc0bbc51a
2 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -163,7 +163,7 @@ export function registerRPC (app: Express, sessions: SessionManager, ctx: Measur
const decodedToken = decodeToken(token)
if (workspaceId !== decodedToken.workspace) {
sendError(res, 401, { message: 'Invalid workspace', workspace: decodedToken.workspace })
sendError(res, 403, { message: 'Invalid workspace', workspace: decodedToken.workspace })
return
}
@@ -173,7 +173,7 @@ export function registerRPC (app: Express, sessions: SessionManager, ctx: Measur
const cs: ConnectionSocket = createClosingSocket(token, rpcSessions)
const s = await sessions.addSession(ctx, cs, decodedToken, token, token)
if (!('session' in s)) {
sendError(res, 401, {
sendError(res, 403, {
message: 'Failed to create session',
mode: 'specialError' in s ? s.specialError ?? '' : 'upgrading'
})
+4 -4
View File
@@ -321,7 +321,7 @@ export function startHttpServer (
try {
const authHeader = req.headers.authorization
if (authHeader === undefined) {
res.status(403).end(JSON.stringify({ error: 'Unauthorized' }))
res.status(401).end(JSON.stringify({ error: 'Unauthorized' }))
return
}
@@ -329,7 +329,7 @@ export function startHttpServer (
const wsIds = await getWorkspaceIds(token)
if (wsIds.uuid == null) {
res.status(401).end(JSON.stringify({ error: 'No workspace found' }))
res.status(403).end(JSON.stringify({ error: 'No workspace found' }))
return
}
@@ -390,7 +390,7 @@ export function startHttpServer (
try {
const authHeader = req.headers.authorization
if (authHeader === undefined) {
res.status(403).send({ error: 'Unauthorized' })
res.status(401).send({ error: 'Unauthorized' })
return
}
@@ -398,7 +398,7 @@ export function startHttpServer (
const wsIds = await getWorkspaceIds(token)
if (wsIds.uuid == null) {
res.status(401).send({ error: 'No workspace found' })
res.status(403).send({ error: 'No workspace found' })
}
const name = req.query.name as string