Bug: cloudflared access tcp with service token launches browser for approval
Describe the bug
cloudflared access tcp --id=<id> --secret=<secret> --hostname=<hostname> --url=localhost:1234 launches browser for approval. I would expect that when using a service token that approval via browser would not be needed.
To Reproduce Steps to reproduce the behavior:
- Create tunnel, application and service token
- Create policy for application which includes service token
- Run
cloudflared access tcp --id=<id> --secret=<secret> --hostname=<hostname> --url=localhost:1234 - Run
curl http://localhost:1234A browser window should open to the Cloudflare 'Access Requested' page.
Expected behavior I would expect that when using a service token I would not need to explicitly approve access via a browser.
Environment and versions
- OS: Windows 11
- Architecture: Intel i7
- Version: 2022.3.1
Logs and errors
❯ cloudflared access tcp --log-level=debug --service-token-id=<id> --service-token-secret=<secret> --hostname=<host> --url=localhost:1234
2022-03-17T10:48:10Z INF Start Websocket listener host=localhost:1234
2022-03-17T10:48:19Z DBG Websocket request: GET / HTTP/1.1
Host: <host>
Cf-Access-Client-Id: <id>
Cf-Access-Client-Secret: <secret>
2022-03-17T10:48:20Z DBG failed to exchange org token for app token: response from https://ameier38.cloudflareaccess.com/cdn-cgi/access/login/<host>?<params> did not contain app token
A browser window should have opened at the following URL:
https://<host>/cdn-cgi/access/cli?edge_token_transfer=true&redirect_url=<host>%3Ftoken%3D-LUtUPD0_rhXdBQnuA2sUX4zfxI5O4dbswg5TAqPvBA%253D&send_org_token=true&token=-LUtUPD0_rhXdBQnuA2sUX4zfxI5O4dbswg5TAqPvBA%3D
If the browser failed to open, please visit the URL above directly in your browser.
@jroyal this one needs to be triaged by your team please
@ameier38 Can you check to see if your Access policy has the "service auth" decision? An allow policy will still require you to login in the browser.
@jroyal That was it! Sorry missed this line in the docs:
You can now use the service token when you create service auth policies . When creating these policies, use the Service Auth action to ensure that the identity provider login screen is not required for end users.
It is working now. Can close this.
Btw cloudflared is awesome. Nice work!
I'm still getting this issue and I just can not figure it out so any help would be greatly appreciated! Here is the command and response
cloudflared access tcp --id <id.access> --secret <secret> --hostname <hostname> --url tcp://<url>:<port> --log-level=debug
2022-12-14T19:30:00Z INF Start Websocket listener host=url:port
2022-12-14T19:30:09Z DBG Websocket request: GET / HTTP/1.1
Host: <hostname>
Cf-Access-Client-Id: <id.access>
Cf-Access-Client-Secret: <secret>
2022-12-14T19:33:39Z DBG failed to exchange org token for app token: response from ... did not contain app token
A browser window should have opened at the following URL:
https://<hostname>/cdn-cgi/access/cli?redirect_url=redirect&send_org_token=true&token=token
If the browser failed to open, please visit the URL above directly in your browser.
Without other debugging information it would be hard to say.
Double check that you are correctly getting an auth token with your service token. Make a curl to your domain using the service token headers (cf-access-client-id and cf-access-client-secret and make sure its actually returning a CF_Authorization cookie. That might also show if you are accidentally getting blocked by the WAF, which is another thing I've seen cause that.
Hmm. Super interesting. Right now I created a new service token and added the policy and it works as expected so I'll take that as a win! Thanks!
Thank you for this:
I had been unable to figure it out until I saw this and realized there's a special SERVICE AUTH action for CFZT Access App Policies.
I was like why on earth would this be asking for me to open a browser when it's set to ALLOW with a specific service token... Ahhhh.
Grateful for this issue being here still.