Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #17
Browse files Browse the repository at this point in the history
Fix password comparison
  • Loading branch information
bsrinivas8687 authored Nov 30, 2020
2 parents 76908e4 + 3365c4e commit a614c8e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cli/rest/auth/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package auth

import (
"crypto/rand"
"crypto/sha256"
"fmt"
"net/http"
"strings"
Expand All @@ -26,7 +27,8 @@ func HandlerLogin(ctx *context.Context) http.HandlerFunc {

auth := r.Header.Get("Authorization")
if auth == "" {
if body.Password != ctx.Config().Password {
password := fmt.Sprintf("%X", sha256.Sum256([]byte(body.Password)))
if password != ctx.Config().Password {
utils.WriteErrorToResponse(w, http.StatusUnauthorized, 3, "")
return
}
Expand Down

0 comments on commit a614c8e

Please sign in to comment.