Documentation
¶
Overview ¶
Package login is the session: log in, log out, and who is asking.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
func Handler(db bun.IDB, mode domain.ServerMode) http.HandlerFunc
Handler logs in: POST /api/login. The session token goes in an HttpOnly cookie, in the body only when the input asks it (the CLI). The multi mode needs the account's name. @Summary Log in @Tags session @Accept json @Produce json @Param body body createsession.Input true "body" @Success 200 {object} createsession.Result @Failure 400 {object} respond.Failure @Failure 401 {object} respond.Failure @Failure 429 {object} respond.Failure @Router /api/login [post]
func Logout ¶
func Logout(db bun.IDB) http.HandlerFunc
Logout logs this device out: POST /api/logout. @Summary Log out @Tags session @Success 204 @Failure 401 {object} respond.Failure @Router /api/logout [post]
func Me ¶
func Me(db bun.IDB, mode domain.ServerMode) http.HandlerFunc
Me is who asks: GET /api/me. @Summary Who is asking @Tags session @Produce json @Success 200 {object} login.MeResult @Failure 401 {object} respond.Failure @Router /api/me [get]
Types ¶
type MeResult ¶
type MeResult struct {
Kind domain.TokenKind `json:"kind" enums:"session,api,oauth"`
Name string `json:"name,omitempty" binding:"optional"` // the token's, for an API token or an OAuth connection
User string `json:"user"` // the account's name
Admin bool `json:"admin"` // the account manages the others, in the multi mode
Mode string `json:"mode" enums:"single,multi"`
ReadOnly bool `json:"read_only"`
Version string `json:"version"`
}
MeResult is who asks: the kind of its token, whether it only reads, its account and the server's mode.