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

Cloudflare Access prevents using Drizzle Studio in dash #183

Closed
RihanArfan opened this issue Jun 24, 2024 · 3 comments · Fixed by #348
Closed

Cloudflare Access prevents using Drizzle Studio in dash #183

RihanArfan opened this issue Jun 24, 2024 · 3 comments · Fixed by #348
Labels
admin enhancement New feature or request

Comments

@RihanArfan
Copy link
Contributor

RihanArfan commented Jun 24, 2024

Describe the bug
When using Cloudflare Access to protect the site, it's not possible to use the database viewer/integrated Drizzle Studio, as it accesses using a proxied request, so any authenticated Cloudflare Access session for the user in the browser doesn't apply.

Steps to reproduce
Enable Cloudflare Access for the Cloudflare Pages site.

Workarounds
Adding a bypass for everyone which applies to /api/_hub

image
image
image

Ideal fix

  1. Either having requests go from the user (guessing CORS issues)
  2. Allow adding custom headers so a Cloudflare Access service token can be included. https://developers.cloudflare.com/cloudflare-one/identity/service-tokens/#connect-your-service-to-access
  3. Fully integrate support for Access into NuxtHub (complex/long term?)
    NuxtHub could automatically create the service token and add the bypass rule to any Access application linked with the Pages site (Pages can determine if an Access application exists for it so I guess it's able to get applications by domain).
    image
  • Zero Trust is an additional subscription (free for 50 users) the same way R2 is a separate subscription from Workers.
  • Requires API key to have new perms to manage Zero Trust
Copy link
Contributor

atinux commented Jun 25, 2024

Should it be something that we document instead?

@RihanArfan
Copy link
Contributor Author

RihanArfan commented Jun 25, 2024

The issue with my workaround is that if anyone knows the hostname of the application, they can bypass Access as the rule allows everyone to access /api/_hub endpoints. If the secret or user token is compromised, an attacker could then read/write the production database. Cloudflare Access would prohibit this as they haven't authenticated with corporate SSO.

Even if the rule limited to NuxtHub IPs, I believe NuxtHub runs on Cloudflare so a malicious user can just use a Worker to make requests from Cloudflare IPs too. I'm happy to PR documention for this workaround in August once I finish uni. However if option 1 or 2 could be considered it's be amazing so Access can fully protect the application 100% from any unauthenticated/public request without breaking NuxtHub dashboard features.

Cloudflare Access also affects npm run dev --remote too, as requests won't be through the authenticated Access browser session. I think adding headers to proxyHubX()'s ofetch from a hook/environment variables/runtime config would be pretty simple (and something I can PR later possibly if you'd like).

@atinux
Copy link
Contributor

atinux commented Jul 28, 2024

Looking forward to see your PRs :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
admin enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants