auth

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account interface {
	Get(AccountConstant) interface{}
	List() []AccountConstant
	Anonymous() bool
	Redirect(c *gin.Context)
}

Account is an interface that gives the application access to infos about the user.

type AccountConstant

type AccountConstant string

AccountConstant is an type for easier linting.

const (
	// AccountID is the ID of the session. Prefferably it should be an UUIDv4 to mitigate security errors.
	AccountID AccountConstant = "jti"
	// AccountAnon is to identify Sessions as Anonymous sessions.
	AccountAnon AccountConstant = "anon"
	// AccountUser is an attribute that identifies the user with an string that is unique for the user, for Example the username.
	AccountUser AccountConstant = "uid"
)

These are Constants to save specific attributes in single points of use.

type AnonAccount

type AnonAccount struct{}

AnonAccount is an simple Account-interface implementation. It is always Anonymous

func (*AnonAccount) Anonymous

func (*AnonAccount) Anonymous() bool

Anonymous is always true

func (*AnonAccount) Get

func (*AnonAccount) Get(key AccountConstant) (in interface{})

Get returns only AccountAnon = true

func (*AnonAccount) List

func (*AnonAccount) List() []AccountConstant

List return only AccountAnon as the only Listitem

func (*AnonAccount) Redirect

func (*AnonAccount) Redirect(c *gin.Context)

Redirect should point to an login, but since its not possible for this handler it sends an 401 Page

type AnonAccountHandler

type AnonAccountHandler struct{}

AnonAccountHandler is an simple struct that fullfills the AuthenticationHandler Interface

func (*AnonAccountHandler) Account

Account is an simple method that returns an Account that is always anonymous.

type AuthenticationHandler

type AuthenticationHandler interface {
	Account(*gin.Context) Account
}

AuthenticationHandler is an interface that is used to give the account of the request. it is set into the context using gin.Context.Set. The context must be reused for the redirect. Account NEVER returns nil. Not loggedin Users have return Anonymous() = true and get() = nil and List() = []string{}

Jump to

Keyboard shortcuts

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