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

Header Parameter is stored in the payload instead of header #19

Open
deanrih opened this issue Dec 28, 2023 · 0 comments
Open

Header Parameter is stored in the payload instead of header #19

deanrih opened this issue Dec 28, 2023 · 0 comments

Comments

@deanrih
Copy link

deanrih commented Dec 28, 2023

The Header Parameter config according to https://elysiajs.com/plugins/jwt.html#config is being stored in the payload section instead of header

for example, when doing

// setup.ts
export const JWT = jwt({
	name: "jwt",
	secret: "supersecret",
	typ: "JWT",
});

// main.ts
const jwtResult = await jwt.sign({
        sub: "subject",
});

will result in

eyJhbGciOiJIUzI1NiJ9.eyJ0eXAiOiJKV1QiLCJzdWIiOiJzdWJqZWN0In0.f69kq3ejRaV56IDJOAKDKHlejLU6_MiSiKsa5U4nTIs
{
  "alg": "HS256"
}
{
  "typ": "JWT",
  "sub": "subject"
}

instead of

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJzdWJqZWN0In0.aaT9AYvX_t5IExIkcUJ6Ux38zJcZ89-7q8SNlG5P9dM
{
  "alg": "HS256",
  "typ": "JWT"
}
{
  "sub": "subject"
}

looking at the code it seems there's no differentiation which is payload and which is header except the alg and crit

elysia-jwt/src/index.ts

Lines 136 to 144 in 188b20c

let jwt = new SignJWT({
...payload,
...morePayload,
nbf: undefined,
exp: undefined
}).setProtectedHeader({
alg,
crit
})

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