Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: option for cloudflared access login to only output jwt (#1249) #1250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rjgpacheco
Copy link

@rjgpacheco rjgpacheco commented May 20, 2024

Adds a -no-pretty flag to cloudflared access login:

$ cloudflared access login -no-pretty $url
<TOKEN>

This removes the need to parse the token from the output message, making it easier for external applications.

This is a pretty small change change that makes it much simpler to use from, eg Python script.

With the current CLI, the caller must manually parse the output, eg:

from subprocess import check_output

def get_auth_token(url) -> str:
    cmd = ["cloudflared", "access", "login", url]
    return check_output(cmd).decode("utf-8").strip().split()[-1]

Python's the simplest case here, but it's a step that doesn't really need to happen.

Also: the hardest part is coming up with a name for the flag, so I didn't thing too much about it, open to suggestions :)

…are#1249)

Adds a -no-pretty flag to cloudflared access login:

```shell
$ cloudflared access login -no-pretty $url
<TOKEN>
```

This removes the need to parse the token from the output message, making it
easier for external applications.
Copy link

@janrueth janrueth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--only-token might be an alternative. But I like this feature, makes using cloudflared in bash scripts a lot simpler

@chungthuang chungthuang added the Area: Access Issue related with cloudflared access label Aug 6, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Area: Access Issue related with cloudflared access
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants