models

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	jwt.StandardClaims
	UserID   string                 `json:"id"`
	Nickname string                 `json:"nck"`
	Values   map[string]interface{} `json:"vls,omitempty"`
}

Claims represents custom claims for jwt authentication.

type Config

type Config struct {
	// Space is the name of the space
	// where long-season is watching for macs.
	Space string

	// City is name of city, where
	// long-season is watching for macs.
	City string

	Debug         bool
	Host          string
	Port          string
	DatabaseType  string
	DatabasePath  string
	JWTSecret     string
	UpdateSecret  string
	AppName       string
	RefreshTime   time.Duration
	SingleAddrTTL time.Duration
}

Config represents configuration that is being used by server.

func (Config) Address

func (c Config) Address() string

Address returns address string that is compatible with http.ListenAndServe function.

type Device

type Device struct {
	DevicePublicData

	// OwnerID is id of user that owns this device.
	OwnerID string
	// MAC contains hashed MAC address of the device.
	MAC []byte
}

type DevicePublicData

type DevicePublicData struct {
	ID    string `json:"id"`
	Tag   string `json:"tag"`
	Owner string `json:"owner"`
}

type OneTimeCode added in v0.4.0

type OneTimeCode struct {
	// ID is unique id of one time code.
	ID string `json:"id,omitempty"`

	// Name is human readable name of one time code
	// provided by user.
	Name string `json:"name,omitempty"`

	// Secret is used to verify one time code.
	Secret string `json:"secret,omitempty"`
}

OneTimeCode holds data stored in database for two factor verification with one time codes.

func (OneTimeCode) Method added in v0.4.0

func (o OneTimeCode) Method(userID string) TwoFactorMethod

Method is adapter of OneTimeCode for TwoFactorMethod type.

type Recovery added in v0.4.0

type Recovery struct {
	// ID is unique id of one time code.
	ID string `json:"id,omitempty"`

	// Name is human readable name of one time code
	// provided by user.
	Name string `json:"name,omitempty"`

	// Codes holds set with recovery codes.
	Codes *set.String `json:"codes,omitempty"`
}

Recovery holds data stored in database for two factor verification with recovery codes.

func (Recovery) Method added in v0.4.0

func (r Recovery) Method(userID string) TwoFactorMethod

Method is adapter of RecoveryCodes for TwoFactorMethod type.

type TwoFactor added in v0.4.0

type TwoFactor struct {
	// OneTimeCodes is map of one time codes entry with
	// theirs IDs as maps keys.
	OneTimeCodes map[string]OneTimeCode `json:"oneTimeCodes,omitempty"`

	// RecoveryCodes is map of recovery codes entries with
	// theirs IDs as maps keys.
	RecoveryCodes map[string]Recovery `json:"recoveryCodes,omitempty"`
}

TwoFactor holds two factor methods with data required to verify with one of the following methods.

type TwoFactorMethod added in v0.4.0

type TwoFactorMethod struct {
	// ID is unique identifier of given two factor method.
	ID string `json:"id"`

	// Name is human readable name given by user
	// to its two factor method.
	Name string `json:"name"`

	// Type is two factor type.
	Type TwoFactorType `json:"type"`

	// Locations is URI where given two factor method
	// is stored. It can be used to disable (delete)
	// given two factor method.
	Location string `json:"location"`
}

TwoFactorMethod holds private data of enabled two factor methods for given user. It allows users to discover their two factor methods.

type TwoFactorType added in v0.4.0

type TwoFactorType string

TwoFactorType describes type of two factor for inspecting user's two factor enabled methods.

const (
	// OneTimeCodes are time-based one time passwords.
	OneTimeCodes TwoFactorType = "totp"

	// RecoveryCodes are codes for one time use as additional
	// two factor method.
	RecoveryCodes TwoFactorType = "recovery codes"
)

type User

type User struct {
	UserPublicData

	// Password of User hashed with bcrypt algorithm.
	Password []byte

	// Private is flag for enabling private-mode that hides
	// user activity from others.
	Private bool
}

User represents single user data stored in storage.

type UserPublicData

type UserPublicData struct {
	// ID unique to every user.
	ID string `json:"id"`
	// Nickname represents name that will be exposed to public,
	// to inform people who is in the hackerspace.
	Nickname string `json:"nickname"`
	// Online indicates if player is currently in the hackerspace.
	Online bool `json:"online"`
}

UserPublicData is subset of User containing only data that can be shown publicly to everybody that will interact with API or website.

Directories

Path Synopsis
Package set implements classic data structure for operating with unique values.
Package set implements classic data structure for operating with unique values.

Jump to

Keyboard shortcuts

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