1
1
mirror of https://github.com/go-gitea/gitea synced 2024-06-13 14:55:50 +00:00

Code cleanup

This commit is contained in:
Anthony Wang 2022-06-11 21:15:45 -05:00
parent 7658649d61
commit 6074222377
No known key found for this signature in database
GPG Key ID: BC96B00AEC5F2D76
3 changed files with 7 additions and 7 deletions

View File

@ -32,8 +32,6 @@ func TestActivityPubPerson(t *testing.T) {
resp := MakeRequest(t, req, http.StatusOK)
body := resp.Body.Bytes()
assert.Contains(t, string(body), "@context")
var m map[string]interface{}
DecodeJSON(t, resp, &m)
var person ap.Person
err := person.UnmarshalJSON(body)

View File

@ -28,7 +28,7 @@ func getPublicKeyFromResponse(ctx context.Context, b []byte, keyID *url.URL) (p
person := ap.PersonNew(ap.IRI(keyID.String()))
err = person.UnmarshalJSON(b)
if err != nil {
err = fmt.Errorf("ActivityStreams type cannot be converted to one known to have publicKey property: %T", b)
err = fmt.Errorf("ActivityStreams type cannot be converted to one known to have publicKey property: %v", err)
return
}
pkey := person.PublicKey
@ -50,7 +50,7 @@ func fetch(iri *url.URL) (b []byte, err error) {
req := httplib.NewRequest(iri.String(), http.MethodGet)
req.Header("Accept", activitypub.ActivityStreamsContentType)
req.Header("Accept-Charset", "utf-8")
req.Header("Date", fmt.Sprintf("%s GMT", time.Now().UTC().Format(time.RFC1123)))
req.Header("Date", fmt.Sprintf("%s UTC", time.Now().UTC().Format(time.RFC1123)))
resp, err := req.Response()
if err != nil {
return
@ -89,7 +89,7 @@ func verifyHTTPSignatures(ctx *gitea_context.APIContext) (authenticated bool, er
}
// 3. Verify the other actor's key
algo := httpsig.Algorithm(setting.Federation.Algorithms[0])
authenticated = nil == v.Verify(pKey, algo)
authenticated = v.Verify(pKey, algo) == nil
return
}

View File

@ -645,8 +645,10 @@ func Routes() *web.Route {
if setting.Federation.Enabled {
m.Get("/nodeinfo", misc.NodeInfo)
m.Group("/activitypub", func() {
m.Get("/user/{username}", activitypub.Person)
m.Post("/user/{username}/inbox", activitypub.ReqSignature(), activitypub.PersonInbox)
m.Group("/user/{username}", func() {
m.Get("", activitypub.Person)
m.Post("/inbox", activitypub.ReqSignature(), activitypub.PersonInbox)
})
})
}
m.Get("/signing-key.gpg", misc.SigningKey)