Merge branch 'fixN00bTypo' into 'master'

Fix typo: peeper => pepper



See merge request !8
This commit is contained in:
Nicolas Duhamel 2016-06-10 21:46:54 +00:00
commit a4cabe7711
5 changed files with 11 additions and 11 deletions

View File

@ -38,11 +38,11 @@ type Params struct {
Backend UserBackend
Cookiejar *sessions.CookieStore
CookieName string
Peeper string
Pepper string
Cost int
}
// New Authorizer peeper is like a salt but not stored in database,
// New Authorizer pepper is like a salt but not stored in database,
// cost is the bcrypt cost for hashing the password
func New(params Params) *Authorizer {
return &Authorizer{
@ -52,7 +52,7 @@ func New(params Params) *Authorizer {
// GenHash generates a new hash from a password
func (a *Authorizer) GenHash(password string) (string, error) {
b, err := bcrypt.GenerateFromPassword([]byte(password+a.Peeper), a.Cost)
b, err := bcrypt.GenerateFromPassword([]byte(password+a.Pepper), a.Cost)
if err != nil {
return "", err
}
@ -71,7 +71,7 @@ func (a *Authorizer) Login(rw http.ResponseWriter, req *http.Request, username,
return err
}
err = bcrypt.CompareHashAndPassword([]byte(u.GetHash()), []byte(password+a.Peeper))
err = bcrypt.CompareHashAndPassword([]byte(u.GetHash()), []byte(password+a.Pepper))
if err != nil {
return ErrInvalidPassword
}

View File

@ -13,7 +13,7 @@ import (
)
const (
peeper = "polp"
pepper = "polp"
ckey = "plop"
cookieName = "auth"
cost = 10
@ -55,7 +55,7 @@ func getBackend() *Backend {
}
func login(w http.ResponseWriter, r *http.Request) {
a := New(getBackend(), peeper, cookieName, ckey, cost)
a := New(getBackend(), pepper, cookieName, ckey, cost)
err := a.Login(w, r, username, password)
if err != nil {
fmt.Fprintf(w, "%s", err)
@ -66,7 +66,7 @@ func login(w http.ResponseWriter, r *http.Request) {
}
func logout(w http.ResponseWriter, r *http.Request) {
a := New(getBackend(), peeper, cookieName, ckey, cost)
a := New(getBackend(), pepper, cookieName, ckey, cost)
err := a.Logout(w, r)
if err != nil {
fmt.Fprintf(w, "%s", err)
@ -76,7 +76,7 @@ func logout(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}
func check(w http.ResponseWriter, r *http.Request) {
a := New(getBackend(), peeper, cookieName, key, cost)
a := New(getBackend(), pepper, cookieName, key, cost)
u, err := a.CurrentUser(w, r)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)

View File

@ -1,7 +1,7 @@
authorizer:
cookie_name: auth
cookie_key: mysecretkey
peeper: peeper
pepper: pepper
cost: 10
pgdsn: postgres://test:test@127.0.0.1:5432/dev?sslmode=disable
trakttv_client_id: my_trakttv_client_id

View File

@ -17,7 +17,7 @@ type Config struct {
type AuthorizerConfig struct {
CookieName string `yaml:"cookie_name"`
Key string `yaml:"cookie_key"`
Peeper string `yaml:"peeper"`
Pepper string `yaml:"pepper"`
Cost int `yaml:"cost"`
}

View File

@ -39,7 +39,7 @@ func main() {
authParams := auth.Params{
Backend: uBackend,
Peeper: cf.Authorizer.Peeper,
Pepper: cf.Authorizer.Pepper,
CookieName: cf.Authorizer.CookieName,
Cookiejar: sessions.NewCookieStore([]byte(cf.Authorizer.Key)),
Cost: cf.Authorizer.Cost,