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

OAuth client in CloudFlare environments #3292

Open
JoviDeCroock opened this issue Dec 25, 2024 · 0 comments
Open

OAuth client in CloudFlare environments #3292

JoviDeCroock opened this issue Dec 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@JoviDeCroock
Copy link

JoviDeCroock commented Dec 25, 2024

Describe the bug

There's a few issues with implementing the OAuth client in environments like CloudFlare and other WinterCG environments.

I have been able to circumvent these myself with a few tricks

  • Fetch.cache is not available, in @atproto/oauth-client we are using cache: 'no-cache' which isn't supported in CloudFlare, we could circumvent this by using cache-control: no-cache instead.
  • Fetch.redirect: error is not available, in @atproto/did-resolver we are using redirect: 'error' which does not work, we need to use manual or follow.
  • When we use a tool like KV we have to restore the state.dpopKey to a JoseKey (more a docs issue I guess) which can be done like kvResult.dpopKey = new JoseKey(kvResult.dpopKey.jwks);
  • The handle-resolvers currently available all require DNS which isn't supported, instead I've made
      handleResolver: {
        resolve: async (handle) => {
          const result = await fetch(
            "https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=" +
              handle,
            {
              cf: {
                cacheEverything: true,
              },
            },
          ).then((x) => x.json<{ did: ResolvedHandle }>());
          return result.did as ResolvedHandle;
        },
      },
    this could also be done with the DNS resolution of CloudFlare itself I reckon.

Expected behaviour

I mainly wanted to describe the issues and discuss them before jumping on pull requests. I'm not sure how to replace redirect: error however the other three look feasible.

@JoviDeCroock JoviDeCroock added the bug Something isn't working label Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant