summaryrefslogtreecommitdiff
path: root/internal/api/security
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-09-16 11:35:09 +0200
committerLibravatar GitHub <noreply@github.com>2021-09-16 11:35:09 +0200
commit92186c8c6f1c374146f085b46a440b69a1d97aa8 (patch)
tree06d7aea58ee399c4939ffa9052bcc548427cbfa4 /internal/api/security
parentFix mentions not notifying (#230) (diff)
downloadgotosocial-92186c8c6f1c374146f085b46a440b69a1d97aa8.tar.xz
federated authentication better logging + tidying (#232)
* change trace logging in authenticator * messing about * lil changes * go fmt * error fix * Fix broken test
Diffstat (limited to 'internal/api/security')
-rw-r--r--internal/api/security/signaturecheck.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/internal/api/security/signaturecheck.go b/internal/api/security/signaturecheck.go
index 71e539e96..be8c87c0d 100644
--- a/internal/api/security/signaturecheck.go
+++ b/internal/api/security/signaturecheck.go
@@ -11,13 +11,10 @@ import (
// SignatureCheck checks whether an incoming http request has been signed. If so, it will check if the domain
// that signed the request is permitted to access the server. If it is permitted, the handler will set the key
-// verifier in the gin context for use down the line.
+// verifier and the signature in the gin context for use down the line.
func (m *Module) SignatureCheck(c *gin.Context) {
l := m.log.WithField("func", "DomainBlockChecker")
- // set this extra field for signature validation
- c.Request.Header.Set("host", m.config.Host)
-
// create the verifier from the request
// if the request is signed, it will have a signature header
verifier, err := httpsig.NewVerifier(c.Request)
@@ -43,8 +40,12 @@ func (m *Module) SignatureCheck(c *gin.Context) {
return
}
- // set the verifier on the context here to save some work further down the line
+ // set the verifier and signature on the context here to save some work further down the line
c.Set(string(util.APRequestingPublicKeyVerifier), verifier)
+ signature := c.GetHeader("Signature")
+ if signature != "" {
+ c.Set(string(util.APRequestingPublicKeySignature), signature)
+ }
}
}
}