Skip to content

web-server/http/id-cookie: accept names & values as bytes; fix HMAC - #75

Closed
LiberalArtist wants to merge 1 commit into
racket:masterfrom
LiberalArtist:fix-id-cookie
Closed

LiberalArtist wants to merge 1 commit into
racket:masterfrom
LiberalArtist:fix-id-cookie

Conversation

@LiberalArtist

Copy link
Copy Markdown
Contributor

Not ready to merge.
Needs docs, tests, and a look at typed/web-server/http.

@LiberalArtist

Copy link
Copy Markdown
Contributor Author

Related to #74

@jeapostrophe

Copy link
Copy Markdown
Contributor

Good work!

@LiberalArtist

Copy link
Copy Markdown
Contributor Author

I should be able to finish this up in time for 7.5, but it may not be until the weekend, depending on how some other things go. (Branch day is Monday.)

@LiberalArtist LiberalArtist changed the title WIP web-server/http/id-cookie: accept string names+values, fix HMAC web-server/http/id-cookie: accept string names+values, fix HMAC Nov 11, 2019
@LiberalArtist

Copy link
Copy Markdown
Contributor Author

Sorry this is so much later than I'd planned: I had some family obligations come up unexpectedly.

@LiberalArtist
LiberalArtist marked this pull request as ready for review November 11, 2019 23:38
@LiberalArtist LiberalArtist changed the title web-server/http/id-cookie: accept string names+values, fix HMAC web-server/http/id-cookie: accept names & values as bytes; fix HMAC Nov 11, 2019
@LiberalArtist

Copy link
Copy Markdown
Contributor Author

I'm still thinking through what to do for typed/web-server/http:

  • I'm leaning toward not allowing Bytes for name and value arguments. In the untyped API, bytes are accepted for a mixture of consistency, backward-compatibility (per RenaissanceBug/racket-cookies@c745ee5), and "be liberal in what you accept." In the typed world, none of the cookie-related functions have ever accepted Bytes: changing that seems likely to cause more problems than it would solve, particularly in that it would make argument and result types different.
  • I'm conflicted about strengthening the type of the #:timeout argument for valid-id-cookie? and request-id-cookie to Real instead of Number. (A non-real #:timeout has always caused a runtime error: this PR just corrects that in the documentation and, in one case, the contract.) On the one hand, we made essentially the same change to response-seconds in racket/typed-racket@acf7707, and that seemed to go fine. On the other hand, it would cause some buggy programs that previously compiled to fail to typecheck: personally, if I'm using static types, it's because I want buggy programs to be rejected at compile-time, but in a strict sense it would be a breaking change. It may or may not be relevant that, usually, you don't actually want to be using the #:timeout argument (see 626ad02).

@LiberalArtist
LiberalArtist force-pushed the fix-id-cookie branch 2 times, most recently from 02f32da to 09bd5c7 Compare November 12, 2019 15:06
This commit changes the functions provided by `web-server/http/id-cookie`
to accept byte-strings for their name and value arguments (rather than
requiring strings) for consistency with other cookie-related functions:
see <RenaissanceBug/racket-cookies@c745ee5>.

Additionally, it fixes a bug which had caused cookie HMAC-SHA1 signatures
to be incorrectly truncated to 25 base64 digits, rather than 27,
since <racket@a5135d5>.

Other minor fixes:
- Corrects the documentatation for `valid-id-cookie?`
  and `request-id-cookie` to specify that the `#:timeout` argument
  must satisfy `real?` (not just `number?`).
- Changes the test suite for `make-secret-salt/file` to avoid needing write
  permissions for the directory where the collection is installed.

Increments the version of the `web-server-lib` package to `1.6`.

Closes racket#74
@jeapostrophe

Copy link
Copy Markdown
Contributor

I don't have a strong opinion about the types. I follow your logic.

@LiberalArtist

Copy link
Copy Markdown
Contributor Author

Subsumed by #84

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

Successfully merging this pull request may close these issues.

2 participants