Webfinger + Small fixes (#20)

This commit is contained in:
Tobi Smethurst
2021-05-09 20:34:27 +02:00
committed by GitHub
parent 41915ab371
commit dc338dc881
16 changed files with 246 additions and 40 deletions

View File

@ -112,6 +112,9 @@ func getPublicKeyFromResponse(c context.Context, b []byte, keyID *url.URL) (voca
// Also note that this function *does not* dereference the remote account that the signature key is associated with.
// Other functions should use the returned URL to dereference the remote account, if required.
func (f *federator) AuthenticateFederatedRequest(username string, r *http.Request) (*url.URL, error) {
// set this extra field for signature validation
r.Header.Set("host", f.config.Host)
verifier, err := httpsig.NewVerifier(r)
if err != nil {
return nil, fmt.Errorf("could not create http sig verifier: %s", err)
@ -208,7 +211,11 @@ func (f *federator) DereferenceRemoteAccount(username string, remoteAccountID *u
}
return p, nil
case string(gtsmodel.ActivityStreamsApplication):
// TODO: convert application into person
p, ok := t.(vocab.ActivityStreamsApplication)
if !ok {
return nil, errors.New("error resolving type as activitystreams application")
}
return p, nil
}
return nil, fmt.Errorf("type name %s not supported", t.GetTypeName())