model

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PaymentStatusCreated   = "created"
	PaymentStatusPending   = "pending"
	PaymentStatusConfirmed = "confirmed"
	PaymentStatusCancelled = "cancelled"
	PaymentStatusRedeemed  = "redeemed"
	PaymentStatusDeleted   = "deleted"
	PaymentStatusTimeout   = "timeout"
)
View Source
const (
	PUBLIC Role = -1
	//Unset/Zero value Role = 0
	GUEST      Role = 1
	USER       Role = 5
	CREATOR    Role = 7
	ADMIN      Role = 10
	SUPERADMIN Role = 50
	ROOT       Role = 100

	Title NameFormat = 1
	Lower NameFormat = 2
	Upper NameFormat = 3
)
View Source
const ApiKeyLength = 40 //example: f235122f9a1e4884123456788a2126f8dd76996b

Variables

View Source
var ErrAuthorityInvalid = fmt.Errorf("invalid authority key")
View Source
var ErrAuthorityMissing = fmt.Errorf("authority missing")
View Source
var ErrAuthorityNotFound = fmt.Errorf("user not found for key")

Functions

func MatchesApiKey

func MatchesApiKey(hiddenApiKey, apiKey string) bool

Types

type AccessibleItem

type AccessibleItem interface {
	IsReadGrantedFor(auth Auth) bool
	IsWriteGrantedFor(auth Auth) bool
	OwnedBy(auth Auth) bool
}

type ApiKey

type ApiKey struct {
	Name string
	Key  string
}

func NewApiKey

func NewApiKey(name, uid string) (*ApiKey, error)

func (*ApiKey) HideKey

func (me *ApiKey) HideKey()

HideKey hashes the key

type Auth

type Auth interface {
	UserID() string
	AccessRights() Role
}

type FormComponentItem

type FormComponentItem struct {
	Permissions
	ID     string `json:"id" storm:"id"`
	Name   string `json:"name" storm:"index"`
	Detail string `json:"detail"`
	//Permissions Permissions `json:"permissions"`
	Updated time.Time `json:"updated" storm:"index"`
	Created time.Time `json:"created" storm:"index"`

	//Settings and Template are just passing through
	Settings compatability.CarriedJsonRaw `json:"settings"`
	Template string                       `json:"template"`
}

func (*FormComponentItem) GetVersion

func (me *FormComponentItem) GetVersion() int

type FormItem

type FormItem struct {
	Permissions
	ID     string `json:"id" storm:"id"`
	Name   string `json:"name" storm:"index"`
	Detail string `json:"detail"`
	//Permissions Permissions `json:"permissions"`
	Updated time.Time `json:"updated" storm:"index"`
	Created time.Time `json:"created" storm:"index"`

	//Data contains the form source
	Data compatability.CarriedStringMap `json:"data"`
}

func (*FormItem) Clone

func (me *FormItem) Clone() FormItem

func (*FormItem) GetVersion

func (me *FormItem) GetVersion() int

type GroupAndOthers

type GroupAndOthers struct {
	//Allowed to modify: @Owner only!
	Group Role `json:"group,omitempty"`
	//Rights pattern:       	    					group others
	//		                     	 	 				 --     --
	//default value is:                	    				----
	//example for group and others with read perm:	    	r-r-
	//Allowed to modify: @Owner only!
	Rights Permission `json:"rights,omitempty"`
}

func (*GroupAndOthers) IsGroupRead

func (me *GroupAndOthers) IsGroupRead(auth Auth) bool

func (*GroupAndOthers) IsGroupWrite

func (me *GroupAndOthers) IsGroupWrite(auth Auth) bool

func (*GroupAndOthers) IsOthersRead

func (me *GroupAndOthers) IsOthersRead() bool

func (*GroupAndOthers) IsOthersWrite

func (me *GroupAndOthers) IsOthersWrite() bool

type Lang

type Lang struct {
	ID      string
	Code    string
	Enabled bool
}

func (*Lang) Matches

func (l *Lang) Matches(code string) bool

type MemoryAuth

type MemoryAuth interface {
	Auth
	GetMemory(k string) (interface{}, bool)
	PutMemory(k string, val interface{})
	DeleteMemory(k string)
	GetSessionDir() string
}

type NameFormat

type NameFormat int

type Permission

type Permission []byte

Permission holds an byte slice for the pattern --/rw or ----/r-r- and so on none read write 0 == - | 1 == r | 2 == w to support []byte we implement the json marshaller interface otherwise use []int

func PermissionFrom

func PermissionFrom(readablePattern string) (Permission, error)

func (Permission) IsGroupRead

func (me Permission) IsGroupRead() bool

func (Permission) IsGroupWrite

func (me Permission) IsGroupWrite() bool

func (Permission) IsOthersRead

func (me Permission) IsOthersRead() bool

func (Permission) IsOthersWrite

func (me Permission) IsOthersWrite() bool

func (Permission) IsRead

func (me Permission) IsRead() bool

func (Permission) IsWrite

func (me Permission) IsWrite() bool

func (Permission) MarshalJSON

func (me Permission) MarshalJSON() ([]byte, error)

func (Permission) String

func (me Permission) String() string

func (Permission) ToReadablePattern

func (me Permission) ToReadablePattern() string

type Permissions

type Permissions struct {
	//Allowed to modify: @Owner only!
	Owner string `json:"owner,omitempty"`
	//Grant can be modified by the owner only and is an optional field to whitelist user's directly
	//Allowed to modify: everyone with write rights!
	Grant map[string]Permission `json:"grant,omitempty"`

	GroupAndOthers GroupAndOthers `json:"groupAndOthers,omitempty"`
	//Accessible by everyone who has the ID
	//Allowed to modify: everyone with write rights!
	PublicByID Permission `json:"publicByID,omitempty"`

	//Execute only! If read or write not set.
	Published bool `json:"published"`
}

func (*Permissions) Change

func (me *Permissions) Change(auth Auth, changed *Permissions) *Permissions

TODO improve perm modification

func (*Permissions) IsPublishedFor

func (me *Permissions) IsPublishedFor(auth Auth) bool

func (*Permissions) IsPublishedOrReadGrantedFor

func (me *Permissions) IsPublishedOrReadGrantedFor(auth Auth) bool

func (*Permissions) IsReadGrantedFor

func (me *Permissions) IsReadGrantedFor(auth Auth) bool

IsReadGrantedFor is checking whether the User has read rights or not Rights pattern: group others

--     --

default value is: ---- example for group and others with read perm: r-r-

func (*Permissions) IsWriteGrantedFor

func (me *Permissions) IsWriteGrantedFor(auth Auth) bool

IsWriteGrantedFor is checking whether the User has write rights or not Rights pattern: group others

--     --

default value is: ---- example for group and others with read perm: r-r-

func (*Permissions) OwnedBy

func (me *Permissions) OwnedBy(auth Auth) bool

func (*Permissions) UpdateUserID

func (me *Permissions) UpdateUserID(usrOldIdNewID map[string]string)

func (*Permissions) UserIdsMap

func (me *Permissions) UserIdsMap(usrIds map[string]bool)

type Role

type Role int

func StringToRole

func StringToRole(role string) Role

StringToRole takes role string case insensitive and returns a GUEST role if no role was found with the provided string

func (Role) AllowedToCreateEntities

func (r Role) AllowedToCreateEntities() bool

func (Role) AllowedToCreateUserData

func (r Role) AllowedToCreateUserData() bool

func (Role) Is

func (r Role) Is(pr Role) bool

Is checks if current role and provided one are equal

func (Role) IsGrantedFor

func (r Role) IsGrantedFor(pr Role) bool

IsGrantedFor checks if current is higher or equal to the provided role

func (Role) IsGrantedForUserModifications

func (r Role) IsGrantedForUserModifications() bool

IsGrantedForUserModifications checks if current is higher or equal to SUPERADMIN

func (Role) Lower

func (r Role) Lower() string

Lower returns every character in lower case like "admin"

func (Role) RolesInRange

func (r Role) RolesInRange() []RoleSet

RolesInRange provides all roles hierarchically sorted in your range

func (Role) RolesInRangeWithNameFormat

func (r Role) RolesInRangeWithNameFormat(nf NameFormat) []RoleSet

func (Role) String

func (r Role) String() string

String returns every character in lower case like "admin"

func (Role) Title

func (r Role) Title() string

Title returns the first character with upper case like "Admin"

func (Role) Upper

func (r Role) Upper() string

Upper returns every character in upper case like "ADMIN"

type RoleSet

type RoleSet struct {
	Name string `json:"name"`
	Role Role   `json:"role"`
}

type Session

type Session struct {
	ID         string    `json:"id"`
	Rights     Role      `json:"rights"`
	UsrID      string    `json:"usrId"`
	UserName   string    `json:"userName"`
	SessionDir string    `json:"sessionDir"`
	Updated    time.Time `json:"updated"`
}

type Settings

type Settings struct {
	DocumentServiceUrl        string `` /* 159-byte string literal not displayed */
	PlatformDomain            string `json:"platformDomain" validate:"required=true" default:"" usage:"Platform Domain used to for links to Platform"`
	DataDir                   string `json:"dataDir" default:"/data/hosted" usage:"Database directory path. All data will be stored here."`
	DefaultRole               string `` /* 132-byte string literal not displayed */
	SessionExpiry             string `` /* 140-byte string literal not displayed */
	CacheExpiry               string `` /* 133-byte string literal not displayed */
	BlockchainNet             string `` /* 153-byte string literal not displayed */
	InfuraApiKey              string `json:"infuraApiKey" validate:"required=true" usage:"API Key to access Infura node."`
	BlockchainContractAddress string `` /* 156-byte string literal not displayed */
	SparkpostApiKey           string `json:"sparkpostApiKey" validate:"required=true" usage:"Sparkpost API key which will be used to send out emails."`
	EmailFrom                 string `json:"emailFrom" validate:"required=true,email=true" usage:"Email that is being used to send out emails."`
	LogPath                   string `json:"logPath" default:"./log" usage:"Location of the log file of this service."`
	DefaultWorkflowIds        string `json:"defaultWorkflowIds" usage:"Workflow IDs to set to clone and add to a new user"`
	AirdropEnabled            string `json:"airdropEnabled" validate:"required=true" default:"false" usage:"Enables/Disables the XES & Ether airdrop feature."`
	AirdropAmountXES          string `json:"airdropAmountXES" default:"0" usage:"Amount of XES to airdrop to newly registered users."`
	AirdropAmountEther        string `json:"airdropAmountEther" default:"0" usage:"Amount of Ether to airdrop to newly registered users."`
	DatabaseEngine            string `json:"databaseEngine" default:"storm" usage:"Selects database engine, supported values: storm, mongo."`
	DatabaseURI               string `json:"DatabaseURI" default:"" usage:"Sets database connection string, not required for embedded databases."`
	TestMode                  string `json:"testMode" default:"false" usage:"Run the server in test mode =NOT FOR PRODUCTION=."`
	AllowHttp                 string `json:"allowHttp" default:"false" usage:"Allow the use of HTTP =NOT FOR PRODUCTION=."`
}

func NewDefaultSettings

func NewDefaultSettings() *Settings

type SignatureRequestItem

type SignatureRequestItem struct {
	ID string `storm:"id"`
	// DocumentID, ie. 8b5e1460-e456-4aea-91dd-efd7f6ff9b40
	DocId string `json:"docid" storm:"index"`
	// DataPath, ie. docs[0]
	DocPath string `json:"docpath" storm:"index"`
	// Keccak256 of Filecontent
	Hash string `json:"hash"`
	// RequestorEthAddress
	Requestor string `json:"requestor" storm:"index"`
	// Timestamp for requested, revoked, rejected
	RequestedAt time.Time `json:"requestedAt"`
	RevokedAt   time.Time `json:"revokedAt"`
	RejectedAt  time.Time `json:"rejectedAt"`
	// SignatoryEthAddress
	Signatory string `json:"signatory" storm:"index"`
	Revoked   bool   `json:"revoked"`
	Rejected  bool   `json:"rejected"`
}

func (*SignatureRequestItem) GetVersion

func (me *SignatureRequestItem) GetVersion() int

type TemplateItem

type TemplateItem struct {
	Permissions
	ID     string `json:"id" storm:"id"`
	Name   string `json:"name" storm:"index"`
	Detail string `json:"detail"`
	//Permissions Permissions `json:"permissions"`
	Updated time.Time `json:"updated" storm:"index"`
	Created time.Time `json:"created" storm:"index"`

	Data TemplateLangMap `json:"data"`
}

func (*TemplateItem) Clone

func (me *TemplateItem) Clone() TemplateItem

func (*TemplateItem) GetTemplate

func (me *TemplateItem) GetTemplate(lang string) (*file.IO, error)

func (*TemplateItem) GetVersion

func (me *TemplateItem) GetVersion() int

type TemplateLangMap

type TemplateLangMap map[string]*file.IO

type TokenRequest

type TokenRequest struct {
	Email  string    `json:"email" validate:"email=true,required=true"`
	Token  string    `json:"token"`
	UserID string    `json:"userID"`
	Role   Role      `json:"role"`
	Type   TokenType `json:"type"`
}

type TokenType

type TokenType string
const (
	TokenResetPassword TokenType = "reset_pw"
	TokenRegister      TokenType = "register_usr"
	TokenChangeEmail   TokenType = "change_email"
)

type User

type User struct {
	ID      string    `json:"id" storm:"id"`
	Name    string    `json:"name" storm:"index"`
	Detail  string    `json:"detail"`
	Updated time.Time `json:"updated" storm:"index"`
	Created time.Time `json:"created" storm:"index"`

	//Item
	Email        string      `json:"email" storm:"unique"`
	Role         Role        `json:"role,omitempty"`
	Data         interface{} `json:"data,omitempty"`
	Active       bool        `json:"active"`
	EthereumAddr string      `json:"etherPK" storm:"index"`
	PhotoPath    string      `json:"-"`
	Photo        string      `json:"photo"`
	//the user is able to tell if he lets other people see his photo, name or email instead of just the blockchain address
	WantToBeFound bool `json:"wantToBeFound"`

	ApiKeys []*ApiKey `json:"apiKeys"`
}

func (*User) AccessRights

func (me *User) AccessRights() Role

func (*User) CheckIfAuthIsAllowedToReadPersonalData

func (me *User) CheckIfAuthIsAllowedToReadPersonalData(auth Auth) bool

func (*User) Close

func (me *User) Close()

func (*User) GetVersion

func (me *User) GetVersion() int

func (*User) IsGrantedFor

func (me *User) IsGrantedFor(role Role) bool

IsGrantedFor check if user has enough permissions

func (*User) SetApiKey

func (me *User) SetApiKey(name string) (*ApiKey, error)

func (*User) String

func (me *User) String() string

func (*User) UserID

func (me *User) UserID() string

----Auth interface----------------

type UserData

type UserData struct {
	ID          string      `json:"id" storm:"id"`
	Name        string      `json:"name" storm:"index"`
	Detail      string      `json:"detail"`
	Permissions Permissions `json:"permissions"`
	Updated     time.Time   `json:"updated" storm:"index"`
	Created     time.Time   `json:"created" storm:"index"`

	WorkflowID string      `json:"workflowId"`
	Lang       string      `json:"lang"`
	LangForm   string      `json:"langForm"`
	LangTmpl   string      `json:"langTmpl"`
	Finished   bool        `json:"finished"`
	Data       interface{} `json:"data"`
}

type UserDataItem

type UserDataItem struct {
	Permissions
	ID     string `json:"id" storm:"id"`
	Name   string `json:"name" storm:"index"`
	Detail string `json:"detail"`
	//Permissions Permissions `json:"permissions"`
	WorkflowID string    `json:"workflowID"`
	Finished   bool      `json:"finished"`
	Updated    time.Time `json:"updated" storm:"index"`
	Created    time.Time `json:"created" storm:"index"`

	Data compatability.CarriedStringMap `json:"data"`
}

func (*UserDataItem) GetAllFileInfos

func (me *UserDataItem) GetAllFileInfos() []*file.IO

func (*UserDataItem) GetVersion

func (me *UserDataItem) GetVersion() int

type WorkflowItem

type WorkflowItem struct {
	Permissions
	ID     string `json:"id" storm:"id"`
	Name   string `json:"name" storm:"index"`
	Detail string `json:"detail"`
	//Permissions Permissions `json:"permissions"`
	Updated time.Time `json:"updated" storm:"index"`
	Created time.Time `json:"created" storm:"index"`
	Price   uint64    `json:"price" storm:"index"`

	Data            *workflow.Workflow `json:"data"`
	OwnerEthAddress string             `json:"ownerEthAddress"` //only used in frontend
	Deactivated     bool               `json:"deactivated"`
}

func (*WorkflowItem) Clone

func (me *WorkflowItem) Clone() WorkflowItem

func (*WorkflowItem) GetVersion

func (me *WorkflowItem) GetVersion() int

func (*WorkflowItem) LoopNodes

func (me *WorkflowItem) LoopNodes(looper *workflow.Looper, cb func(l *workflow.Looper, node *workflow.Node) bool)

type WorkflowPaymentItem

type WorkflowPaymentItem struct {
	//save from who payment
	ID         string    `json:"id" storm:"id,unique"`
	TxHash     string    `json:"hash" storm:"index,unique"`
	WorkflowID string    `json:"workflowID" storm:"index"`
	From       string    `json:"from" storm:"index"`
	To         string    `json:"to"`
	Xes        uint64    `json:"xes"`
	Status     string    `json:"status" storm:"index"`
	CreatedAt  time.Time `json:"createdAt"`
}

func (*WorkflowPaymentItem) GetVersion

func (me *WorkflowPaymentItem) GetVersion() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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