mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-21 00:02:30 +00:00
fix: fail open when whoami resolves without a role
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L99mAR4LitqTcYY1Kn1ATH
This commit is contained in:
co-authored by
Claude Opus 5
parent
5f7ec4e2c0
commit
c5e4d0100e
@@ -83,4 +83,10 @@ describe('resolveSessionAccess', () => {
|
||||
expect(access.capabilities.has('write_draft')).toBe(true)
|
||||
expect(access.capabilities.has('deploy')).toBe(true)
|
||||
})
|
||||
|
||||
it('fails open on a body that resolves without a role, rather than throwing', async () => {
|
||||
whoami.mockResolvedValueOnce(undefined)
|
||||
const access = await resolveSessionAccess('ws')
|
||||
expect(access.capabilities.has('write_draft')).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -42,10 +42,14 @@ export function hasCapabilities(
|
||||
}
|
||||
|
||||
export async function resolveSessionAccess(workspace: string): Promise<SessionAccess> {
|
||||
let me: User
|
||||
let me: User | undefined
|
||||
try {
|
||||
me = await UserService.whoami({ workspace })
|
||||
} catch {
|
||||
} catch {}
|
||||
// Checked rather than trusted: a body that arrives malformed resolves without
|
||||
// throwing, and reading a capability off it would surface as a TypeError thrown
|
||||
// out of the send rather than as the fail-open this whole path promises.
|
||||
if (!me) {
|
||||
return fullSessionAccess(workspace)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user