diff options
author | FChannel <> | 2022-06-05 21:36:17 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | dac4b267cab31fb3a4ce301f1bcdf364fcb541a1 (patch) | |
tree | 22852a6457e08f3ea047d2c20900db73c26e2fda | |
parent | 3ac22385f2cb2256db718e47f5ae3c6d13353b70 (diff) |
fix finger actor
-rw-r--r-- | activitypub/actor.go | 10 | ||||
-rw-r--r-- | activitypub/util.go | 8 | ||||
-rw-r--r-- | activitypub/webfinger.go | 12 | ||||
-rw-r--r-- | db/database.go | 12 | ||||
-rw-r--r-- | views/admin.html | 1 |
5 files changed, 23 insertions, 20 deletions
diff --git a/activitypub/actor.go b/activitypub/actor.go index c6283c8..e54088d 100644 --- a/activitypub/actor.go +++ b/activitypub/actor.go @@ -951,8 +951,7 @@ func (actor Actor) Verify(signature string, verify string) error { sig, _ := base64.StdEncoding.DecodeString(signature) if actor.PublicKey.PublicKeyPem == "" { - // TODO: this should be Finger but its not getting PublicKeyPem atm - _actor, err := GetActorFromDB(actor.Id) + _actor, err := FingerActor(actor.Id) if err != nil { return util.MakeError(err, "Verify") @@ -962,7 +961,12 @@ func (actor Actor) Verify(signature string, verify string) error { } block, _ := pem.Decode([]byte(actor.PublicKey.PublicKeyPem)) - pub, _ := x509.ParsePKIXPublicKey(block.Bytes) + + pub, err := x509.ParsePKIXPublicKey(block.Bytes) + + if err != nil { + return util.MakeError(err, "Verify") + } hashed := sha256.New() hashed.Write([]byte(verify)) diff --git a/activitypub/util.go b/activitypub/util.go index f53d8e5..274493f 100644 --- a/activitypub/util.go +++ b/activitypub/util.go @@ -282,6 +282,12 @@ func GetActorByNameFromDB(name string) (Actor, error) { return nActor, util.MakeError(err, "GetActorByNameFromDB") } + nActor.PublicKey, err = GetActorPemFromDB(publicKeyPem) + + if err != nil { + return nActor, util.MakeError(err, "GetActorFromDB") + } + if nActor.Id != "" && nActor.PublicKey.PublicKeyPem == "" { if err := CreatePublicKeyFromPrivate(&nActor, publicKeyPem); err != nil { return nActor, util.MakeError(err, "GetActorByNameFromDB") @@ -345,7 +351,7 @@ func GetActorFromDB(id string) (Actor, error) { err := config.DB.QueryRow(query, id).Scan(&nActor.Type, &nActor.Id, &nActor.Name, &nActor.PreferredUsername, &nActor.Inbox, &nActor.Outbox, &nActor.Following, &nActor.Followers, &nActor.Restricted, &nActor.Summary, &publicKeyPem) if err != nil { - return nActor, util.MakeError(err, "GetActorFromDB") + return nActor, nil } nActor.PublicKey, err = GetActorPemFromDB(publicKeyPem) diff --git a/activitypub/webfinger.go b/activitypub/webfinger.go index 276a791..8dce506 100644 --- a/activitypub/webfinger.go +++ b/activitypub/webfinger.go @@ -122,20 +122,22 @@ func FingerRequest(actor string, instance string) (*http.Response, error) { if len(finger.Links) > 0 { for _, e := range finger.Links { if e.Type == "application/activity+json" { - req, err := http.NewRequest("GET", e.Href, nil) + req, err = http.NewRequest("GET", e.Href, nil) if err != nil { return resp, util.MakeError(err, "FingerRequest") } - req.Header.Set("Accept", config.ActivityStreams) - resp, _ := util.RouteProxy(req) - - return resp, nil + break } } } + req.Header.Set("Accept", config.ActivityStreams) + if resp, err = util.RouteProxy(req); err != nil { + return resp, util.MakeError(err, "FingerRequest") + } + return resp, nil } diff --git a/db/database.go b/db/database.go index 2c42cf5..830edc5 100644 --- a/db/database.go +++ b/db/database.go @@ -85,7 +85,7 @@ func CreateNewBoard(actor activitypub.Actor) (activitypub.Actor, error) { } } - { + if actor.Id == config.Domain { var verify util.Verify verify.Type = "admin" verify.Identifier = actor.Id @@ -95,16 +95,6 @@ func CreateNewBoard(actor activitypub.Actor) (activitypub.Actor, error) { } } - { - var verify util.Verify - verify.Type = "janitor" - verify.Identifier = actor.Id - - if err := actor.CreateVerification(verify); err != nil { - return activitypub.Actor{}, util.MakeError(err, "CreateNewBoardDB") - } - } - activitypub.CreatePem(actor) if actor.Name != "main" { diff --git a/views/admin.html b/views/admin.html index 8c784b5..e490704 100644 --- a/views/admin.html +++ b/views/admin.html @@ -70,6 +70,7 @@ {{ end }} </ul> {{ end }} +</div> <!-- <div id="reported" class="popup-box" style="margin-bottom: 25px; padding: 12px;"> --> <!-- <h4 style="margin: 0; margin-bottom: 5px;">Reported</h4> --> |