Skip to content

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

@odiferousmint

Description

@odiferousmint

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions