parity(functions): never send new-format API key as Authorization Bearer [from supabase-js]

Open
#279 2 comments 0 reactions 1 assignee View on GitHub

@Tr00d is already working on this.

Since Jul 17, 2026.

Assessment

This issue has not been assessed yet.

Description

bug parity

SDK Parity: C# implementation needed

A change was made in supabase-js that needs to be implemented in this repository for SDK parity.

Reference Implementation (supabase-js)

  • Commit: 558c1f5
  • PR: #2511
  • Module: functions / client
  • Type: bug-fix (security-relevant)
What Changed

New-format API keys (sb_publishable_… / sb_secret_…) must never be sent as a Bearer token. Edge Functions calls now use a dedicated fetch path where apikey always carries the key and Authorization only carries a real session JWT — with no session and a new-format key, no Bearer key fallback is sent. Legacy JWT keys are unaffected.

Code Reference
this.functionsFetch = fetchWithAuth(
  supabaseKey, supabaseUrl, this._getSessionToken.bind(this),
  settings.global.fetch, settings.tracePropagation,
  { omitApiKeyAsBearer: true }
)

Confirmed in supabase-csharp: Supabase/Client.cs:256-275 GetAuthHeaders() sets bearer = Auth.CurrentSession?.AccessToken ?? _supabaseKey and Authorization: Bearer {bearer} when there's no session — meaning the raw Supabase key (including new-format sb_publishable_/sb_secret_) is sent as the Bearer token whenever no session exists. This is the exact bug supabase-js fixed, and it applies to Functions invoke() as well since it shares this header path.

Implementation Guidance

Expected API Surface

Functions invoke path needs its own header-resolution logic distinct from REST/Storage: apikey always carries the key; Authorization only carries a session JWT, never a new-format key. Legacy JWT keys keep existing Bearer fallback.

Acceptance Criteria

  • Fix implemented matching supabase-js behavior
  • Unit tests cover: no-session+new-key, no-session+legacy-key, has-session
  • No breaking changes to existing legacy-key behavior

Context

  • supabase-js version: v3.0.0-next.29 / 2.110.6
  • Parity tracking: This issue was auto-generated by SDK parity analysis
  • Related parity issues: supabase-flutter (SDK-1320), supabase-py (SDK-1325), supabase-swift (SDK-1329), supabase-kt (#1357)

Generated with Claude Code /sync-sdk-parity

Dominant language
C#
Stars
701
Forks
106
Avg merge
16h 35m
Merged PRs (30d)
45

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from supabase/supabase-csharp

All issues in supabase/supabase-csharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.