Documentation ¶
Index ¶
- Variables
- func NewContentReader(lines []ContentLine) (result io.Reader, err error)
- type ContentLine
- type ContextKey
- type File
- func (f *File) Copy() FileI
- func (f *File) GetDate() FileTime
- func (f *File) GetID() FileID
- func (f *File) GetName() string
- func (f *File) MarshalBSON() ([]byte, error)
- func (f *File) MarshalJSON() ([]byte, error)
- func (f *File) SetID(id FileID)
- func (f *File) SetName(n string)
- func (f *File) UnmarshalBSON(b []byte) error
- func (f *File) UnmarshalJSON(b []byte) error
- type FileDecoder
- type FileI
- type FileID
- type FileStore
- type FileTime
- type Group
- func (g *Group) AddMember(o Owner)
- func (g *Group) Copy() Owner
- func (g *Group) Equal(o Owner) bool
- func (g *Group) GetID() OwnerID
- func (g *Group) GetMembers() []Owner
- func (g *Group) GetName() string
- func (g *Group) MarshalBSON() ([]byte, error)
- func (g *Group) MarshalJSON() ([]byte, error)
- func (g *Group) Match(o Owner) bool
- func (g *Group) MaxFiles() int64
- func (g *Group) RemoveMember(o Owner)
- func (g *Group) SetName(s string)
- func (g *Group) UnmarshalBSON(b []byte) error
- func (g *Group) UnmarshalJSON(b []byte) error
- type GroupI
- type Owner
- type OwnerID
- type Permission
- func (p *Permission) CheckPerm(o Owner, s string) bool
- func (p *Permission) CopyPerm(newowner Owner) PermissionI
- func (p *Permission) GetOwner() Owner
- func (p *Permission) GetPerm(s string) []Owner
- func (p *Permission) MarshalBSON() ([]byte, error)
- func (p *Permission) MarshalJSON() ([]byte, error)
- func (p *Permission) PermTypes() []string
- func (p *Permission) Populate(ub PermissionPopulator) error
- func (p *Permission) SetPerm(o Owner, s string, b bool)
- func (p *Permission) UnmarshalBSON(b []byte) error
- func (p *Permission) UnmarshalJSON(b []byte) error
- type PermissionI
- type PermissionPopulator
- type StoreID
- type User
- func (u *User) ChangeEmail(path string)
- func (u *User) CheckCookie(r *http.Request) bool
- func (u *User) Copy() Owner
- func (u *User) Equal(o Owner) bool
- func (u *User) GetCookieTimeouts() (time.Time, time.Time)
- func (u *User) GetEmail() string
- func (u *User) GetID() OwnerID
- func (u *User) GetLock() UserCredentialI
- func (u *User) GetName() string
- func (u *User) GetRole(k string) bool
- func (u *User) GetRoles() []string
- func (u *User) GetTotalSpace() int64
- func (u *User) Match(o Owner) bool
- func (u *User) MaxFiles() int64
- func (u *User) NewCookies(inactivity time.Time, timeout time.Time) []*http.Cookie
- func (u *User) RefreshCookie(inactive time.Time)
- func (u *User) SetLock(c UserCredentialI)
- func (u *User) SetRole(k string, v bool)
- type UserCredential
- type UserCredentialI
- type UserI
- type ViewStore
- type WebFile
Constants ¶
This section is empty.
Variables ¶
var Public publicowner
Public is the owner that matches all other owners
Functions ¶
func NewContentReader ¶
func NewContentReader(lines []ContentLine) (result io.Reader, err error)
NewContentReader streams content lines together into a reader
Types ¶
type ContentLine ¶
type ContentLine struct { ID StoreID `bson:"id"` //PageNum int `bson:"pagenum"` Position int `bson:"position"` Content []string `bson:"content"` }
ContentLine is a line of content within a file
type ContextKey ¶
type ContextKey byte
ContextKey is used to store connections to a database in the values of a context
const ( DATABASE ContextKey = iota OWNER FILE STORE CONTENT TAG ACRONYM VIEW )
Context Keys for each type of database connection
type File ¶
type File struct { Permission ID FileID `json:"id" bson:"id"` Name string `json:"name" bson:"name"` Date FileTime `json:"date" bson:"date"` }
File is the meta data and permission values of a file
func (*File) MarshalBSON ¶
MarshalBSON converts file into bson representation
func (*File) MarshalJSON ¶
MarshalJSON converts file into json representation
func (*File) UnmarshalBSON ¶
UnmarshalBSON convert bson to file
func (*File) UnmarshalJSON ¶
UnmarshalJSON converts json to File
type FileDecoder ¶
FileDecoder Unmarshals as either a File or WebFile
func (*FileDecoder) UnmarshalBSON ¶
func (fd *FileDecoder) UnmarshalBSON(b []byte) error
UnmarshalBSON decodes bson into WebFile or File
func (*FileDecoder) UnmarshalJSON ¶
func (fd *FileDecoder) UnmarshalJSON(b []byte) error
UnmarshalJSON decodes json to either File or WebFile
type FileI ¶
type FileI interface { PermissionI GetID() FileID SetID(FileID) GetName() string SetName(n string) GetDate() FileTime Copy() FileI }
FileI is the interface type to represent a file
type FileID ¶
FileID uniquely identifies a file and its associated file store.
func DecodeFileID ¶
DecodeFileID produces a FileID from a base64 encoded string, inverse of String().
func (FileID) MarshalJSON ¶
MarshalJSON returns the string representation of the FileID in json format
func (*FileID) UnmarshalJSON ¶
UnmarshalJSON decodes a json string value into a FileID, using DecodeFileID
type FileStore ¶
type FileStore struct { ID StoreID `json:"id" bson:"id"` Content []byte `json:"content" bson:"-"` ContentType string `json:"ctype" bson:"ctype"` FileSize int64 `json:"fsize" bson:"fsize"` Perr *dberrs.Processing `json:"err,omitempty" bson:"perr,omitempty"` }
FileStore represents a file's content
func NewFileStore ¶
NewFileStore builds a FileStore from a reader of the file content
type Group ¶
type Group struct { Permission ID OwnerID `json:"id" bson:"id"` Name string `json:"name" bson:"name"` Max int64 `json:"max,omitempty" bson:"max,omitempty"` }
Group is the basic Group implementation
func (*Group) MarshalBSON ¶
MarshalBSON builds bson representation
func (*Group) MarshalJSON ¶
MarshalJSON builds json representation
func (*Group) Match ¶
Match returns true if owner is equal to group, matches group's owner, or matches any of the group's members
func (*Group) UnmarshalBSON ¶
UnmarshalBSON decodes to Group group still needs Populate to be called inorder to load owner and members
func (*Group) UnmarshalJSON ¶
UnmarshalJSON decodes to Group group still needs Populate called inorder to load owner and members
type GroupI ¶
type GroupI interface { Owner PermissionI SetName(string) GetMembers() []Owner AddMember(o Owner) RemoveMember(o Owner) }
GroupI is the group interface
type Owner ¶
type Owner interface { GetID() OwnerID GetName() string Match(o Owner) bool Equal(o Owner) bool Copy() Owner MaxFiles() int64 // Maximum file count for owner, 0 indicates to use the default configuration, -1 indicates infinite }
Owner is the interface for types that can own things
type OwnerID ¶
type OwnerID struct { Type byte `bson:"type"` UserDefined [3]byte `bson:"ud"` Stamp []byte `bson:"stamp,omitempty"` }
OwnerID used to uniquely identify owners
func DecodeOwnerIDString ¶
DecodeOwnerIDString inverse operation of String()
func GetCookieUID ¶
GetCookieUID gets OwnerID of current session
func (OwnerID) MarshalJSON ¶
MarshalJSON build json representation of OwnerID
func (*OwnerID) UnmarshalJSON ¶
UnmarshalJSON builds OwnerID from json
type Permission ¶
type Permission struct { Own Owner `json:"own" bson:"own"` Perm map[string][]Owner `json:"perm,omitempty" bson:"perm,omitempty"` // contains filtered or unexported fields }
Permission is to be used as an abstract class of objects that are owned
func (*Permission) CheckPerm ¶
func (p *Permission) CheckPerm(o Owner, s string) bool
CheckPerm returns true if owner has particular permission
func (*Permission) CopyPerm ¶
func (p *Permission) CopyPerm(newowner Owner) PermissionI
CopyPerm creates new permission with new owner, if new owner is nil, reuses current owner
func (*Permission) GetOwner ¶
func (p *Permission) GetOwner() Owner
GetOwner returns owner of object
func (*Permission) GetPerm ¶
func (p *Permission) GetPerm(s string) []Owner
GetPerm returns all owners that have a certain permission
func (*Permission) MarshalBSON ¶
func (p *Permission) MarshalBSON() ([]byte, error)
MarshalBSON converts permission to bson
func (*Permission) MarshalJSON ¶
func (p *Permission) MarshalJSON() ([]byte, error)
MarshalJSON converts permission to json
func (*Permission) PermTypes ¶
func (p *Permission) PermTypes() []string
PermTypes returns all permission types that have an associated owner
func (*Permission) Populate ¶
func (p *Permission) Populate(ub PermissionPopulator) error
Populate loads owners from the database after decoding Permission object from json or bson
func (*Permission) SetPerm ¶
func (p *Permission) SetPerm(o Owner, s string, b bool)
SetPerm sets permission for a particular owner
func (*Permission) UnmarshalBSON ¶
func (p *Permission) UnmarshalBSON(b []byte) error
UnmarshalBSON converts bson to permission
func (*Permission) UnmarshalJSON ¶
func (p *Permission) UnmarshalJSON(b []byte) error
UnmarshalJSON converts json to permission
type PermissionI ¶
type PermissionI interface { json.Marshaler json.Unmarshaler bson.Marshaler bson.Unmarshaler GetOwner() Owner CheckPerm(Owner, string) bool GetPerm(string) []Owner PermTypes() []string SetPerm(Owner, string, bool) CopyPerm(Owner) PermissionI Populate(PermissionPopulator) error }
PermissionI interface for Permission Object that can be owned
type PermissionPopulator ¶
PermissionPopulator is an iterface type for Populating Permission Objects with Populate Actions Most likely used with database.Ownerbase type
type StoreID ¶
StoreID is used to uniquely identify a FileStore. Contains a hash of the file's content used to quickly identify copies of the same file.
func DecodeStoreID ¶
DecodeStoreID returns a StoreID from base64 encoded string, inverse of String()
func NewStoreID ¶
NewStoreID builds a StoreID from a reader of the file's contents
func NewStoreIDComplete ¶
NewStoreIDComplete build a StoreID from a reader of the file's contents, a hash scheme and stamp value
type User ¶
type User struct { ID OwnerID `json:"uid" bson:"id"` Name string `json:"name" bson:"name"` Pass UserCredential `json:"pass" bson:"pass"` Email string `json:"email" bson:"email"` CookieSig []byte `json:"cs" bson:"cs"` CookieInactivity time.Time `json:"ci" bson:"ci"` CookieTimeout time.Time `json:"ct" bson:"ct"` Roles map[string]bool `json:"roles,omitempty" bson:"roles,omitempty"` Space int64 `json:"space,omitempty" bson:"space,omitempty"` Max int64 `json:"max,omitempty" bson:"max,omitempty"` }
User basic user object
func (*User) CheckCookie ¶
CheckCookie returns true if request has cookied session cookies
func (*User) GetCookieTimeouts ¶
GetCookieTimeouts returns current session timeouts
func (*User) GetTotalSpace ¶
GetTotalSpace returns current Total Space value of user
func (*User) NewCookies ¶
NewCookies creates new cookies for a new session
func (*User) RefreshCookie ¶
RefreshCookie sets inactivity timeout
type UserCredential ¶
UserCredential is a salt and hashed of a password
func NewUserCredential ¶
func NewUserCredential(pass string) UserCredential
NewUserCredential build UserCredential from password
func (UserCredential) Valid ¶
func (up UserCredential) Valid(credential map[string]interface{}) bool
Valid returns true if credential has the field "pass" has the correct password.
type UserCredentialI ¶
UserCredentialI interface representing types that can be used to validate user
type UserI ¶
type UserI interface { Owner GetLock() UserCredentialI SetLock(UserCredentialI) NewCookies(time.Time, time.Time) []*http.Cookie CheckCookie(*http.Request) bool RefreshCookie(time.Time) GetCookieTimeouts() (time.Time, time.Time) GetRole(string) bool GetRoles() []string SetRole(string, bool) GetEmail() string ChangeEmail(string) GetTotalSpace() int64 }
UserI interface tyoe for representing users
type ViewStore ¶
ViewStore represents the PDF representation of a File
func NewViewStore ¶
NewViewStore builds ViewStore from a StoreID and Reader of pdf representation
type WebFile ¶
WebFile is an extention of a File with URL value
func (*WebFile) MarshalBSON ¶
MarshalBSON converts webfile to bson
func (*WebFile) MarshalJSON ¶
MarshalJSON converts webfile to json
func (*WebFile) UnmarshalBSON ¶
UnmarshalBSON converts bson to file
func (*WebFile) UnmarshalJSON ¶
UnmarshalJSON converts json to File