Documentation
¶
Overview ¶
Package auth is KnightLoader's optional password lock. Self-hosted means the instance often sits on a LAN where "anyone who can reach the port" is not the same as "anyone who should control the downloads".
It is off by default: a fresh install behaves exactly as before until a password is set. Sessions are signed cookies rather than a server-side table, so a restart does not log everyone out.
Index ¶
Constants ¶
const CookieName = "kl_session"
CookieName is the session cookie the browser sends back.
const SessionTTL = 30 * 24 * time.Hour
SessionTTL is how long a login lasts.
Variables ¶
var ( // ErrWrongPassword is returned when the supplied password does not match. ErrWrongPassword = errors.New("wrong password") // ErrTooShort rejects a password that is not worth having. ErrTooShort = errors.New("the password must be at least 8 characters") )
Functions ¶
This section is empty.
Types ¶
type Guard ¶
type Guard struct {
// contains filtered or unexported fields
}
Guard holds the password and signs sessions.
func (*Guard) SetPassword ¶
SetPassword sets, changes or (with an empty next) removes the password. When a password is already set, the current one has to be supplied — otherwise anyone with an open session could silently lock the owner out.