elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
9.74k stars 207 forks source link

Cookies are getting signed but not unsigned #706

Open binamralamsal opened 2 months ago

binamralamsal commented 2 months ago

What version of Elysia.JS is running?

1.0.26

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

const app = new Elysia({
  cookie: {
    httpOnly: true,
    secure: true,
    secrets: env.COOKIE_SIGNATURE,
    sign: ["accessToken", "refreshToken"],
  },
})

When I am using Cookie Signature, it's signing the cookies but it's not unsigning them when accessing it.

What is the expected behavior?

It should unsign the cookies while accessing it.

What do you see instead?

If the cookie is altered, I get the error saying "accessToken" has invalid cookie signature but when accessing it, it's not getting unsigned.

Additional information

I have a separate handler for auth related stuff like this:

export const authControllers = new Elysia()
  .use(setup)
////
binamralamsal commented 2 months ago

Well, looks like this doesn't work as I expected when using cookie schema (I was using it on logout route only) or probably I am dumb to not understand this. Removing cookie schema works fine but I am not sure if it should be considered an issue or not.

If this is an intentional behavior, then you can close this issue and please also provide short explanation as I am extremely confused.