account

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2018 License: AGPL-3.0 Imports: 3 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrWrongIP is raised when a source IP doesn't match with token-associated IP.
	ErrWrongIP = errors.New("ip don't match")
	// ErrInvalidTS is raised when a packet has a TS out of valid range.
	ErrInvalidTS = errors.New("packet TS is out of valid range")
	// ErrWrongCredentials is raised when user logs with invalid username/password.
	ErrWrongCredentials = errors.New("invalid credentials")
	// ErrInsufficientACLs is raised when a user apply an action without valid rights.
	ErrInsufficientACLs = errors.New("insufficient rights")
	// ErrInvalidAction is raised when an action is not possible following game rules.
	ErrInvalidAction = errors.New("action is not possible")
	// ErrMultipleLogin is raised zhen an account is already logged.
	ErrMultipleLogin = errors.New("account already logged")
)

Functions

This section is empty.

Types

type A

type A struct {
	ID       ulid.ID
	Username string
	Password string  `json:"-"`
	Token    ulid.ID `json:"-"`
}

A A represents an user account.

type ACL

type ACL uint8

ACL is a enum for different rights between entities.

const (
	// Read right gives access to retrieve the value.
	Read ACL = 0
	// Update right gives access to update an already existing value.
	Update ACL = 1
	// Set right gives access to create a new entity.
	Set ACL = 2
	// Delete right gives access to delete an already existing entity.
	Delete ACL = 3
	// Owner right gives access to all rights.
	Owner ACL = 4
)

type Mapper

type Mapper interface {
	SetAccount(A) error
	GetAccount(Subset) (A, error)
}

Mapper wraps account interactions.

type Subset

type Subset struct {
	Username string
	Password string
}

Subset is the subset to retrieve an account.

type Token

type Token struct {
	ID ulid.ID `json:"ID"`

	IP      *net.UDPAddr `json:"-"`
	Account ulid.ID      `json:"-"`
	Ping    uint64       `json:"-"`

	CorePool ulid.ID `json:"-"`
	SyncPool ulid.ID `json:"-"`
	PC       ulid.ID `json:"-"`
	Entity   ulid.ID `json:"-"`
}

Token represents a user connection. Creation is made by secure https only.

type TokenHCMapper

type TokenHCMapper interface {
	SetTokenHC(ulid.ID, int64) error
	ListTokenHC(TokenHCSubset) ([]ulid.ID, error)
}

TokenHCMapper is the service gate for Token health check.

type TokenHCSubset

type TokenHCSubset struct {
	MaxTS int64
}

TokenHCSubset retrieves token healthchecks based on last tick.

type TokenMapper

type TokenMapper interface {
	SetToken(Token) error
	GetToken(TokenSubset) (Token, error)
	DelToken(TokenSubset) error
}

TokenMapper is the service gate for Token resource.

type TokenSubset

type TokenSubset struct {
	ID ulid.ID
}

TokenSubset retrieves a token per ID.

Jump to

Keyboard shortcuts

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