mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
6fde3632ef
The vendor/ folder was created with the help of @FiloSottile's gvt and vendorcheck. Any dependencies of Caddy plugins outside this repo are not vendored. We do not remove any unused, vendored packages because vendorcheck -u only checks using the current build configuration; i.e. packages that may be imported by files toggled by build tags of other systems. CI tests have been updated to ignore the vendor/ folder. When Go 1.9 is released, a few of the go commands should be revised to again use ./... as it will ignore the vendor folder by default.
28 lines
912 B
Go
28 lines
912 B
Go
package basic
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
type plainPassword struct {
|
|
password string
|
|
}
|
|
|
|
// Accept any password in the plain text encoding.
|
|
// Be careful: This matches any line, so it *must* be the last parser in you list.
|
|
func AcceptPlain(pw string) (EncodedPasswd, error) {
|
|
return &plainPassword{pw}, nil
|
|
}
|
|
|
|
// Reject any plain text encoded passoword.
|
|
// Be careful: This matches any line, so it *must* be the last parser in you list.
|
|
func RejectPlain(pw string) (EncodedPasswd, error) {
|
|
return nil, fmt.Errorf("plain password rejected: %s", pw)
|
|
}
|
|
|
|
func (p *plainPassword) MatchesPassword(pw string) bool {
|
|
// Notice: nginx prefixes plain passwords with {PLAIN}, so we see if that would
|
|
// let us match too. I'd split {PLAIN} off, but someone probably uses that
|
|
// in their password. It's a big planet.
|
|
return constantTimeEquals(pw, p.password) || constantTimeEquals("{PLAIN}"+pw, p.password)
|
|
}
|