models

package
v0.0.0-...-447d7c9 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2017 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthToken   TokenType = "auth"
	CodeToken             = "code"
	UploadToken           = "upload"
)

AuthToken is for authorization, CodeToken is for 3rd party app OAuth flow.

Variables

This section is empty.

Functions

func NormalizeAddress

func NormalizeAddress(input string) string

NormalizeAddress splits the email into two parts and performs normalization on both parts

func NormalizeUsername

func NormalizeUsername(input string) string

NormalizeUsername removes all weird stuff from the username

func RemoveDots

func RemoveDots(input string) string

RemoveDots performs a Gmail-like operation on the email - removes all dots.

Types

type Account

type Account struct {
	ID               uint64    `db:"id" json:"id" goqu:"skipinsert"`
	DateCreated      time.Time `db:"date_created" json:"date_created"`
	DateModified     time.Time `db:"date_modified" json:"date_modified"`
	Type             string    `db:"type" json:"type"`
	MainAddress      string    `db:"main_address" json:"main_address"`
	Identity         string    `db:"identity" json:"identity"`
	Password         string    `db:"password" json:"-"`
	Subscription     string    `db:"subscription" json:"subscription"`
	Blocked          bool      `db:"blocked" json:"blocked"`
	AltEmail         string    `db:"alt_email" json:"alt_email"`
	AltEmailVerified time.Time `db:"alt_email_verified" json:"alt_email_verified"`
}

Account is pretty much an account.

type Address

type Address struct {
	ID           string    `db:"id" json:"id"`
	StyledID     string    `db:"styled_id" json:"styled_id"`
	DateCreated  time.Time `db:"date_created" json:"date_created"`
	DateModified time.Time `db:"date_modified" json:"date_modified"`
	Account      uint64    `db:"account" json:"account"`
	PublicKey    uint64    `db:"public_key" json:"public_key"`
}

Address is the mapping between email addresses and accounts

type Application

type Application struct {
	ID           uint64    `db:"id" json:"id" goqu:"skipinsert"`
	DateCreated  time.Time `db:"date_created" json:"date_created"`
	DateModified time.Time `db:"date_modified" json:"date_modified"`
	Owner        uint64    `db:"owner" json:"owner"`
	Secret       string    `db:"secret" json:"secret"`
	Callback     string    `db:"callback" json:"callback"`
	Name         string    `db:"name" json:"name"`
	Email        string    `db:"email" json:"email"`
	HomePage     string    `db:"home_page" json:"home_page"`
	Description  string    `db:"description" json:"description"`
}

Application is an entity used for OAuth token creation

type Meta

type Meta map[string]interface{}

Meta is a custom JSON storage type for objects

func (*Meta) Scan

func (m *Meta) Scan(value interface{}) error

Scan implements the database/sql Scanner interface

func (Meta) Value

func (m Meta) Value() (driver.Value, error)

Value implements the database/sql Valuer interface

type PublicKey

type PublicKey struct {
	ID           uint64    `db:"key_id" json:"key_id"`
	DateCreated  time.Time `db:"date_created" json:"date_created"`
	DateModified time.Time `db:"date_modified" json:"date_modified"`
	Owner        uint64    `db:"owner" json:"owner"`

	Algorithm        uint8  `db:"algorithm" json:"algorithm"`
	Length           uint16 `db:"length" json:"length"`
	Body             []byte `db:"body" json:"body"`
	KeyIDString      string `db:"key_id_string" json:"key_id_string"`
	KeyIDShortString string `db:"key_id_short_string" json:"key_id_short_string"`
	MasterKey        uint64 `db:"master_key" json:"master_key"`
}

PublicKey is the representation of a public key in the system

type PublicKeyIdentity

type PublicKeyIdentity struct {
	ID            uint64   `db:"identity" json:"identity" goqu:"skipinsert"`
	Key           uint64   `db:"key" json:"key"`
	Name          string   `db:"name" json:"name"`
	SelfSignature uint64   `db:"self_signature" json:"self_signature"`
	Signatures    []uint64 `db:"signatures" json:"signatures"`
}

PublicKeyIdentity is part of the metadata of the key, a signed identity of the key

type PublicKeySignature

type PublicKeySignature struct {
	ID                   uint64    `db:"id" json:"id" goqu:"skipinsert"`
	Type                 uint8     `db:"type" json:"type"`
	Algorithm            uint8     `db:"algorithm" json:"algorithm"`
	Hash                 uint      `db:"hash" json:"hash"`
	CreationTime         time.Time `db:"creation_time" json:"creation_time"`
	SigLifetimeSecs      uint32    `db:"sig_lifetime_secs" json:"sig_lifetime_secs"`
	KeyLifetimeSecs      uint32    `db:"key_lifetime_secs" json:"key_lifetime_secs"`
	IssuerKeyID          uint64    `db:"issuer_key_id" json:"issuer_key_id"`
	IsPrimaryID          bool      `db:"is_primary_id" json:"is_primary_id"`
	RevocationReason     uint8     `db:"revocation_reason" json:"revocation_reason"`
	RevocationReasonText string    `db:"revocation_reason_text" json:"revocation_reason_text"`
}

PublicKeySignature is a signature of an identity. Creates Web of Trust.

type ReferenceType

type ReferenceType string

ReferenceType is what the token refers to in case of upload and fetch tokens.

const (
	ResourceRef ReferenceType = "resource"
	EmailRef                  = "email"
)

ReferenceType is all the possible models that you can reference

func (*ReferenceType) Scan

func (t *ReferenceType) Scan(value interface{}) error

Scan implements the database/sql Scanner interface

func (ReferenceType) Value

func (t ReferenceType) Value() (driver.Value, error)

Value implements the database/sql Valuer interface

type Resource

type Resource struct {
	ID           uint64    `db:"id" json:"id" goqu:"skipinsert"`
	DateCreated  time.Time `db:"date_created" json:"date_created"`
	DateModified time.Time `db:"date_modified" json:"date_modified"`
	Owner        uint64    `db:"owner" json:"owner"`
	Meta         Meta      `db:"meta" json:"meta"`
	Tags         Tags      `db:"tags" json:"tags"`
	File         string    `db:"file" json:"file,omitempty"`
	UploadToken  string    `db:"upload_token" json:"upload_token,omitempty"`
}

Resource is a basic storage in the system without any particular structure.

type Tags

type Tags []string

Tags is a custom JSON storage type for arrays

func (*Tags) Scan

func (t *Tags) Scan(value interface{}) error

Scan implements the database/sql Scanner interface

func (Tags) Value

func (t Tags) Value() (driver.Value, error)

Value implements the database/sql Valuer interface

type Token

type Token struct {
	ID            string        `db:"id" json:"id" goqu:"skipinsert"`
	DateCreated   time.Time     `db:"date_created" json:"date_created"`
	DateModified  time.Time     `db:"date_modified" json:"date_modified"`
	Owner         uint64        `db:"owner" json:"owner"`
	ExpiryDate    time.Time     `db:"expiry_date" json:"expiry_date"`
	Type          TokenType     `db:"type" json:"type"`
	Perms         perms.Nodes   `db:"perms" json:"perms,omitempty"`
	Application   uint64        `db:"application" json:"application,omitempty"`
	ReferenceType ReferenceType `db:"reference_type" json:"reference_type,omitempty"`
	ReferenceID   uint64        `db:"reference_id" json:"reference_id,omitempty"`
}

Token is an implementation of both types of OAuth tokens implement some sorts of perms

func (*Token) Check

func (t *Token) Check(perm string) bool

Check checks if the perm is there

func (*Token) CheckAnd

func (t *Token) CheckAnd(rp []string) bool

CheckAnd checks all passed perms

func (*Token) CheckOr

func (t *Token) CheckOr(rp []string) bool

CheckOr checks if there is at least one perm

type TokenType

type TokenType string

TokenType is either auth or code and defines what function a token serves.

func (*TokenType) Scan

func (t *TokenType) Scan(value interface{}) error

Scan implements the database/sql Scanner interface

func (TokenType) Value

func (t TokenType) Value() (driver.Value, error)

Value implements the database/sql Valuer interface

Jump to

Keyboard shortcuts

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