Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
johtso committed Apr 7, 2024
1 parent 95354ae commit 6090887
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@sveltejs/kit": "^2.4.3",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@tailwindcss/typography": "^0.5.10",
"@types/cookie": "^0.6.0",
"@types/debug": "^4.1.12",
"@types/sql.js": "^1.4.9",
"@typescript-eslint/eslint-plugin": "^6.19.1",
Expand Down Expand Up @@ -81,6 +82,7 @@
},
"packageManager": "[email protected]",
"dependencies": {
"@cloudflare/pages-plugin-cloudflare-access": "^1.0.4"
"@cloudflare/pages-plugin-cloudflare-access": "^1.0.4",
"cookie": "^0.6.0"
}
}
7 changes: 6 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/access.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copied from https://github.com/cloudflare/pages-plugins/blob/434fad8db20e483cc532d9c678d46a73a4ae7115/packages/cloudflare-access/functions/_middleware.ts

import type { PluginArgs } from "@cloudflare/pages-plugin-cloudflare-access";
import { generateLoginURL, getIdentity } from "@cloudflare/pages-plugin-cloudflare-access/api";
import { parse as parseCookies } from "cookie";

type CloudflareAccessPagesPluginFunction<
Env = unknown,
Expand All @@ -10,7 +10,8 @@ type CloudflareAccessPagesPluginFunction<
> = PagesPluginFunction<Env, Params, Data, PluginArgs>;

const extractJWTFromRequest = (request: Request) =>
request.headers.get("Cf-Access-Jwt-Assertion") || request.headers.get("CF_Authorization");
request.headers.get("Cf-Access-Jwt-Assertion") ||
parseCookies(request.headers.get("Cookie") || "")["CF_Authorization"];

// Adapted slightly from https://github.com/cloudflare/workers-access-external-auth-example
const base64URLDecode = (s: string) => {
Expand Down

0 comments on commit 6090887

Please sign in to comment.