Skip to content

Commit

Permalink
Remove unnecessary conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
justinas committed Jun 1, 2014
1 parent 85a9cfa commit 12a7749
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions basic_auth.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package httpauth

import (
"bytes"
"crypto/sha256"
"crypto/subtle"
"encoding/base64"
Expand Down Expand Up @@ -63,12 +64,12 @@ func (b *basicAuth) authenticate(r *http.Request) bool {
// Split on the first ":" character only, with any subsequent colons assumed to be part
// of the password. Note that the RFC2617 standard does not place any limitations on
// allowable characters in the password.
creds := strings.SplitN(string(str), ":", 2)
creds := bytes.SplitN(str, []byte(":"), 2)

// Equalize lengths of supplied and required credentials
// by hashing them
givenUser := sha256.Sum256([]byte(creds[0]))
givenPass := sha256.Sum256([]byte(creds[1]))
givenUser := sha256.Sum256(creds[0])
givenPass := sha256.Sum256(creds[1])
requiredUser := sha256.Sum256([]byte(b.opts.User))
requiredPass := sha256.Sum256([]byte(b.opts.Password))

Expand Down

0 comments on commit 12a7749

Please sign in to comment.