You've already forked oauth2-proxy
mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-06-19 00:27:39 +02:00
Add comments to exported methods for root package
This commit is contained in:
@ -14,10 +14,12 @@ import (
|
||||
// Lookup passwords in a htpasswd file
|
||||
// Passwords must be generated with -B for bcrypt or -s for SHA1.
|
||||
|
||||
// HtpasswdFile represents the structure of an htpasswd file
|
||||
type HtpasswdFile struct {
|
||||
Users map[string]string
|
||||
}
|
||||
|
||||
// NewHtpasswdFromFile constructs an HtpasswdFile from the file at the path given
|
||||
func NewHtpasswdFromFile(path string) (*HtpasswdFile, error) {
|
||||
r, err := os.Open(path)
|
||||
if err != nil {
|
||||
@ -27,6 +29,7 @@ func NewHtpasswdFromFile(path string) (*HtpasswdFile, error) {
|
||||
return NewHtpasswd(r)
|
||||
}
|
||||
|
||||
// NewHtpasswd consctructs an HtpasswdFile from an io.Reader (opened file)
|
||||
func NewHtpasswd(file io.Reader) (*HtpasswdFile, error) {
|
||||
csvReader := csv.NewReader(file)
|
||||
csvReader.Comma = ':'
|
||||
@ -44,6 +47,7 @@ func NewHtpasswd(file io.Reader) (*HtpasswdFile, error) {
|
||||
return h, nil
|
||||
}
|
||||
|
||||
// Validate checks a users password against the HtpasswdFile entries
|
||||
func (h *HtpasswdFile) Validate(user string, password string) bool {
|
||||
realPassword, exists := h.Users[user]
|
||||
if !exists {
|
||||
|
Reference in New Issue
Block a user