Documentation
¶
Overview ¶
Package auth provides the role-based access model shared by tie-triplestore and tie-filehost: read/write roles, per-request access classification, and HTTP Basic Auth resolution with constant-time password comparison.
Passwords are stored in plaintext in each server's config (operator-managed secrecy); only the wire comparison is hardened. A Store is read-only after construction and safe for concurrent use.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Role ¶
type Role int
Role is an access tier. Roles are totally ordered (RoleNone < RoleRead < RoleWrite) and a higher role subsumes every lower one: write implies read.
func ParseAnonAccess ¶
ParseAnonAccess parses the AnonymousAccess config value — the role granted to a request that presents no valid credentials. An empty string returns def, the per-server default.
func ParseUserRole ¶
ParseUserRole parses a per-user Role config value. An empty string defaults to RoleWrite so accounts predating roles keep full read+write access.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store resolves a request's role from HTTP Basic Auth credentials.
func NewStore ¶
NewStore builds a Store from a username->User map and the anonymous role granted to unauthenticated or invalid requests.
func (*Store) Authorize ¶
Authorize reports whether a request may perform access a. When it may not, status is the HTTP status to return: 401 when authentication is missing or failed (no credentials, unknown user, wrong password), or 403 when a valid user authenticated but its role is too low.
func (*Store) Require ¶
func (s *Store) Require(a Access, h http.HandlerFunc) http.HandlerFunc
Require wraps h so it runs only when the request satisfies the access level. A 401 rejection carries a Basic-Auth challenge.