auth

package
v1.3.15 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 11 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 lets through the requests of a logged-in account only, and tells the routes which one.

Index

Constants

View Source
const ReadOnlyHeader = "Notes-Read-Only"

ReadOnlyHeader is set to "true" on the answers to a read-only API token.

Variables

View Source
var Cookie = config.Current.Name + "_session"

Cookie holds the session token of the web app: HttpOnly, page scripts never see it.

Functions

func New

func New(db bun.IDB, next http.Handler) http.Handler

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 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.

func Token

func Token(r *http.Request) string

Token is the request's session token, "" without one.

Types

This section is empty.

Jump to

Keyboard shortcuts

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