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

Client issue with Cloudflare (bot management) #384

Open
DerrickMartinez opened this issue Feb 4, 2025 · 0 comments
Open

Client issue with Cloudflare (bot management) #384

DerrickMartinez opened this issue Feb 4, 2025 · 0 comments

Comments

@DerrickMartinez
Copy link

DerrickMartinez commented Feb 4, 2025

/api/v1/enrollment/create_device will return a cookie, for example:

defguard_proxy=ABCD1234; Expires=Tue, 04 Feb 2025 22:37:57 GMT

But running through cloudflare, it will set a second cookie, i.e.

set-cookie: __cf_bm=doJLB55tYR_sq26VsCzp9JkRSoxGZr6KxSes1ILLo3c-1738708077-1.0.1.1-61526ibFeVTYxR_jeYMZt1PfbQtRz82H1Krnt1qx3rPvsLldvpIABCmK97eLQOe28Z0W8KXgjewU7YLFxNqU.g; path=/; expires=Tue, 04-Feb-25 22:57:57 GMT; domain=.skyslope.com; HttpOnly; Secure; SameSite=None

The issue is that the client is sending the __cf_bm cookie in the following /api/v1/enrollment/create_device request, not defguard_proxy, causing the request to fail.

Since the code is expecting a string (single cookie) and not an array it fails.

For example, maybe something like this:
let authCookie = res.headers['set-cookie']; if (Array.isArray(authCookie)) { // Find the cookie that starts with "defguard_proxy=" authCookie = authCookie.find(cookie => cookie.startsWith("defguard_proxy=")); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant