Commit 0e3eab5
committed
refactor: use Supabase service role key for worker authentication (#472)
# Use Supabase Service Role Key for Worker Authentication
This PR simplifies the authentication mechanism for workers by leveraging the `SUPABASE_SERVICE_ROLE_KEY` that's automatically available in Edge Functions, eliminating the need for a separate `PGFLOW_SECRET_KEY`.
Changes:
- Workers now authenticate with the Control Plane using the Supabase service role key
- Removed the `secretKey` option from `ControlPlaneOptions` interface
- Updated the `verifyAuth` function to check against `SUPABASE_SERVICE_ROLE_KEY` environment variable
- Modified tests to properly set and clean up the environment variable during testing
- Added a test case for when the service role key is not set in the environment
This change reduces configuration overhead as both Control Plane and Worker Edge Functions automatically have access to this key via `Deno.env`.1 parent befd2d5 commit 0e3eab5
3 files changed
Lines changed: 277 additions & 230 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
| 36 | + | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
| 48 | + | |
| 49 | + | |
49 | 50 | | |
50 | | - | |
51 | | - | |
52 | | - | |
| 51 | + | |
53 | 52 | | |
54 | 53 | | |
55 | 54 | | |
| |||
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
69 | | - | |
| 68 | + | |
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
| |||
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
122 | | - | |
| 121 | + | |
123 | 122 | | |
124 | 123 | | |
125 | 124 | | |
| |||
718 | 717 | | |
719 | 718 | | |
720 | 719 | | |
721 | | - | |
| 720 | + | |
722 | 721 | | |
723 | 722 | | |
724 | 723 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
52 | 50 | | |
53 | 51 | | |
54 | 52 | | |
| |||
195 | 193 | | |
196 | 194 | | |
197 | 195 | | |
198 | | - | |
| 196 | + | |
199 | 197 | | |
200 | | - | |
201 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
202 | 201 | | |
203 | | - | |
| 202 | + | |
204 | 203 | | |
205 | 204 | | |
206 | 205 | | |
| |||
249 | 248 | | |
250 | 249 | | |
251 | 250 | | |
252 | | - | |
| 251 | + | |
253 | 252 | | |
254 | 253 | | |
255 | 254 | | |
| |||
0 commit comments