Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rsc-auth): Implement getRoles function in auth mw & update default ServerAuthState #10656

Merged
merged 29 commits into from
May 31, 2024
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a9a9772
feat(rsc-auth): Implement extractRoles function in auth mw
dac09 May 21, 2024
34cec37
Bit more cleanup
dac09 May 21, 2024
940fa63
Bit more cleanup
dac09 May 21, 2024
b88b169
Update invokeMiddleware tests
dac09 May 21, 2024
910e9ad
Update supabase middleware tests
dac09 May 21, 2024
9dc27b1
Update dbAuth middleware tests
dac09 May 21, 2024
11b3712
Merge branch 'main' of github.com:redwoodjs/redwood into feat/extract…
dac09 May 21, 2024
3e22b82
Cleanup red lines in dbAuthMw tests
dac09 May 21, 2024
12e4eea
Add test for extractRoles for supa mw
dac09 May 21, 2024
71fd715
Cleanup createStreamingHandler
dac09 May 21, 2024
5f47249
Fix dbAuth middleware and update tests
dac09 May 22, 2024
dc7dd9c
Merge branch 'main' into feat/extract-role-authmw
dac09 May 22, 2024
a1a2caa
Merge branch 'main' of github.com:redwoodjs/redwood into feat/extract…
dac09 May 22, 2024
a730f93
Add changeset, update dbAuthReadme
dac09 May 22, 2024
f0390de
Merge branch 'feat/extract-role-authmw' of github.com:dac09/redwood i…
dac09 May 22, 2024
21df537
Rename extractRoles to getRoles
dac09 May 25, 2024
8728346
Implement default getRoles for dbAuth
dac09 May 27, 2024
85700ef
Update readme
dac09 May 27, 2024
854fbe0
Add default get roles for supabase
dac09 May 27, 2024
01544bc
Lint
dac09 May 27, 2024
33c6190
Merge branch 'main' into feat/extract-role-authmw
dac09 May 28, 2024
61f6dc1
Merge branch 'main' into feat/extract-role-authmw
dthyresson May 28, 2024
9618e8e
Fix tests to init supabase middleware
dthyresson May 28, 2024
783a76e
explain getRole usage in readme
dthyresson May 28, 2024
dc7ae9c
add how to set roles in supabase
dthyresson May 28, 2024
d2a2772
Update readme with more explanation on roles
dac09 May 28, 2024
5c06594
Merge branch 'main' into feat/extract-role-authmw
dac09 May 30, 2024
0672064
Merge branch 'main' into feat/extract-role-authmw
Tobbe May 30, 2024
ca79741
Merge branch 'main' into feat/extract-role-authmw
Tobbe May 31, 2024
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
18 changes: 12 additions & 6 deletions packages/auth-providers/supabase/middleware/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# Supabase Middleware

---

NOTE: This README needs to be updated when the Supabase Web Auth will create a client and register the middleware

----

```tsx filename='entry.server.tsx'
import type { TagDescriptor } from '@redwoodjs/web'

Expand All @@ -20,12 +14,24 @@ interface Props {
meta?: TagDescriptor[]
}

type SupabaseAppMetadata = {
provider: string
providers: string[]
roles: string[]
}

export const registerMiddleware = () => {
const supabaseAuthMiddleware = initSupabaseMiddleware({
// Optional. If not set, Supabase will use its own `currentUser` function
// instead of your app's
getCurrentUser,
// Optional. If you wish to enforce RBAC, define a function to return roles.
// Typically, one will define roles in Supabase in the user's app_metadata.
dthyresson marked this conversation as resolved.
Show resolved Hide resolved
getRoles: ({ app_metadata }: { app_metadata: SupabaseAppMetadata }) => {
return app_metadata.roles
},
})

return [supabaseAuthMiddleware]
}

Expand Down
Loading