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

The token is not identical due to table not being ordered #102

Open
odiferousmint opened this issue Jun 4, 2023 · 0 comments
Open

The token is not identical due to table not being ordered #102

odiferousmint opened this issue Jun 4, 2023 · 0 comments

Comments

@odiferousmint
Copy link

odiferousmint commented Jun 4, 2023

Hey. Due to the table header not being ordered, I get two different tokens (randomly). Both are correct, but it is unacceptable in many cases to not have only one token.

local function generateToken(payload)
  local token = jwt:sign(secret, {
    header = { typ = "JWT", alg = "HS512" },
    payload = payload,
    exp = ngx.time() + tokenExp
  })
  return token
end

The issue is that the header table might end up being { typ = "JWT", alg = "HS512" } and at other times { alg = "HS512", typ = "JWT" }, and thus resulting in a completely different token.

Do any of you know if there is a workaround for it?

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