Documentation
¶
Overview ¶
Package auth lets through the requests of a logged-in account only, and tells the routes which one.
Index ¶
Constants ¶
const ReadOnlyHeader = "Notes-Read-Only"
ReadOnlyHeader is set to "true" on the answers to a read-only API token.
Variables ¶
var Cookie = config.Current.Name + "_session"
Cookie holds the session token of the web app: HttpOnly, page scripts never see it.
Functions ¶
func New ¶
New runs next with the account of the request's session in its context: the cookie, or a "Authorization: Bearer <token>" header for scripts, a session token or an API token. Without a valid one, 401.
func Reads ¶ added in v1.44.0
Reads tells a request that changes nothing: a GET, or a POST of readRoutes.
func SetCookie ¶
func SetCookie(w http.ResponseWriter, token string, expires time.Time)
SetCookie gives the browser the session token until expires; a zero time deletes it. Secure works on http://localhost too: browsers count it as a secure context.
Types ¶
This section is empty.