solid / authentication-panel

GitHub repository for the Solid Authentication Panel
MIT License
11 stars 15 forks source link

can `keyid` really hold a URL? #164

Closed bblfish closed 3 years ago

bblfish commented 3 years ago

In Signing HTTP Messages v04 the keyid parameter of the Signature-Input is specifed to be of type sf-string. This is defined in RFC8941

sf-string = DQUOTE *chr DQUOTE
chr       = unescaped / escaped
unescaped = %x20-21 / %x23-5B / %x5D-7E
escaped   = "\" ( DQUOTE / "\" )

and a little later

Note that Strings only use DQUOTE as a delimiter; single quotes do not delimit Strings. Furthermore, only DQUOTE and "\" can be escaped; other characters after "\" MUST cause parsing to fail.

Unicode is not directly supported in Strings, because it causes a number of interoperability issues, and -- with few exceptions -- field values do not require it.

When it is necessary for a field value to convey non-ASCII content, a Byte Sequence (Section 3.3.5) can be specified, along with a character encoding (preferably UTF-8 [STD63]).

This means that if one is to place a URL in the keyid field it needs to be encoded. What is the best encoding? URL-encoding? That does not look that good.

val foaf = "https://xmlns.com/foaf/0.1/knows"
java.net.URLEncoder.encode(foaf)
res8: String = "https%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2Fknows"

One could add a different field and base64 encode a URL as an sf-byte-sequence

Base64.getEncoder.encodeToString(foaf.getBytes)
res10: String = "aHR0cHM6Ly94bWxucy5jb20vZm9hZi8wLjEv"

Any other ideas? Could one use the encoding of URLs used in HTTP headers? What are those?

bblfish commented 3 years ago

Looking around the spec text that I think addresses this is RFC3987 Internationalized Resource Identifiers §3.1. The Link header RFC only talks in terms of URIs. So the reference should probably be the URI spec.

The right code is the something like the following in the ammonite or scala shell

@ new java.net.URI("https://anaïs.eu/🤍/cats/")
res13: java.net.URI = https://anaïs.eu/🤍/cats/
@ res13.toASCIIString
res15: String = "https://ana%C3%AFs.eu/%F0%9F%A4%8D/cats/"
bblfish commented 3 years ago

I think the above answered my question