[chore] Return more useful errors from auth failure (#494)

* try rsa_sha256 sig algo first

* return more informative errors from auth

* adapt to reworked auth function
This commit is contained in:
tobi 2022-04-26 18:10:11 +02:00 committed by GitHub
commit 9cf66bf298
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 92 additions and 65 deletions

View file

@ -20,7 +20,6 @@ package federation
import (
"context"
"errors"
"fmt"
"net/url"
@ -38,9 +37,9 @@ func (p *processor) GetStatusReplies(ctx context.Context, requestedUsername stri
}
// authenticate the request
requestingAccountURI, authenticated, err := p.federator.AuthenticateFederatedRequest(ctx, requestedUsername)
if err != nil || !authenticated {
return nil, gtserror.NewErrorNotAuthorized(errors.New("not authorized"), "not authorized")
requestingAccountURI, errWithCode := p.federator.AuthenticateFederatedRequest(ctx, requestedUsername)
if errWithCode != nil {
return nil, errWithCode
}
requestingAccount, err := p.federator.GetRemoteAccount(ctx, requestedUsername, requestingAccountURI, false, false)