use ConstantTimeCompare for password comparison (#549)
This commit is contained in:
parent
314d7e7e3f
commit
062dcf6306
1 changed files with 2 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package middleware
|
||||
|
||||
import (
|
||||
"crypto/subtle"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
|
@ -16,7 +17,7 @@ func BasicAuth(realm string, creds map[string]string) func(next http.Handler) ht
|
|||
}
|
||||
|
||||
credPass, credUserOk := creds[user]
|
||||
if !credUserOk || pass != credPass {
|
||||
if !credUserOk || subtle.ConstantTimeCompare([]byte(pass), []byte(credPass)) != 1 {
|
||||
basicAuthFailed(w, realm)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue