htpasswd: refactor and add Passwd methods #3
Merged
amery
merged 1 commits from pr-karasz-refactor
into master
1 year ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'pr-karasz-refactor'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Signed-off-by: Nagy Károly Gábriel k@jpi.io
please see comments
if err != nil {
return err
}
newpp, err := pp.CreateUser(user, passwd, algo)
as it's a map, newpp and pp are actually the same map and both contain the new user.
if we really want a new map this should be via a
newpp, err := pp.Clone().AddUser(...)
}
// Byte will return the Passwd as a byte slice
func (pp Passwds) Byte() []byte {
standard is
Bytes()
as the returned value contains many.WriteTo()
is also a nice interfacereturn fmt.Errorf("unsupported hash algorithm %v", alg)
}
func identifyHash(h string) (HashAlgorithm, error) {
wouldn't it be better to return a split?
(algo, hash, bool)
?return apr1_crypt.New().Verify(hashedPassword, []byte(password))
}
func hashBcrypt(passwd string) (string, error) {
method of the algo sharing an interface?
return nil
}
func hashSha512(passwd string) (string, error) {
begging for the Hasher interface
func (pp Passwds) CreateUser(user, passwd string, algo HashAlgorithm) (Passwds, error) {
if _, exists := pp[user]; exists {
return fmt.Errorf("user %s already exists", user)
return nil, fmt.Errorf("user %s already exists", user)
we may want errors that can be tested without parsing the content
Not sure what you mean
usage or wrapping predefined errors so one can use errors.Is() and similar
56008698b2
to5f5cbeab4f
1 year agoafac3a836f
into master 1 year agoReviewers
afac3a836f
.