auth

package
v0.0.0-...-f7c0027 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SQLColumns the context key to store and retrieve the SQL fields permitted
	// to access by the partial policy query.
	SQLColumns = ContextField("sql fields")
	// SQLClause the context key to store and retrieve the SQL where clause
	// from a partial policy query.
	SQLClause = ContextField("sql clause")
	// SQLValues the context key to store and retrieve the SQL where clause
	// values from a partial policy query.
	SQLValues = ContextField("sql values")
)
View Source
const (
	// CurrentUser is the context key to store and retrieve the current logged in
	// user.
	CurrentUser = ContextField("user")
)
View Source
const (
	// SessionCookie is the name of the session cookie.
	SessionCookie = "session"
)

Variables

This section is empty.

Functions

func HandleCurrentUser

func HandleCurrentUser() http.HandlerFunc

HandleCurrentUser returns the user as stored in the context. Basically it returns the user associated with the active session.

func HandleLogin

func HandleLogin(db database.Instance, repo cache.Repository) http.HandlerFunc

HandleLogin is a request handler that checks credentials, and starts a session for an authorized user.

func HandleLogout

func HandleLogout(repo cache.Repository) http.HandlerFunc

func IfAllowed

func IfAllowed(e *policy.Enforcer, query string) func(next http.Handler) http.Handler

IfAllowed is a middleware that allows/denies access to the handler based on the policy. This is an all-or-nothing evaluation.

func IfPossible

func IfPossible(e *policy.Enforcer, query string, unknowns []string) func(next http.Handler) http.Handler

IfPossible is a middleware policy enforcer that can execute partial evaluations. If an action _could_ be permitted, the context will reflect which SQL fields are accessible, and contain a WHERE clause with values. The handler can use this information to restrict the SQL statement.

func WithSession

func WithSession(repo cache.Repository, required bool) func(next http.Handler) http.Handler

Types

type ContextField

type ContextField string

ContextField is a string type for storing auth fields in the context.

Jump to

Keyboard shortcuts

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