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

Implement Rfc8941 #13

Closed
bblfish opened this issue Apr 10, 2021 · 4 comments
Closed

Implement Rfc8941 #13

bblfish opened this issue Apr 10, 2021 · 4 comments

Comments

@bblfish
Copy link
Member

bblfish commented Apr 10, 2021

RFC 8941 Structured Field Values for HTTP is a requirement of Signing Http Messages which is a requirement for HTTP Sig Authentication.

For the context on what RFC8941 brings see the very helpful blog post.

@bblfish
Copy link
Member Author

bblfish commented Apr 10, 2021

This was implemented and tested in two days and committed in fe12b81.
Code in Rfc8941.scala and tests are in Rfc8941_Test

cats-parse was a delight to use. I was able to write the whole parser in one go, from reading the spec, and the tests then just showed up some minor problems in the code.
Will test the architecture by using it in Signing HTTP Messages.

@bblfish
Copy link
Member Author

bblfish commented Apr 13, 2021

Canonical serialization of RFC8941 headers was pretty much finished by commit ab71456 . This is very important for HTTP Signatures.
Doing this helped clarify the data model, especially sfDict which I had nearly got right the first time (see especially with dd01e5f).

Things remaining to be done could be:
use native types link Long instead of IntStr and BigDecimal rather that DecStr.

@bblfish
Copy link
Member Author

bblfish commented Apr 14, 2021

use native types link Long instead of IntStr and BigDecimal rather that DecStr.

Using native types like Long and hiding them with opaque type does not work so well when refining types, as the refinement constraints are lost at compile time, where they would be needed. I.e. an opaque subtype of string for ASCII strings, would check for constraints at compile time, but could not stop a normal string being passed in a pattern match. Libraries like Refined could be useful here...

To get going and to avoid bringing in another library that soon, I built specific Sf* types with private constructors to make sure that they are always constructed. This should help make sure that no errors are inadvertently introduced during serialization.
See commit f62facd

@bblfish
Copy link
Member Author

bblfish commented Feb 26, 2022

The code for this has not been moved to the httpSig repository and generalised to compile to JS libs too.

@bblfish bblfish closed this as completed Feb 26, 2022
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