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

Feature request: -j flag for encoding using the output of decode -j #148

Open
nnsee opened this issue Oct 26, 2021 · 1 comment
Open

Feature request: -j flag for encoding using the output of decode -j #148

nnsee opened this issue Oct 26, 2021 · 1 comment

Comments

@nnsee
Copy link

nnsee commented Oct 26, 2021

decode allows supplying the -j (--json) flag to output JSON in the following format:

{
  "header": {
    "typ": "JWT",
    "alg": "HS256"
  },
  "payload": {
    "exp": 1835241013,
    "iat": 1635240113,
    "sub": "2e5c4600-9fb6-47b4-aff7-f490d23c6074",
    "email": "[email protected]"
  }
}

I propose adding a -j (--json) flag to encode as well which accepts JSON in the same format. That means, options such as typ, alg etc. should be inferred from the header object, as well as payload and so on.

Ideally, this should enable the following workflow:

echo $JWT | jwt decode -j - | modify-token | jwt encode -j -S secret-key -

... where modify-token can be replaced with whatever utility that modifies the JSON.

@nnsee nnsee changed the title Feature request: -j flag for encoding using the output of decode -j Feature request: -j flag for encoding using the output of decode -j Oct 26, 2021
@mike-engel
Copy link
Owner

@neonSea This is a pretty neat idea, however I'll need to think about this a bit more. The problem here is that a flag of -j or --json would conflict with the name and idea of the last argument, which allows the payload to be a json string.

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

2 participants