Skip to content

feat(docs): edge functions JWT Signing Keys guide - #41444

Merged
ChrisChinchilla merged 26 commits into
supabase:masterfrom
kallebysantos:feat-edge-fn-jwt-migration-guide
Jan 5, 2026
Merged

ChrisChinchilla merged 26 commits into
supabase:masterfrom
kallebysantos:feat-edge-fn-jwt-migration-guide

Conversation

@kallebysantos

@kallebysantos kallebysantos commented Dec 17, 2025 •

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

Docs update

What is the current behaviour?

Info about JWT Signing keys is not clear enough for edge-functions

What is the new behaviour?

Improve docs, as well provide jwt template to valide the new JWT Signing keys

Additional context

previous auth integration guide was moved to /auth-legacy-jwt

Summary by CodeRabbit

  • New Features

    • Supabase Auth navigation now includes a nested submenu linking to expanded authentication guides.
  • Documentation

    • Added a new guide for legacy JWT integration with Edge Functions.
    • Revised the Edge Functions auth guide to emphasize explicit JWT verification patterns, remote JWKS flows, and secure templates.
    • Updated example snippets and middleware patterns to reflect current JWT verification best practices.

✏️ Tip: You can customize this high-level summary in your review settings.

@kallebysantos kallebysantos changed the title feat: edge functions JWT Signing Keys guide feat(docs): edge functions JWT Signing Keys guide Dec 17, 2025
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for contributing to Supabase! ❤️ Our team will review your PR.

A few tips for a smoother review process:

  • If you have a local version of the repo, run pnpm run format to make sure formatting checks pass.
  • Once we've reviewed your PR, please don't trivially merge master (don't click Update branch if there are no merge conflicts to be fixed). This invalidates any pre-merge checks we've run.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Dec 17, 2025
@vercel

vercel Bot commented Dec 17, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
design-system Ready Ready Preview, Comment Jan 5, 2026 1:11pm
docs Ready Ready Preview, Comment Jan 5, 2026 1:11pm
studio-self-hosted Ready Ready Preview, Comment Jan 5, 2026 1:11pm
studio-staging Ready Ready Preview, Comment Jan 5, 2026 1:11pm
ui-library Ready Ready Preview, Comment Jan 5, 2026 1:11pm
zone-www-dot-com Ready Ready Preview, Comment Jan 5, 2026 1:11pm
2 Skipped Deployments
Project Deployment Review Updated (UTC)
cms Ignored Ignored Preview Jan 5, 2026 1:11pm
studio Ignored Ignored Jan 5, 2026 1:11pm

@vercel

vercel Bot commented Dec 17, 2025

Copy link
Copy Markdown

@kallebysantos is attempting to deploy a commit to the Supabase Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 12

🧹 Nitpick comments (3)
examples/edge-functions/supabase/functions/_shared/jwt/default.ts (1)

12-23: Code duplication with other JWT modules.

The getAuthToken function is duplicated across default.ts, legacy-jwt.ts, and clerk.ts. Consider extracting this to a shared utility to reduce maintenance burden and ensure consistent behavior.

apps/docs/content/guides/functions/auth-legacy-jwt.mdx (1)

31-36: Non-null assertion on potentially missing header.

Using req.headers.get('Authorization')! assumes the header always exists. While this is example code, it could be misleading. Consider showing defensive handling:

-        headers: { Authorization: req.headers.get('Authorization')! },
+        headers: { Authorization: req.headers.get('Authorization') ?? '' },

Or add a guard before this line.

examples/edge-functions/supabase/functions/_shared/jwt/legacy-jwt.ts (1)

21-31: Consider handling missing JWT_SECRET more explicitly.

If JWT_SECRET is undefined, encoder.encode(undefined) will produce unexpected results. While this env var is automatically supplied by Supabase, adding a guard would make the code more defensive for local development or misconfiguration:

 async function verifyJWT(jwt: string): Promise<boolean> {
+  if (!JWT_SECRET) {
+    console.error("JWT_SECRET environment variable is not set");
+    return false;
+  }
   const encoder = new TextEncoder();
   const secretKey = encoder.encode(JWT_SECRET);
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c740f5a and 299e3f1.

📒 Files selected for processing (5)
  • apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts (1 hunks)
  • apps/docs/content/guides/functions/auth-legacy-jwt.mdx (1 hunks)
  • apps/docs/content/guides/functions/auth.mdx (1 hunks)
  • examples/edge-functions/supabase/functions/_shared/jwt/default.ts (3 hunks)
  • examples/edge-functions/supabase/functions/_shared/jwt/legacy-jwt.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-11T02:39:31.320Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/docs-embeddings-generation.md:0-0
Timestamp: 2025-12-11T02:39:31.320Z
Learning: Partner Integrations source should fetch approved partner integration documentation from Supabase database, including technology integrations only and excluding agencies

Applied to files:

  • apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
🧬 Code graph analysis (2)
examples/edge-functions/supabase/functions/_shared/jwt/default.ts (2)
examples/edge-functions/supabase/functions/_shared/jwt/legacy-jwt.ts (1)
  • getAuthToken (9-19)
examples/edge-functions/supabase/functions/_shared/jwt/clerk.ts (1)
  • getAuthToken (11-21)
examples/edge-functions/supabase/functions/_shared/jwt/legacy-jwt.ts (1)
examples/edge-functions/supabase/functions/_shared/jwt/default.ts (1)
  • AuthMiddleware (32-52)
🪛 GitHub Actions: Check Code with Prettier
apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts

[error] 1-1: Prettier formatting check failed. Run 'prettier --write' to fix code style issues.

🪛 LanguageTool
apps/docs/content/guides/functions/auth-legacy-jwt.mdx

[grammar] ~52-~52: Use a hyphen to join words.
Context: ...object to obtain metadata for the logged in user. ```js Deno.serve(async (req: R...

(QB_NEW_EN_HYPHEN)


[grammar] ~66-~66: Use a hyphen to join words.
Context: ...User(token) // ... }) ``` --- ## Row Level Security After initializing a Sup...

(QB_NEW_EN_HYPHEN)

apps/docs/content/guides/functions/auth.mdx

[grammar] ~21-~21: Ensure spelling is correct
Context: ...equest is sent to Edge Functions we can levarage to Supabase Auth to secure our endpoints, ...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[style] ~23-~23: Consider using “incompatible” to avoid wordiness.
Context: ...hecks). But unfortunely this method is not compatible with the new [JWT Signing Keys](docs/gu...

(NOT_ABLE_PREMIUM)


[grammar] ~23-~23: Use a hyphen to join words.
Context: ...d a lot of trouble when trying to [third party integration](https://github.com/or...

(QB_NEW_EN_HYPHEN)


[grammar] ~25-~25: Ensure spelling is correct
Context: ...n and control the auth code, instead of hidding it internally under Edge Runtime infras...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[grammar] ~29-~29: Ensure spelling is correct
Context: ...le, the verify_jwt flag will be still suported and enabled by default. In order to mov...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[style] ~29-~29: Consider a more concise word here.
Context: ... still suported and enabled by default. In order to move to new [JWT Signing Keys](docs/gui...

(IN_ORDER_TO_PREMIUM)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: typecheck
  • GitHub Check: build
🔇 Additional comments (4)
examples/edge-functions/supabase/functions/_shared/jwt/default.ts (1)

25-52: LGTM!

The remote JWKS verification pattern using jose.jwtVerify with issuer validation is correct and follows best practices for asymmetric JWT verification. The middleware structure is clean and consistent with the legacy version.

apps/docs/content/guides/functions/auth-legacy-jwt.mdx (1)

1-96: LGTM overall!

The documentation is clear, well-structured, and provides practical examples for legacy JWT integration. The sections flow logically from setup to fetching users to RLS integration.

apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts (1)

1666-1673: LGTM for the navigation structure change.

The nested sub-menu structure for Supabase Auth is well-organized, providing clear navigation paths to both the new security guide and the legacy JWT documentation.

examples/edge-functions/supabase/functions/_shared/jwt/legacy-jwt.ts (1)

9-55: LGTM for the overall implementation.

The legacy JWT verification using symmetric secrets is correctly implemented. The middleware pattern is consistent with the default.ts approach, making it easy for users to switch between verification methods.


## Fetching the user

By getting the JWT from the `Authorization` header, you can provide the token to `getUser()` to fetch the user object to obtain metadata for the logged in user.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Minor grammar fix: use hyphenated "logged-in" as an adjective.

The phrase "logged in user" should be "logged-in user" when used as a compound adjective.

-By getting the JWT from the `Authorization` header, you can provide the token to `getUser()` to fetch the user object to obtain metadata for the logged in user.
+By getting the JWT from the `Authorization` header, you can provide the token to `getUser()` to fetch the user object to obtain metadata for the logged-in user.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
By getting the JWT from the `Authorization` header, you can provide the token to `getUser()` to fetch the user object to obtain metadata for the logged in user.
By getting the JWT from the `Authorization` header, you can provide the token to `getUser()` to fetch the user object to obtain metadata for the logged-in user.
🧰 Tools
🪛 LanguageTool

[grammar] ~52-~52: Use a hyphen to join words.
Context: ...object to obtain metadata for the logged in user. ```js Deno.serve(async (req: R...

(QB_NEW_EN_HYPHEN)

🤖 Prompt for AI Agents
In apps/docs/content/guides/functions/auth-legacy-jwt.mdx around line 52, change
the phrase "logged in user" to the hyphenated compound adjective "logged-in
user" so the sentence reads: "By getting the JWT from the `Authorization`
header, you can provide the token to `getUser()` to fetch the user object to
obtain metadata for the logged-in user."

Comment on lines +5 to +10
const SUPABASE_JWT_ISSUER = Deno.env.get("SB_JWT_ISSUER") ??
Deno.env.get("SUPABASE_URL") + "/auth/v1";

const SUPABASE_JWT_KEYS = jose.createRemoteJWKSet(
new URL(Deno.env.get("SUPABASE_URL")! + "/auth/v1/.well-known/jwks.json"),
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Potential runtime error if SUPABASE_URL is undefined.

Line 9 uses the non-null assertion ! on SUPABASE_URL, but if this environment variable is not set, the code will attempt to create a URL from "undefined/auth/v1/.well-known/jwks.json", which may cause unexpected behavior or a malformed URL error.

Consider adding a guard or early validation:

+const SUPABASE_URL = Deno.env.get("SUPABASE_URL");
+if (!SUPABASE_URL) {
+  throw new Error("SUPABASE_URL environment variable is required");
+}
+
 const SUPABASE_JWT_ISSUER = Deno.env.get("SB_JWT_ISSUER") ??
-  Deno.env.get("SUPABASE_URL") + "/auth/v1";
+  SUPABASE_URL + "/auth/v1";

 const SUPABASE_JWT_KEYS = jose.createRemoteJWKSet(
-  new URL(Deno.env.get("SUPABASE_URL")! + "/auth/v1/.well-known/jwks.json"),
+  new URL(SUPABASE_URL + "/auth/v1/.well-known/jwks.json"),
 );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const SUPABASE_JWT_ISSUER = Deno.env.get("SB_JWT_ISSUER") ??
Deno.env.get("SUPABASE_URL") + "/auth/v1";
const SUPABASE_JWT_KEYS = jose.createRemoteJWKSet(
new URL(Deno.env.get("SUPABASE_URL")! + "/auth/v1/.well-known/jwks.json"),
);
const SUPABASE_URL = Deno.env.get("SUPABASE_URL");
if (!SUPABASE_URL) {
throw new Error("SUPABASE_URL environment variable is required");
}
const SUPABASE_JWT_ISSUER = Deno.env.get("SB_JWT_ISSUER") ??
SUPABASE_URL + "/auth/v1";
const SUPABASE_JWT_KEYS = jose.createRemoteJWKSet(
new URL(SUPABASE_URL + "/auth/v1/.well-known/jwks.json"),
);
🤖 Prompt for AI Agents
In examples/edge-functions/supabase/functions/_shared/jwt/default.ts around
lines 5 to 10, the code uses a non-null assertion on SUPABASE_URL when building
the JWKS URL which will produce a malformed URL or runtime error if the
environment variable is missing; fix by validating Deno.env.get("SUPABASE_URL")
first (throw a clear error or return early) and only call
jose.createRemoteJWKSet with a constructed URL when SUPABASE_URL is present, and
update the SUPABASE_JWT_ISSUER fallback to handle missing SUPABASE_URL safely
instead of relying on the non-null assertion.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (8)
apps/docs/content/guides/functions/auth.mdx (8)

65-68: Use SUPABASE_ANON_KEY for consistency with documented standards.

 const supabase = createClient(
   Deno.env.get('SUPABASE_URL')!,
-  Deno.env.get('SUPABASE_PUBLISHABLE_KEY')!
+  Deno.env.get('SUPABASE_ANON_KEY')!
 )

11-11: Typo: "walkthought" should be "walk through".

-But it was replaced by the new [JWT Signing Keys](/blog/jwt-signing-keys#start-using-asymmetric-jwts-today), in this guide we'll walkthought the new patterns for securing your Edge Functions.
+But it was replaced by the new [JWT Signing Keys](/blog/jwt-signing-keys#start-using-asymmetric-jwts-today), in this guide we'll walk through the new patterns for securing your Edge Functions.

17-17: Missing leading slash in documentation link.

-Before continuing check the comprehensive guide on [JWT Signing Keys](docs/guides/auth/signing-keys) for all the details about the main differences compared to Legacy JWTs.
+Before continuing check the comprehensive guide on [JWT Signing Keys](/docs/guides/auth/signing-keys) for all the details about the main differences compared to Legacy JWTs.

21-25: Multiple grammar and spelling errors in the overview section.

-When a HTTP request is sent to Edge Functions we can leverage to Supabase Auth to secure our endpoints, in the past this verification was controlled from [`verify_jwt` flag](http://localhost:3001/docs/guides/functions/function-configuration#skipping-authorization-checks).
+When an HTTP request is sent to Edge Functions we can leverage Supabase Auth to secure our endpoints. In the past, this verification was controlled by the [`verify_jwt` flag](/docs/guides/functions/function-configuration#skipping-authorization-checks).

-But unfortunately this method is not compatible with the new [JWT Signing Keys](docs/guides/auth/signing-keys) and also caused a lot of trouble when trying to [third party integration](https://github.com/orgs/supabase/discussions/34988#discussion-8199151).
+But unfortunately this method is incompatible with the new [JWT Signing Keys](/docs/guides/auth/signing-keys) and also caused trouble when attempting [third-party integration](https://github.com/orgs/supabase/discussions/34988#discussion-8199151).

-That's why we decided to not implicit force JWT verification anymore, but instead suggest patterns and templates to handle this task. It allow users to own and control the auth code, instead of hiding it internally under Edge Runtime infrastructure.
+That's why we decided to no longer implicitly force JWT verification, but instead suggest patterns and templates to handle this task. This allows users to own and control the auth code, instead of hiding it internally under Edge Runtime infrastructure.

29-29: Localhost URL and spelling error in warning admonition.

-Following the [Upcoming changes](https://github.com/orgs/supabase/discussions/29260) timetable, the `verify_jwt` flag will be still supported and enabled by default. In order to move to new [JWT Signing Keys](docs/guides/auth/signing-keys) you need to manually [skip the authorization checks](http://localhost:3001/docs/guides/functions/function-configuration#skipping-authorization-checks) and follow the steps bellow.
+Following the [Upcoming changes](https://github.com/orgs/supabase/discussions/29260) timetable, the `verify_jwt` flag will still be supported and enabled by default. To move to the new [JWT Signing Keys](/docs/guides/auth/signing-keys), you need to manually [skip the authorization checks](/docs/guides/functions/function-configuration#skipping-authorization-checks) and follow the steps below.

96-99: Missing SUPABASE_URL definition before use.

+const SUPABASE_URL = Deno.env.get('SUPABASE_URL')!
+
 const SUPABASE_JWT_ISSUER = SUPABASE_URL + '/auth/v1'
 const SUPABASE_JWT_KEYS = createRemoteJWKSet(
   new URL(SUPABASE_JWT_ISSUER + '/.well-known/jwks.json')
 )

113-115: Bug: Using wrong variable name token instead of jwt.

 function verifySupabaseJWT(jwt: string) {
-  return jwtVerify(token, SUPABASE_JWT_KEYS, { issuer: SUPABASE_JWT_ISSUER })
+  return jwtVerify(jwt, SUPABASE_JWT_KEYS, { issuer: SUPABASE_JWT_ISSUER })
 }

117-136: Incomplete code example missing return statement and proper closing.

The code block ends abruptly without completing the function. Add a return statement and proper closing:

       }
     }
   }
+
+  return Response.json({ message: 'Hello!' })
 })

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used**: Repository UI

**Review profile**: CHILL

**Plan**: Pro

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 299e3f12ed314a9e7ed99c92898963ec47db8bdc and b766c1591d0002d825f3630a8c25f1f555e24e77.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `apps/docs/content/guides/functions/auth.mdx` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧠 Learnings (2)</summary>

<details>
<summary>📚 Learning: 2025-12-11T00:21:01.839Z</summary>

Learnt from: dnywh
Repo: supabase/supabase PR: 41215
File: apps/design-system/content/docs/accessibility.mdx:30-30
Timestamp: 2025-12-11T00:21:01.839Z
Learning: In apps/design-system/content/docs/, MDX files use different relative path formats based on their location: root-level docs use components/button format, while subdirectory docs (ui-patterns/, components/) use ../components/button format for linking to components.


**Applied to files:**
- `apps/docs/content/guides/functions/auth.mdx`

</details>
<details>
<summary>📚 Learning: 2025-12-11T02:39:49.745Z</summary>

Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/docs-test-requirements.mdc:0-0
Timestamp: 2025-12-11T02:39:49.745Z
Learning: Applies to apps/docs/**/*.{test,spec}.ts : Before running tests in the docs application, check Supabase status using pnpm supabase status. If Supabase is not running, start it with pnpm supabase start. Reset the database with pnpm supabase db reset --local to ensure clean state. Run tests using pnpm run -F docs test:local:unwatch (without watch mode)


**Applied to files:**
- `apps/docs/content/guides/functions/auth.mdx`

</details>

</details><details>
<summary>🪛 LanguageTool</summary>

<details>
<summary>apps/docs/content/guides/functions/auth.mdx</summary>

[style] ~23-~23: Consider using “incompatible” to avoid wordiness.
Context: ...cks).  But unfortunately this method is not compatible with the new [JWT Signing Keys](docs/gu...

(NOT_ABLE_PREMIUM)

---

[grammar] ~23-~23: Use a hyphen to join words.
Context: ...d a lot of trouble when trying to [third party integration](https://github.com/or...

(QB_NEW_EN_HYPHEN)

---

[style] ~29-~29: Consider a more concise word here.
Context: ...still supported and enabled by default. In order to move to new [JWT Signing Keys](docs/gui...

(IN_ORDER_TO_PREMIUM)

</details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)</summary>

* GitHub Check: build
* GitHub Check: typecheck

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@github-actions

Copy link
Copy Markdown
Contributor

supa-mdx-lint results

apps/docs/content/guides/functions/auth.mdx

Error

27 | <Admonition type="warning">
28 | 

[Rule002AdmonitionTypes] Allowed admonition types are: note, tip, caution, deprecation, danger. Got: "warning".
(customize configuration at supa-mdx-lint.config.toml)

Warning

39 | To simply verify incoming requests you can download the specified template and start using it:
40 | 

[Rule004ExcludeWords] Don't use 'simply'. The sentence is more concise and/or the tone is more neutral without it.
(customize configuration at supa-mdx-lint.config.toml)

Recommendations

  1. Delete the text from row 39, column 4 to row 39, column 11

Summary

  • 🤖 2 files linted
  • 🚨 1 error
  • 🔔 1 warning
    🕚 Done in 0.0 seconds

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
apps/docs/content/guides/functions/auth.mdx (2)

65-68: Use SUPABASE_ANON_KEY for consistency with documented standards.

The code uses SUPABASE_PUBLISHABLE_KEY, but Supabase documentation for Edge Functions typically uses SUPABASE_ANON_KEY as the standard environment variable name for the anonymous/public key.

Apply this diff:

 const supabase = createClient(
   Deno.env.get('SUPABASE_URL')!,
-  Deno.env.get('SUPABASE_PUBLISHABLE_KEY')!
+  Deno.env.get('SUPABASE_ANON_KEY')!
 )

17-17: Missing leading slash in documentation link.

The link docs/guides/auth/signing-keys is still missing the leading slash and will result in a broken relative link.

Apply this diff:

-Before continuing check the comprehensive guide on [JWT Signing Keys](docs/guides/auth/signing-keys) for all the details about the main differences compared to Legacy JWTs.
+Before continuing check the comprehensive guide on [JWT Signing Keys](/docs/guides/auth/signing-keys) for all the details about the main differences compared to Legacy JWTs.
🧹 Nitpick comments (2)
apps/docs/content/guides/functions/auth.mdx (2)

70-73: Add defensive check for missing Authorization header.

The code uses a non-null assertion on line 71, which will throw an uncaught error if the Authorization header is missing, resulting in a 500 error instead of a proper 401 response.

Apply this diff:

 Deno.serve(async (req) => {
-  const authHeader = req.headers.get('Authorization')!
+  const authHeader = req.headers.get('Authorization')
+  if (!authHeader) {
+    return Response.json(
+      { msg: 'Missing authorization header' },
+      { status: 401 }
+    )
+  }
   const token = authHeader.replace('Bearer ', '')

123-140: Remove redundant validation check.

The verifySupabaseJWT function uses jwtVerify from jose, which either returns a verification result object or throws an error. It never returns a falsy value. The check on line 129 (if (!isValidJWT)) is redundant since any verification failure will be caught in the catch block.

Apply this diff:

   if (req.method !== 'OPTIONS') {
     try {
       const token = getAuthToken(req)
-      const isValidJWT = await verifySupabaseJWT(token)
-
-      if (!isValidJWT) {
-        return Response.json({ msg: 'Invalid JWT' }, {
-          status: 401,
-        })
-      }
+      await verifySupabaseJWT(token)
     } catch (e) {
       console.error(e)
       return Response.json({ msg: e.toString() }, {
         status: 401,
       })
     }
   }
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f2816d and b5f8fef.

📒 Files selected for processing (1)
  • apps/docs/content/guides/functions/auth.mdx (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-12-11T00:21:01.839Z
Learnt from: dnywh
Repo: supabase/supabase PR: 41215
File: apps/design-system/content/docs/accessibility.mdx:30-30
Timestamp: 2025-12-11T00:21:01.839Z
Learning: In apps/design-system/content/docs/, MDX files use different relative path formats based on their location: root-level docs use `components/button` format, while subdirectory docs (ui-patterns/, components/) use `../components/button` format for linking to components.

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
📚 Learning: 2025-12-11T02:39:49.745Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/docs-test-requirements.mdc:0-0
Timestamp: 2025-12-11T02:39:49.745Z
Learning: Applies to apps/docs/**/*.{test,spec}.ts : Before running tests in the docs application, check Supabase status using `pnpm supabase status`. If Supabase is not running, start it with `pnpm supabase start`. Reset the database with `pnpm supabase db reset --local` to ensure clean state. Run tests using `pnpm run -F docs test:local:unwatch` (without watch mode)

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: typecheck
  • GitHub Check: build
🔇 Additional comments (7)
apps/docs/content/guides/functions/auth.mdx (7)

1-6: LGTM!

The title and subtitle changes appropriately reflect the updated focus on securing Edge Functions with the new JWT patterns.


8-15: LGTM!

The admonition clearly explains the transition from legacy JWT to JWT Signing Keys and provides appropriate links to both the new approach and legacy documentation.


19-31: LGTM!

The overview section clearly explains the motivation for moving away from implicit JWT verification and provides proper context about the verify_jwt flag deprecation.


33-55: LGTM!

The template-based approach provides a clean, reusable pattern for JWT verification. The curl download command and example usage are clear and complete.


94-103: LGTM!

The JWT setup correctly handles development environments with the SB_JWT_ISSUER fallback and properly configures the remote JWKS endpoint for token verification.


105-115: LGTM!

The getAuthToken helper properly validates the Authorization header format and provides clear error messages for missing or malformed headers.


117-121: LGTM!

The verifySupabaseJWT helper correctly verifies the JWT using the remote JWKS and validates the issuer, providing proper security guarantees.

@github-actions

Copy link
Copy Markdown
Contributor

supa-mdx-lint results

apps/docs/content/guides/functions/auth.mdx

Error

27 | <Admonition type="warning">
28 | 

[Rule002AdmonitionTypes] Allowed admonition types are: note, tip, caution, deprecation, danger. Got: "warning".
(customize configuration at supa-mdx-lint.config.toml)

Warning

39 | To simply verify incoming requests you can download the specified template and start using it:
40 | 

[Rule004ExcludeWords] Don't use 'simply'. The sentence is more concise and/or the tone is more neutral without it.
(customize configuration at supa-mdx-lint.config.toml)

Recommendations

  1. Delete the text from row 39, column 4 to row 39, column 11

Summary

  • 🤖 2 files linted
  • 🚨 1 error
  • 🔔 1 warning
    🕚 Done in 0.0 seconds

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

♻️ Duplicate comments (1)
apps/docs/content/guides/functions/auth.mdx (1)

65-68: Use SUPABASE_ANON_KEY for consistency with documented Supabase standards.

The secrets documentation specifies SUPABASE_ANON_KEY as the standard environment variable for Edge Functions.

 const supabase = createClient(
   Deno.env.get('SUPABASE_URL')!,
-  Deno.env.get('SUPABASE_PUBLISHABLE_KEY')!
+  Deno.env.get('SUPABASE_ANON_KEY')!
 )
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b5f8fef and 165e8f8.

📒 Files selected for processing (1)
  • apps/docs/content/guides/functions/auth.mdx (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-12-11T00:21:01.839Z
Learnt from: dnywh
Repo: supabase/supabase PR: 41215
File: apps/design-system/content/docs/accessibility.mdx:30-30
Timestamp: 2025-12-11T00:21:01.839Z
Learning: In apps/design-system/content/docs/, MDX files use different relative path formats based on their location: root-level docs use `components/button` format, while subdirectory docs (ui-patterns/, components/) use `../components/button` format for linking to components.

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
📚 Learning: 2025-12-11T02:39:49.745Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/docs-test-requirements.mdc:0-0
Timestamp: 2025-12-11T02:39:49.745Z
Learning: Applies to apps/docs/**/*.{test,spec}.ts : Before running tests in the docs application, check Supabase status using `pnpm supabase status`. If Supabase is not running, start it with `pnpm supabase start`. Reset the database with `pnpm supabase db reset --local` to ensure clean state. Run tests using `pnpm run -F docs test:local:unwatch` (without watch mode)

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: typecheck

@github-actions

Copy link
Copy Markdown
Contributor

supa-mdx-lint results

apps/docs/content/guides/functions/auth.mdx

Error

27 | <Admonition type="warning">
28 | 

[Rule002AdmonitionTypes] Allowed admonition types are: note, tip, caution, deprecation, danger. Got: "warning".
(customize configuration at supa-mdx-lint.config.toml)

Warning

39 | To simply verify incoming requests you can download the specified template and start using it:
40 | 

[Rule004ExcludeWords] Don't use 'simply'. The sentence is more concise and/or the tone is more neutral without it.
(customize configuration at supa-mdx-lint.config.toml)

Recommendations

  1. Delete the text from row 39, column 4 to row 39, column 11

Summary

  • 🤖 2 files linted
  • 🚨 1 error
  • 🔔 1 warning
    🕚 Done in 0.1 seconds

@ChrisChinchilla ChrisChinchilla left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small things to begin with…

### Using Supabase template

By getting the JWT from the `Authorization` header, you can provide the token to `getUser()` to fetch the user object to obtain metadata for the logged in user.
We've prepared some [JWT verification](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/custom-jwt-validation) templates, that can be found [here](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/_shared/jwt).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We've prepared some [JWT verification](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/custom-jwt-validation) templates, that can be found [here](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/_shared/jwt).
You can find [JWT verification](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/custom-jwt-validation) templates, that can be found [here](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/_shared/jwt).

I'm slightly confused by the difference between these two links as they point to different places but reference each other?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!
The first one is about the readme/example about custom jwt.

The second one is the folder with all templates.

It's supposed to users download templates on demand based on their auth needs, for example you can get the Clerk template if you're using third party oAuth or reference the default one if you're using Supa Auth instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then let's try…

Suggested change
We've prepared some [JWT verification](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/custom-jwt-validation) templates, that can be found [here](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/_shared/jwt).
You can see [a custom JWT verification example on GitHub](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/custom-jwt-validation) and a variety of [auth function templates](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/_shared/jwt) also on GitHub.

Though it may also be an idea to merge that first readme into the docs…

Comment on lines +65 to +68
const supabase = createClient(
Deno.env.get('SUPABASE_URL')!,
Deno.env.get('SUPABASE_PUBLISHABLE_KEY')!
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remind me @laktek I think for functions, we still use ANON?

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (4)
apps/docs/content/guides/functions/auth.mdx (4)

134-143: Remove dead code: jwtVerify never returns a falsy value.

The jose library's jwtVerify() function throws an error on failure and returns a JWTVerifyResult object on success—it never returns a falsy value. The if (!isValidJWT) check at lines 136-143 is unreachable dead code since validation failures are already caught by the catch block at line 144.

🔎 Proposed fix
      const token = getAuthToken(req)
-      const isValidJWT = await verifySupabaseJWT(token)
-
-      if (!isValidJWT) {
-        return Response.json(
-          { msg: 'Invalid JWT' },
-          {
-            status: 401,
-          }
-        )
-      }
+      await verifySupabaseJWT(token)
    } catch (e) {

98-98: Fix awkward phrasing.

The sentence "library can be used to verify" is grammatically awkward.

-You can use the popular [`jose`](https://www.npmjs.com/package/jose/v/4.10.0) library can be used to verify received JWTs, like the following example:
+You can use the popular [`jose`](https://www.npmjs.com/package/jose/v/4.10.0) library to verify received JWTs, like the following example:

78-79: Add null check for Authorization header.

The code uses a non-null assertion (!) which will throw an unhelpful error if the Authorization header is missing. A previous review flagged this issue as addressed, but the null check is not present in the current code.

🔎 Proposed fix
-  const authHeader = req.headers.get('Authorization')!
-  const token = authHeader.replace('Bearer ', '')
+  const authHeader = req.headers.get('Authorization')
+  if (!authHeader) {
+    return Response.json({ msg: 'Missing Authorization header' }, { status: 401 })
+  }
+  const token = authHeader.replace('Bearer ', '')

131-156: Fix: OPTIONS requests will fail when calling req.json().

The OPTIONS check at line 131 only wraps the JWT verification logic, but line 155 unconditionally calls req.json() for all requests including OPTIONS. Preflight OPTIONS requests typically have no body and will throw an error.

🔎 Proposed fix
  if (req.method !== 'OPTIONS') {
    try {
      const token = getAuthToken(req)
      await verifySupabaseJWT(token)
    } catch (e) {
      console.error(e)
      return Response.json(
        { msg: e.toString() },
        {
          status: 401,
        }
      )
    }
+
+    const { name } = await req.json()
+    return Response.json({ message: `hello ${name}` })
  }

-  const { name } = await req.json()
-  return Response.json({ message: `hello ${name}` })
+  return new Response(null, { status: 204 })
})
🧹 Nitpick comments (2)
apps/docs/content/guides/functions/auth.mdx (2)

37-37: Consider more concise phrasing (optional).

"A variety of" could be simplified to "various" or "multiple" for slightly more concise documentation.

-You can see [a custom JWT verification example on GitHub](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/custom-jwt-validation) and a variety of [auth function templates](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/_shared/jwt) also on GitHub.
+You can see [a custom JWT verification example on GitHub](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/custom-jwt-validation) and various [auth function templates](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/_shared/jwt) also on GitHub.

101-101: Update jose library version to the latest stable release.

The example uses [email protected], which is two major versions behind the current v6.1.3. While v4 still works, updating to the latest version provides access to security patches and improvements.

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8a5f2b1 and eb5283c.

📒 Files selected for processing (1)
  • apps/docs/content/guides/functions/auth.mdx
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: kallebysantos
Repo: supabase/supabase PR: 41444
File: examples/edge-functions/supabase/functions/_shared/jwt/legacy-jwt.ts:6-7
Timestamp: 2026-01-05T12:21:37.661Z
Learning: In Supabase Edge Functions, the JWT_SECRET environment variable is automatically injected by the Supabase platform and is guaranteed to be present in production environments.
Learnt from: kallebysantos
Repo: supabase/supabase PR: 41444
File: apps/docs/content/guides/functions/auth.mdx:105-110
Timestamp: 2026-01-05T12:21:45.493Z
Learning: In Supabase Edge Functions, the `SUPABASE_URL` environment variable is automatically injected by the platform at runtime and is guaranteed to be available.
📚 Learning: 2026-01-05T12:21:37.661Z
Learnt from: kallebysantos
Repo: supabase/supabase PR: 41444
File: examples/edge-functions/supabase/functions/_shared/jwt/legacy-jwt.ts:6-7
Timestamp: 2026-01-05T12:21:37.661Z
Learning: In Supabase Edge Functions, the JWT_SECRET environment variable is automatically injected by the Supabase platform and is guaranteed to be present in production environments.

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
📚 Learning: 2025-12-11T00:21:05.527Z
Learnt from: dnywh
Repo: supabase/supabase PR: 41215
File: apps/design-system/content/docs/accessibility.mdx:30-30
Timestamp: 2025-12-11T00:21:05.527Z
Learning: In apps/design-system/content/docs/, MDX files use different relative path formats based on their location: root-level docs use `components/button` format, while subdirectory docs (ui-patterns/, components/) use `../components/button` format for linking to components.

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
📚 Learning: 2026-01-05T12:21:45.493Z
Learnt from: kallebysantos
Repo: supabase/supabase PR: 41444
File: apps/docs/content/guides/functions/auth.mdx:105-110
Timestamp: 2026-01-05T12:21:45.493Z
Learning: In Supabase Edge Functions, the `SUPABASE_URL` environment variable is automatically injected by the platform at runtime and is guaranteed to be available.

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
📚 Learning: 2025-12-11T02:39:49.764Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/docs-test-requirements.mdc:0-0
Timestamp: 2025-12-11T02:39:49.764Z
Learning: Applies to apps/docs/**/*.{test,spec}.ts : Before running tests in the docs application, check Supabase status using `pnpm supabase status`. If Supabase is not running, start it with `pnpm supabase start`. Reset the database with `pnpm supabase db reset --local` to ensure clean state. Run tests using `pnpm run -F docs test:local:unwatch` (without watch mode)

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Use Admonition sparingly

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/components/**/*.{ts,tsx} : Use Admonition component to alert users of important actions or restrictions

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/**/*.{ts,tsx} : Place Admonition at the top of page contents (below page title) or at the top of the related ScaffoldSection below ScaffoldTitle

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
🪛 LanguageTool
apps/docs/content/guides/functions/auth.mdx

[style] ~37-~37: Consider using a more concise synonym.
Context: ...se/functions/custom-jwt-validation) and a variety of [auth function templates](https://githu...

(A_VARIETY_OF)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: typecheck

@supabase supabase deleted a comment from github-actions Bot Jan 5, 2026
@supabase supabase deleted a comment from github-actions Bot Jan 5, 2026
@supabase supabase deleted a comment from github-actions Bot Jan 5, 2026
@supabase supabase deleted a comment from github-actions Bot Jan 5, 2026
@github-actions

github-actions Bot commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

supa-mdx-lint results

apps/docs/content/guides/functions/auth.mdx

Error

63 | <Admonition type="caution">
64 |  Currently, the new API keys are not available by default on the Edge Functions environment.
65 | But you can manually exposed them as [secret](/docs/guides/functions/secrets#local-secrets) using the `SB_` prefix.
66 | 
67 | We're working on exposing these secrets and make them as default in the future.
68 | 
69 | </Admonition>
70 | 

[Rule005AdmonitionNewlines] Admonition must have empty lines between tags and content

Recommendations

  1. Insert the following text at row 64, column 1:

Summary

  • 🤖 2 files linted
  • 🚨 1 error
  • 🔔 0 warnings
    🕚 Done in 0.0 seconds

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Fix all issues with AI Agents 🤖
In @apps/docs/content/guides/functions/auth.mdx:
- Around line 64-68: Fix the grammar in the admonition: change "manually exposed
them as" to "manually expose them as" (use the infinitive after "can") and
change "make them as default" to "make them the default" (or "make them
default") so the sentences read correctly; update the phrases "exposed" ->
"expose" and "make them as default" -> "make them the default" in the admonition
text.
- Line 101: Update the jose import to use the patched v5.9.6 by changing the
version suffix in the import URL from @v4.14.4 to @v5.9.6; update the import
line that currently references createRemoteJWKSet and jwtVerify to point to
[email protected], then run the relevant tests and validate the usage of
createRemoteJWKSet and jwtVerify (adjust call signatures or named exports if the
v5 API differs) to ensure compatibility.
♻️ Duplicate comments (4)
apps/docs/content/guides/functions/auth.mdx (4)

134-143: Dead code: jwtVerify throws on failure, never returns falsy.

The jose library's jwtVerify() function either returns a valid JWTVerifyResult on success or throws an error on failure—it never returns a falsy value. The if (!isValidJWT) block (lines 136-143) will never execute since failures are already caught by the catch block.

A previous review flagged this as addressed, but the code still contains the dead branch.

🔎 Proposed fix
     try {
       const token = getAuthToken(req)
-      const isValidJWT = await verifySupabaseJWT(token)
-
-      if (!isValidJWT) {
-        return Response.json(
-          { msg: 'Invalid JWT' },
-          {
-            status: 401,
-          }
-        )
-      }
+      await verifySupabaseJWT(token)
     } catch (e) {

153-156: OPTIONS requests will crash on req.json().

After skipping JWT verification for OPTIONS requests (line 131), the code still falls through to line 155 which calls await req.json(). OPTIONS preflight requests typically have no body, causing this to throw an error.

🔎 Proposed fix
     }
   }

+  if (req.method === 'OPTIONS') {
+    return new Response(null, { status: 204 })
+  }
+
   const { name } = await req.json()
   return Response.json({ message: `hello ${name}` })
 })

98-98: Malformed sentence structure.

The sentence reads "You can use the popular jose library can be used to verify received JWTs" — this has redundant phrasing ("You can use... can be used").

🔎 Proposed fix
-You can use the popular [`jose`](https://www.npmjs.com/package/jose/v/4.10.0) library can be used to verify received JWTs, like the following example:
+You can use the popular [`jose`](https://www.npmjs.com/package/jose/v/4.10.0) library to verify received JWTs, like the following example:

77-90: Missing Authorization header null check can cause runtime crash.

Line 78 uses a non-null assertion (!) on the Authorization header. If the header is missing, line 79 will throw Cannot read properties of null (reading 'replace') before reaching the error handling at lines 83-90.

A past review flagged this issue as addressed, but the code still appears vulnerable.

🔎 Proposed fix
 Deno.serve(async (req) => {
-  const authHeader = req.headers.get('Authorization')!
+  const authHeader = req.headers.get('Authorization')
+  if (!authHeader) {
+    return Response.json({ msg: 'Missing Authorization header' }, { status: 401 })
+  }
   const token = authHeader.replace('Bearer ', '')
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb5283c and f266491.

📒 Files selected for processing (1)
  • apps/docs/content/guides/functions/auth.mdx
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: kallebysantos
Repo: supabase/supabase PR: 41444
File: examples/edge-functions/supabase/functions/_shared/jwt/legacy-jwt.ts:6-7
Timestamp: 2026-01-05T12:21:37.661Z
Learning: In Supabase Edge Functions, the JWT_SECRET environment variable is automatically injected by the Supabase platform and is guaranteed to be present in production environments.
📚 Learning: 2026-01-05T12:21:37.661Z
Learnt from: kallebysantos
Repo: supabase/supabase PR: 41444
File: examples/edge-functions/supabase/functions/_shared/jwt/legacy-jwt.ts:6-7
Timestamp: 2026-01-05T12:21:37.661Z
Learning: In Supabase Edge Functions, the JWT_SECRET environment variable is automatically injected by the Supabase platform and is guaranteed to be present in production environments.

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
📚 Learning: 2025-12-11T00:21:05.527Z
Learnt from: dnywh
Repo: supabase/supabase PR: 41215
File: apps/design-system/content/docs/accessibility.mdx:30-30
Timestamp: 2025-12-11T00:21:05.527Z
Learning: In apps/design-system/content/docs/, MDX files use different relative path formats based on their location: root-level docs use `components/button` format, while subdirectory docs (ui-patterns/, components/) use `../components/button` format for linking to components.

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
📚 Learning: 2026-01-05T12:21:45.493Z
Learnt from: kallebysantos
Repo: supabase/supabase PR: 41444
File: apps/docs/content/guides/functions/auth.mdx:105-110
Timestamp: 2026-01-05T12:21:45.493Z
Learning: In Supabase Edge Functions, the `SUPABASE_URL` environment variable is automatically injected by the platform at runtime and is guaranteed to be available.

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
📚 Learning: 2025-12-11T02:39:49.764Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/docs-test-requirements.mdc:0-0
Timestamp: 2025-12-11T02:39:49.764Z
Learning: Applies to apps/docs/**/*.{test,spec}.ts : Before running tests in the docs application, check Supabase status using `pnpm supabase status`. If Supabase is not running, start it with `pnpm supabase start`. Reset the database with `pnpm supabase db reset --local` to ensure clean state. Run tests using `pnpm run -F docs test:local:unwatch` (without watch mode)

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Use Admonition sparingly

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/components/**/*.{ts,tsx} : Use Admonition component to alert users of important actions or restrictions

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/**/*.{ts,tsx} : Place Admonition at the top of page contents (below page title) or at the top of the related ScaffoldSection below ScaffoldTitle

Applied to files:

  • apps/docs/content/guides/functions/auth.mdx
🪛 LanguageTool
apps/docs/content/guides/functions/auth.mdx

[style] ~37-~37: Consider using a more concise synonym.
Context: ...se/functions/custom-jwt-validation) and a variety of [auth function templates](https://githu...

(A_VARIETY_OF)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: typecheck
  • GitHub Check: build

You can use the popular [`jose`](https://www.npmjs.com/package/jose/v/4.10.0) library can be used to verify received JWTs, like the following example:

```ts
import { createRemoteJWKSet, jwtVerify } from 'https://deno.land/x/[email protected]/index.ts'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

jose npm package latest version

💡 Result:

The latest published version of the npm package "jose" is 6.1.0 (published 9 days ago). [1]

Sources:
[1] npm package page — jose.


🌐 Web query:

jose deno.land latest version security patches

💡 Result:

Short answer — as of Jan 5, 2026:

  • The jose module on deno.land/x is published as the v5.x series (latest deno.land/x release referenced publicly is v5.9.6). (deno.land)
  • Known security advisories:
    • CVE-2024-28176 (resource exhaustion via compressed JWE plaintext) — fixed in the v5.x line by removing compressed-payload support; affected older 2.x/4.x releases were patched in 2.0.7 and 4.15.5. (advisories.gitlab.com)
    • Other advisories/CVEs for jose are tracked upstream (see the project's security advisories / changelog on the jose repo and npm). Always check the upstream GitHub advisories and deno.land import page before upgrading. (skypack.dev)

Recommendation: pin an explicit deno.land/x version (e.g. @v5.9.6) and verify the jose GitHub security advisories / npm release notes for any newer security patches before deployment. (deno.land)

If you want, I can fetch the current deno.land/x jose version and the latest security advisories right now.

Citations:


Update jose library to v5.9.6 for security fixes.

The jose library is pinned to v4.14.4, which is vulnerable to CVE-2024-28176 (resource exhaustion via compressed JWE plaintext). Update to v5.9.6, the latest version available on deno.land/x.

🤖 Prompt for AI Agents
In @apps/docs/content/guides/functions/auth.mdx around line 101, Update the jose
import to use the patched v5.9.6 by changing the version suffix in the import
URL from @v4.14.4 to @v5.9.6; update the import line that currently references
createRemoteJWKSet and jwtVerify to point to [email protected], then run the relevant
tests and validate the usage of createRemoteJWKSet and jwtVerify (adjust call
signatures or named exports if the v5 API differs) to ensure compatibility.

@ChrisChinchilla
ChrisChinchilla merged commit 0a8e264 into supabase:master Jan 5, 2026
@github-actions

github-actions Bot commented Jan 5, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1767619867)

Score Average Improvements Regressions
Completeness 100% (+40pp) 2 🟢 -
Conciseness 0% (+0pp) - -
Goal Completion 90% (+40pp) 2 🟢 -
Tool Usage 60% (+10pp) 1 🟢 -
SQL Validity 100% (+0pp) - -
Time_to_first_token 0.15tok (-0.05tok) 4 🟢 1 🔴
Llm_calls 7.4 (-1) 1 🟢 4 🔴
Tool_calls 3.8 (+0) 3 🟢 2 🔴
Errors 0 (+0) - -
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 57374tok (-2210.4tok) 3 🟢 2 🔴
Prompt_cached_tokens 33689.6tok (-16076.8tok) 1 🟢 4 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Completion_tokens 6590.4tok (+2888tok) - 5 🔴
Completion_reasoning_tokens 4966.4tok (+1792tok) - 5 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 63964.4tok (+677.6tok) 3 🟢 2 🔴
Estimated_cost 0.02$ (+0.01$) - 5 🔴
Duration 46.08s (+3.76s) 3 🟢 2 🔴
Llm_duration 91.58s (+7.42s) 3 🟢 2 🔴

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants