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

Invalid session cookie handling when creating 100-year cookies #892

Closed
vonox7 opened this issue Jan 22, 2019 · 1 comment
Closed

Invalid session cookie handling when creating 100-year cookies #892

vonox7 opened this issue Jan 22, 2019 · 1 comment
Assignees
Labels
Milestone

Comments

@vonox7
Copy link

vonox7 commented Jan 22, 2019

Ktor 1.1.1 reverts fixes that are made in #686:

If you crate a cookie with cookie.duration = Duration.ofDays((100 * 365).toLong()) a cookie without a duration (session-cookie) is created. Apparently the commit 17bb8fb which fixed another issue broke that case

I see here 2 ways to fix it:
a) throw if maxAge > Int.MAX_VALUE (so at least the error would be found immediately and not after several days of debugging)
b) move the ?.takeIf { it <= Int.MAX_VALUE } from line 31 to line 38, so line 38 would be maxAge?.takeIf { it <= Int.MAX_VALUE }?.toInt() ?: 0,

@cy6erGn0m cy6erGn0m self-assigned this Jan 22, 2019
@cy6erGn0m cy6erGn0m added the bug label Jan 22, 2019
@cy6erGn0m cy6erGn0m added this to the 1.1.2 milestone Jan 22, 2019
@cy6erGn0m
Copy link
Contributor

Other possible options would be:

  • bump maxAge to Int.MAX_VALUE since usually people simply want very very long duration and it doesn't matter what exact value it will be (for now I'll prefer it as a quick fix)
  • replace Int with Long to support larger values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants