auth

package
v0.35.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: GPL-3.0 Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package auth checks Basic credentials against single and multiple accounts, validates proof-of-work answers and matches trusted proxies.

Index

Constants

This section is empty.

Variables

View Source
var AnyAddress = forwarded.NewPrefixSet(netip.MustParsePrefix("0.0.0.0/0"), netip.MustParsePrefix("::/0"))

AnyAddress is the set of every address.

Functions

func CheckAuth

func CheckAuth(r *http.Request, user, passwd string, accountMap, authMap map[string]string) bool

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

func CheckAuthWithAccountMap(u, p, user, passwd string, accountMap, authMap map[string]string) bool

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 DealMultiUser(s string) map[string]string

func NeedsAuth

func NeedsAuth(user, passwd string, accountMap, authMap map[string]string) bool

NeedsAuth reports whether any credential is configured. A username or a password on its own is enough to require authentication.

func ParseBasicAuth

func ParseBasicAuth(header string) (user, passwd string, ok bool)

ParseBasicAuth parses a "Basic <base64(user:pass)>" credential. The scheme is matched case-insensitively and unpadded base64 is accepted.

func ParseTrustedProxies

func ParseTrustedProxies(list string) *forwarded.PrefixSet

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

func ValidatePoW(bits int, parts ...string) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL