Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 5 additions & 3 deletions supabase/functions/_backend/utils/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,17 @@ export async function apikeyHasOrgRightWithPolicy(
c: Context,
key: Database['public']['Tables']['apikeys']['Row'],
orgId: string,
supabase: SupabaseClient<Database>,
_supabase: SupabaseClient<Database>,
): Promise<{ valid: boolean, error?: string }> {
// First check basic org access
if (!apikeyHasOrgRight(key, orgId)) {
return { valid: false, error: 'invalid_org_id' }
}

// Then check if org requires expiring keys
const policyCheck = await checkApikeyMeetsOrgPolicy(c, key, orgId, supabase)
// Then check if org requires expiring keys. The scope check above proves the
// key is org-scoped; use service role for the policy lookup so runtime
// permission denials for non-expiring keys do not hide the policy row.
const policyCheck = await checkApikeyMeetsOrgPolicy(c, key, orgId, supabaseAdmin(c))
if (!policyCheck.valid) {
return policyCheck
}
Expand Down
Loading
Loading