Skip to content

Commit

Permalink
remove useless logger for httpserver.VerifyRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Jun 10, 2022
1 parent e527a8f commit c706efb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions httpserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Server interface {

// VerifyRequest implements the verification side of the discord interactions api signing algorithm, as documented here: https://discord.com/developers/docs/interactions/slash-commands#security-and-authorization
// Credit: https://github.com/bsdlp/discord-interactions-go/blob/main/interactions/verify.go
func VerifyRequest(logger log.Logger, r *http.Request, key PublicKey) bool {
func VerifyRequest(r *http.Request, key PublicKey) bool {
var msg bytes.Buffer

signature := r.Header.Get("X-Signature-Ed25519")
Expand All @@ -64,10 +64,7 @@ func VerifyRequest(logger log.Logger, r *http.Request, key PublicKey) bool {
msg.WriteString(timestamp)

defer func() {
err = r.Body.Close()
if err != nil {
logger.Error("error while closing request body: ", err)
}
_ = r.Body.Close()
}()
var body bytes.Buffer

Expand Down
2 changes: 1 addition & 1 deletion httpserver/server_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const (
)

func (h *WebhookInteractionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if ok := VerifyRequest(h.server.Logger(), r, h.server.PublicKey()); !ok {
if ok := VerifyRequest(r, h.server.PublicKey()); !ok {
w.WriteHeader(http.StatusUnauthorized)
data, _ := io.ReadAll(r.Body)
h.server.Logger().Trace("received http interaction with invalid signature. body: ", string(data))
Expand Down

0 comments on commit c706efb

Please sign in to comment.