Skip to content

Commit

Permalink
Add constant time compare to basic auth password (fixes #194)
Browse files Browse the repository at this point in the history
  • Loading branch information
kieranajp committed Oct 8, 2017
1 parent 9329ba1 commit d1fe91b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/plugin/basic/middleware.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package basic

import (
"crypto/subtle"
"net/http"

"github.com/hellofresh/janus/pkg/errors"
Expand Down Expand Up @@ -32,7 +33,7 @@ func NewBasicAuth(repo Repository) func(http.Handler) http.Handler {
}

for _, u := range users {
if username == u.Username && password == u.Password {
if username == u.Username && (subtle.ConstantTimeCompare([]byte(password), []byte(u.Password)) == 1) {
found = true
break
}
Expand Down

0 comments on commit d1fe91b

Please sign in to comment.