-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
Make auth optional in withApiAuth #254
Comments
Why would you wrap your endpoint with Anyhow, the objects you want to return based on authentication status is anyway to be handled by your function's logic, so from my point of view you could just remove the |
To be able to query tables with RLS enabled. I might be missing sth, but haven't managed to get that working. |
But how you would you achieve querying with RLS if an API user is not authenticated? Usually you would instantiate it like this
As shown here, just without the |
In my use case, I have an Nextjs API endpoint which wants to return partial data for unauthorized users, and full data for authorized users. |
Yes, I think that's a reasonable use case. |
In that case, I think making the RLS return that partial data at all times when requested. And the protected data only when it's being accessed by authorized users. |
This will be enabled via #364 |
Feature request
Is your feature request related to a problem? Please describe.
I would like to protect API routes just as you can do pages (with optional authentication).
Describe the solution you'd like
I would like the authentication to be optional for an API route such that I can return results depending on if a user exists and is authenticated or not.
Example: return all objects if you are not Authenticated, if you are, return objects with attributes like those you have marked as favorites.
Describe alternatives you've considered
At this point, I have to make use of
withPageAuth
, andauthRequired: false
, and create 2 different endpoints in my app.## Additional information
Related issue: #74
The text was updated successfully, but these errors were encountered: