Documentation
¶
Overview ¶
Package auth checks Basic credentials against single and multiple accounts, validates proof-of-work answers and matches trusted proxies.
Index ¶
- Variables
- func CheckAuth(r *http.Request, user, passwd string, accountMap, authMap map[string]string) bool
- func CheckAuthWithAccountMap(u, p, user, passwd string, accountMap, authMap map[string]string) bool
- func DealMultiUser(s string) map[string]string
- func NeedsAuth(user, passwd string, accountMap, authMap map[string]string) bool
- func ParseBasicAuth(header string) (user, passwd string, ok bool)
- func ParseTrustedProxies(list string) *forwarded.PrefixSet
- func ValidatePoW(bits int, parts ...string) bool
Constants ¶
This section is empty.
Variables ¶
var AnyAddress = forwarded.NewPrefixSet(netip.MustParsePrefix("0.0.0.0/0"), netip.MustParsePrefix("::/0"))
AnyAddress is the set of every address.
Functions ¶
func CheckAuth ¶
CheckAuth validates the Basic credentials of a request to a reverse-proxied host. It reads Authorization and falls back to Proxy-Authorization only when the request carries no Authorization header at all.
func CheckAuthWithAccountMap ¶
CheckAuthWithAccountMap reports whether u and p log in. u current login user p current login passwd user global user passwd global passwd accountMap enable multi user auth
func DealMultiUser ¶
func NeedsAuth ¶
NeedsAuth reports whether any credential is configured. A username or a password on its own is enough to require authentication.
func ParseBasicAuth ¶
ParseBasicAuth parses a "Basic <base64(user:pass)>" credential. The scheme is matched case-insensitively and unpadded base64 is accepted.
func ParseTrustedProxies ¶
ParseTrustedProxies parses a comma-separated list of trusted proxies: IP addresses, CIDR prefixes, IPv4 patterns whose trailing octets are "*" (such as "192.168.*.*"), or "*" for every address. Entries that are none of these are skipped. Parse the list once, where the config is read.
func ValidatePoW ¶
Types ¶
This section is empty.