aboutsummaryrefslogtreecommitdiff
path: root/verification.go
diff options
context:
space:
mode:
authorFChannel <>2021-06-25 01:39:50 -0700
committerFChannel <>2021-06-25 01:39:50 -0700
commit3b806e4603a7da8bb6a24029a0115e18a6b7ba5b (patch)
tree1616572f47ebf68e52bb1b0d0eff942c72fa9d9c /verification.go
parentef7eb7330018c84a44fb24711982c25f51749d2e (diff)
expanded header signature support to known possible values at this time
Diffstat (limited to 'verification.go')
-rw-r--r--verification.go31
1 files changed, 26 insertions, 5 deletions
diff --git a/verification.go b/verification.go
index 3215688..7c634e1 100644
--- a/verification.go
+++ b/verification.go
@@ -38,6 +38,7 @@ type Signature struct {
KeyId string
Headers []string
Signature string
+ Algorithm string
}
func DeleteBoardMod(db *sql.DB, verify Verify) {
@@ -606,10 +607,12 @@ func ActivityVerify(actor Actor, signature string, verify string) error {
func VerifyHeaderSignature(r *http.Request, actor Actor) bool {
s := ParseHeaderSignature(r.Header.Get("Signature"))
- var method string
- var path string
- var host string
- var date string
+ var method string
+ var path string
+ var host string
+ var date string
+ var digest string
+ var contentLength string
var sig string
for _, e := range s.Headers {
@@ -630,7 +633,19 @@ func VerifyHeaderSignature(r *http.Request, actor Actor) bool {
date = r.Header.Get("date")
sig += "date: " + date
continue
- }
+ }
+
+ if e == "digest" {
+ digest = r.Header.Get("digest")
+ sig += "digest: " + digest
+ continue
+ }
+
+ if e == "content-length" {
+ contentLength = r.Header.Get("content-length")
+ sig += "content-length: " + contentLength
+ continue
+ }
}
if s.KeyId != actor.PublicKey.Id {
@@ -656,6 +671,7 @@ func ParseHeaderSignature(signature string) Signature {
keyId := regexp.MustCompile(`keyId=`)
headers := regexp.MustCompile(`headers=`)
sig := regexp.MustCompile(`signature=`)
+ algo := regexp.MustCompile(`algorithm=`)
signature = strings.ReplaceAll(signature, "\"", "")
parts := strings.Split(signature, ",")
@@ -676,6 +692,11 @@ func ParseHeaderSignature(signature string) Signature {
nsig.Signature = sig.ReplaceAllString(e, "")
continue
}
+
+ if algo.MatchString(e) {
+ nsig.Algorithm = algo.ReplaceAllString(e, "")
+ continue
+ }
}
return nsig