users

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: LGPL-3.0 Imports: 10 Imported by: 0

README

What does this directory DO?

This defines the common LocksmithUserInterface interface, as well as the base LocksmithUser structure.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocksmithUser

type LocksmithUser struct {
	ID               string                          `bson:"id"`
	Username         string                          `json:"username" bson:"username"`
	Email            string                          `json:"email" bson:"email"`
	PasswordInfo     authentication.PasswordInfo     `json:"-" bson:"password"`
	WebAuthnSessions []webauthn.SessionData          `json:"-" bson:"websessions"`
	PasswordSessions authentication.PasswordSessions `json:"-" bson:"sessions"`
	Magics           magic.MagicAuthentications      `json:"-" bson:"magic"`
	Role             string                          `json:"role" bson:"role"`
	MagicPermissions []string                        `json:"-" bson:"-"`
	ImMagic          bool                            `json:"-" bson:"-"`
	ImRegular        bool                            `json:"-" bson:"-"`
	LastLogin        time.Time                       `json:"-" bson:"-"`
}

func (LocksmithUser) AddNewWebAuthnCredential

func (u LocksmithUser) AddNewWebAuthnCredential(cred *webauthn.Credential)

func (LocksmithUser) CleanupOldMagicTokens added in v0.4.5

func (u LocksmithUser) CleanupOldMagicTokens(db database.DatabaseAccessor)

func (LocksmithUser) CreateMagicAuthenticationCode added in v0.4.5

func (u LocksmithUser) CreateMagicAuthenticationCode(db database.DatabaseAccessor, vars magic.MagicAuthenticationVariables) (string, error)

func (LocksmithUser) GenerateCookieValueFromSession

func (u LocksmithUser) GenerateCookieValueFromSession(session authentication.PasswordSession) string

func (LocksmithUser) GeneratePasswordSession

func (u LocksmithUser) GeneratePasswordSession() (authentication.PasswordSession, error)

func (LocksmithUser) GetEmail

func (u LocksmithUser) GetEmail() string

func (LocksmithUser) GetID

func (u LocksmithUser) GetID() string

func (LocksmithUser) GetLastLoginDate added in v0.8.0

func (u LocksmithUser) GetLastLoginDate() time.Time

func (LocksmithUser) GetMagicPermissions added in v0.4.5

func (u LocksmithUser) GetMagicPermissions() []string

func (LocksmithUser) GetMagics added in v0.4.5

func (u LocksmithUser) GetMagics() []magic.MagicAuthentication

func (LocksmithUser) GetPasswordInfo

func (u LocksmithUser) GetPasswordInfo() authentication.PasswordInfo

func (LocksmithUser) GetPasswordSessions

func (u LocksmithUser) GetPasswordSessions() []authentication.PasswordSession

func (LocksmithUser) GetRole

func (u LocksmithUser) GetRole() (roles.Role, error)

func (LocksmithUser) GetUsername

func (u LocksmithUser) GetUsername() string

func (LocksmithUser) GetWebAuthnSessions

func (u LocksmithUser) GetWebAuthnSessions() []webauthn.SessionData

func (LocksmithUser) IsMagic added in v0.4.5

func (u LocksmithUser) IsMagic() bool

func (LocksmithUser) ReadFromMap

func (u LocksmithUser) ReadFromMap(writeTo *LocksmithUserInterface, user map[string]interface{})

func (LocksmithUser) SavePasswordSession

func (u LocksmithUser) SavePasswordSession(session authentication.PasswordSession, db database.DatabaseAccessor) error

func (LocksmithUser) SetMagic added in v0.4.5

func (u LocksmithUser) SetMagic() LocksmithUser

func (LocksmithUser) SetMagicPermissions added in v0.4.5

func (u LocksmithUser) SetMagicPermissions(permissions []string) LocksmithUserInterface

func (LocksmithUser) ToMap added in v0.3.0

func (u LocksmithUser) ToMap() map[string]interface{}

func (LocksmithUser) ToPublic

func (LocksmithUser) ValidatePassword

func (u LocksmithUser) ValidatePassword(inputPassword string) (bool, error)

func (LocksmithUser) ValidateSessionToken

func (u LocksmithUser) ValidateSessionToken(token string, db database.DatabaseAccessor) bool

func (LocksmithUser) WebAuthnCredentials

func (u LocksmithUser) WebAuthnCredentials() []webauthn.Credential

func (LocksmithUser) WebAuthnDisplayName

func (u LocksmithUser) WebAuthnDisplayName() string

func (LocksmithUser) WebAuthnID

func (u LocksmithUser) WebAuthnID() []byte

func (LocksmithUser) WebAuthnIcon

func (u LocksmithUser) WebAuthnIcon() string

func (LocksmithUser) WebAuthnName

func (u LocksmithUser) WebAuthnName() string

type LocksmithUserInterface

type LocksmithUserInterface interface {
	ValidatePassword(string) (bool, error)
	ValidateSessionToken(token string, db database.DatabaseAccessor) bool
	GeneratePasswordSession() (authentication.PasswordSession, error)
	SavePasswordSession(authentication.PasswordSession, database.DatabaseAccessor) error

	GetLastLoginDate() time.Time

	// Read from Database
	ReadFromMap(*LocksmithUserInterface, map[string]interface{})
	ToMap() map[string]interface{}

	// Convert to "public" interface
	// Slimmed down version of this interface
	// with less sensitive information
	ToPublic() (PublicLocksmithUserInterface, error)

	GetRole() (roles.Role, error)

	// Magic Auth stuff
	CleanupOldMagicTokens(database.DatabaseAccessor)
	SetMagicPermissions([]string) LocksmithUserInterface
	SetMagic() LocksmithUser // Denotes the user as a "magic only" user
	CreateMagicAuthenticationCode(database.DatabaseAccessor, magic.MagicAuthenticationVariables) (string, error)
	GetMagicPermissions() []string
	IsMagic() bool

	WebAuthnID() []byte
	WebAuthnDisplayName() string
	WebAuthnName() string
	WebAuthnCredentials() []webauthn.Credential

	// WebAuthnIcon is a deprecated option.
	// Deprecated: this has been removed from the specification recommendation. Suggest a blank string.
	WebAuthnIcon() string
	AddNewWebAuthnCredential(*webauthn.Credential)

	// Getters
	GetUsername() string
	GetEmail() string
	GetID() string
	GetPasswordInfo() authentication.PasswordInfo
	GetWebAuthnSessions() []webauthn.SessionData
	GetPasswordSessions() []authentication.PasswordSession
}

type PublicLocksmithUser

type PublicLocksmithUser struct {
	ID                 string `json:"id"`
	Username           string `json:"username"`
	Email              string `json:"email"`
	ActiveSessionCount int    `json:"sessions"`
	LastActive         int64  `json:"lastActive"`
	Role               string `json:"role"`
}

Only used to show user data to an endpoint This should hide any sensitive data like password session info, etc

func (PublicLocksmithUser) FromRegular

Convert a LocksmithUser{} into the public equivalent.

type PublicLocksmithUserInterface

type PublicLocksmithUserInterface interface {
	FromRegular(LocksmithUserInterface) (PublicLocksmithUserInterface, error)
}

This interface is used when user structures are sent to the frontend

Jump to

Keyboard shortcuts

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