auth

package
v0.0.0-...-dcf7d21 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentUser

func CurrentUser(r *http.Request) *users.User

func CurrentUserHasPermission

func CurrentUserHasPermission(r *http.Request, perm permissions.Permission) bool

Types

type Config

type Config struct {
	Prefix              string // The prefix string used for our API calls
	PasswordFilePath    string // Location of our password database file
	MaxClockSkewSeconds int
}

type Handler

type Handler struct {
	ApiHandler http.Handler
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(c *Config) Handler

func (*Handler) CreatePasswordFile

func (h *Handler) CreatePasswordFile() error

func (*Handler) RequireAuth

func (h *Handler) RequireAuth(httpHandler http.Handler) http.Handler

func (*Handler) UpdatePassword

func (h *Handler) UpdatePassword(userid, password string) error

Set a password for a user into our password database. We don't save the plaintext password, we concatenate the userid with the raw password, take the sha256sum of that, and store that in our database.

func (*Handler) UpdateUserPassword

func (h *Handler) UpdateUserPassword(userid string) error

Read a password from the terminal and pass it to UpdatePassword.

type LoginStatus

type LoginStatus struct {
	LoggedIn    bool
	Permissions string
}

type Token

type Token struct {
	Key string
	// contains filtered or unexported fields
}

func (*Token) User

func (t *Token) User() *users.User

Jump to

Keyboard shortcuts

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