Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateID(t IDType) (string, error)
- func GenerateJWT(uuid string, sessionid string) (string, error)
- func GenerateSessionID() (string, error)
- func LoadKeys(rsaPrivateKeyFile, rsaPublicKeyFile string) error
- type Auth
- type DB
- func (d *DB) AddLogLogin(uuid string, sessionID string, ipaddr string, devinfo string) error
- func (d *DB) AddLogPassChange(uuid string, ipaddr string, sessionID string) error
- func (d *DB) AddLogPassReset(uuid string, ipaddr string, devinfo string) error
- func (d *DB) AddSession(uuid string, sessionID string, IPAddr string, DeviceData string) error
- func (d *DB) AddTeamMember(teamuuid string, useruuid string, perm TeamPerm) error
- func (d *DB) ChangePass(uuid string, oldpass string, newpass string) error
- func (d *DB) ChangeTeamOwner(teamuuid string, olduuid string, newuuid string) error
- func (d *DB) CheckInviteToken(token string) error
- func (d *DB) CleanupExpired() error
- func (d *DB) CreateDocument(title string, permission FilePerm, parentfid string, owneruuid string, ...) (string, error)
- func (d *DB) CreateFolder(name string, permission FilePerm, parentfid string, owneruuid string, ...) (string, error)
- func (d *DB) CreateTeam(teamname string, useruuid string) (string, error)
- func (d *DB) DeleteDocument(did string) error
- func (d *DB) DeleteFolder(fid string) error
- func (d *DB) DeleteInviteToken(token string) error
- func (d *DB) DeleteTeam(teamuuid string) error
- func (d *DB) DeleteTeamMember(teamuuid string, useruuid string) error
- func (d *DB) DuplicateDocument(did string, permission FilePerm, parentfid string, owneruuid string, ...) (string, error)
- func (d *DB) GenerateInviteToken(useruuid string) (string, error)
- func (d *DB) GetDocList(fid string) ([]string, error)
- func (d *DB) GetDocumentInfo(fid string) (Document, error)
- func (d *DB) GetFolderInfo(fid string) (Folder, error)
- func (d *DB) GetFolderList(fid string) ([]string, error)
- func (d *DB) GetLatestDocument(did string) (string, error)
- func (d *DB) GetLoginPassResetLog(logid int64) (LogExtLoginPassReset, error)
- func (d *DB) GetLogs(offset int, limit int, uuid string, target []string, ltype []string) ([]Log, error)
- func (d *DB) GetProfileByUUID(uuid string) (Profile, error)
- func (d *DB) GetProfileByUsername(name string) (Profile, error)
- func (d *DB) GetRootFID() (string, error)
- func (d *DB) GetSession(uuid string) ([]Session, error)
- func (d *DB) GetTeamMember(teamuuid string, limit int, offset int, uuid string) (int, []TeamMember, error)
- func (d *DB) GetTeamMemberPerm(teamuuid string, useruuid string) (TeamPerm, error)
- func (d *DB) GetTeamsByUser(useruuid string) ([]string, error)
- func (d *DB) GetUUIDByEmail(email string) (string, error)
- func (d *DB) GetUserFID() (string, error)
- func (d *DB) IsAdmin(uuid string) (bool, error)
- func (d *DB) IsUserLocked(uuid string) (bool, error)
- func (d *DB) LockUser(uuid string) error
- func (d *DB) ModifyTeamMember(teamuuid string, useruuid string, perm TeamPerm) error
- func (d *DB) MoveDocument(did string, targetfid string) error
- func (d *DB) MoveFolder(fid string, targetfid string) error
- func (d *DB) PasswordCheck(userid string, pass string) (string, error)
- func (d *DB) PreRegistUser(username string, email string, password string) (string, error)
- func (d *DB) RegistUser(token string) error
- func (d *DB) RemoveSession(uuid string, sessionID string) error
- func (d *DB) ResetPass(uuid string) (string, error)
- func (d *DB) ResetPassTokenCheck(token string) (string, error)
- func (d *DB) ResetPassVerify(token string, newpass string) (string, error)
- func (d *DB) SaveDocument(did string, updateruuid string, text string) error
- func (d *DB) SearchTeam(query string, limit int, offset int) (int, []string, error)
- func (d *DB) SearchUser(query string, limit int, offset int, filters []int) (int, []string, error)
- func (d *DB) SetPass(uuid string, newpass string) error
- func (d *DB) SetProfile(profile Profile) error
- func (d *DB) UnlockUser(uuid string) error
- func (d *DB) UpdateDocument(did string, updateruuid string) error
- func (d *DB) UpdateDocumentInfo(dat Document) error
- func (d *DB) UpdateFolder(fid string, updateruuid string) error
- func (d *DB) UpdateFolderInfo(dat Folder) error
- func (d *DB) UpdateSessionLastUsed(uuid string, sessionID string) error
- func (d *DB) VerifyToken(token string) (string, string, error)
- type Document
- type DocumentRevision
- type FilePerm
- type Folder
- type IDType
- type Log
- type LogExtLoginPassReset
- type Profile
- type Session
- type TeamMember
- type TeamPerm
Constants ¶
const ( LogTypeAuthLogin = "auth.login" LogTypeAuthPassReset = "auth.passreset" LogTypeAuthPassChange = "auth.passchange" )
#nosec G101 LogTypeAuth enum
const ( SearchFilterLocked = iota SearchFilterNotLocked )
Variables ¶
var ( // Auth ErrIDPassInvalid = errors.New("ID or password is incorrect") ErrInvalidToken = errors.New("Token is expired or invalid") ErrExistUser = errors.New("UserName or email is already exist") ErrInvalidSession = errors.New("SessionID is invalid") // User/Team ErrUserNotFound = errors.New("The user is not found") ErrUserTeamNotFound = errors.New("User/team is not found") // Document/Folder ErrDocumentNotFound = errors.New("Document is not found") ErrFolderNotFound = errors.New("Folder is not found") )
Errors
Functions ¶
func GenerateJWT ¶
GenerateJWT generates JWT using UUID and sessionID
func GenerateSessionID ¶
GenerateSessionID generates randomID for sessions
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB holds DB connection
func (*DB) AddLogLogin ¶
AddLogLogin adds login log
func (*DB) AddLogPassChange ¶
AddLogPassChange adds pass change log
func (*DB) AddLogPassReset ¶
AddLogPassReset adds pass reset log
func (*DB) AddSession ¶
AddSession records new session information
func (*DB) AddTeamMember ¶
AddTeamMember adds new member into the team
func (*DB) ChangePass ¶
ChangePass checks oldpass and changes to new pass
func (*DB) ChangeTeamOwner ¶
ChangeTeamOwner changes the owner of the team
func (*DB) CheckInviteToken ¶
CheckInviteToken checks invitation token
func (*DB) CleanupExpired ¶
CleanupExpired removes expired record
func (*DB) CreateDocument ¶
func (d *DB) CreateDocument(title string, permission FilePerm, parentfid string, owneruuid string, updateruuid string) (string, error)
CreateDocument creates new document
func (*DB) CreateFolder ¶
func (d *DB) CreateFolder(name string, permission FilePerm, parentfid string, owneruuid string, updateruuid string) (string, error)
CreateFolder creates new folder
func (*DB) CreateTeam ¶
CreateTeam creates new team
func (*DB) DeleteDocument ¶
DeleteDocument deletes document
func (*DB) DeleteInviteToken ¶
DeleteInviteToken removes invitation token
func (*DB) DeleteTeamMember ¶
DeleteTeamMember removes the member from the team
func (*DB) DuplicateDocument ¶ added in v1.4.0
func (d *DB) DuplicateDocument(did string, permission FilePerm, parentfid string, owneruuid string, updateruuid string) (string, error)
DuplicateDocument duplicates document and save into target folder
func (*DB) GenerateInviteToken ¶
GenerateInviteToken generates token for invitation
func (*DB) GetDocList ¶
GetDocList returns the list of documents in the specified folder
func (*DB) GetDocumentInfo ¶
GetDocumentInfo returns document information
func (*DB) GetFolderInfo ¶
GetFolderInfo returns folder information
func (*DB) GetFolderList ¶
GetFolderList returns the list of folders in the specified folder
func (*DB) GetLatestDocument ¶
GetLatestDocument returns document data
func (*DB) GetLoginPassResetLog ¶
func (d *DB) GetLoginPassResetLog(logid int64) (LogExtLoginPassReset, error)
GetLoginPassResetLog returns log of loginpassreset
func (*DB) GetLogs ¶
func (d *DB) GetLogs(offset int, limit int, uuid string, target []string, ltype []string) ([]Log, error)
GetLogs returns the list of logs target is list of teamids
func (*DB) GetProfileByUUID ¶
GetProfileByUUID returns the profile info
func (*DB) GetProfileByUsername ¶
GetProfileByUsername returns the profile info
func (*DB) GetSession ¶
GetSession deletes the session
func (*DB) GetTeamMember ¶
func (d *DB) GetTeamMember(teamuuid string, limit int, offset int, uuid string) (int, []TeamMember, error)
GetTeamMember returns the member list of the team
func (*DB) GetTeamMemberPerm ¶
GetTeamMemberPerm returns team member permission
func (*DB) GetTeamsByUser ¶
GetTeamsByUser returns team IDs for specified user
func (*DB) GetUUIDByEmail ¶ added in v1.3.0
ResetPass generates and returns token to reset password
func (*DB) IsUserLocked ¶
IsUserLocked checks the user is locked.
func (*DB) ModifyTeamMember ¶
ModifyTeamMember updates team member permission
func (*DB) MoveDocument ¶
MoveDocument moves document to target folder
func (*DB) MoveFolder ¶
MoveFolder moves folder
func (*DB) PasswordCheck ¶
PasswordCheck checks given ID and pass and returns UUID
func (*DB) PreRegistUser ¶
PreRegistUser records new user information into preuser and return token to activate
func (*DB) RemoveSession ¶
RemoveSession deletes the session
func (*DB) ResetPassTokenCheck ¶
ResetPassTokenCheck checks the token to reset password and returns UUID
func (*DB) ResetPassVerify ¶
ResetPassVerify checks the token and changes to new pass
func (*DB) SaveDocument ¶
SaveDocument store the document data
func (*DB) SearchTeam ¶
SearchTeam returns the team uuid list of search
func (*DB) SearchUser ¶
SearchUser returns the user uuid list of search
func (*DB) SetProfile ¶
SetProfile updates the profile info
func (*DB) UnlockUser ¶ added in v1.3.0
UnlockUser unlocks user.
func (*DB) UpdateDocument ¶
UpdateDocument modifies document update time
func (*DB) UpdateDocumentInfo ¶
UpdateDocumentInfo modifies document info
func (*DB) UpdateFolder ¶
UpdateFolder modifies folder update time
func (*DB) UpdateFolderInfo ¶
UpdateFolderInfo modifies folder info
func (*DB) UpdateSessionLastUsed ¶
UpdateSessionLastUsed deletes the session
type Document ¶
type Document struct { UUID string OwnerUUID string ParentFolderUUID string Title string Permission FilePerm CreatedAt int64 UpdatedAt int64 UpdaterUUID string Revision int }
Document table model
type DocumentRevision ¶
DocumentRevision table model
type Folder ¶
type Folder struct { UUID string OwnerUUID string ParentFolderUUID string Name string Permission FilePerm CreatedAt int64 UpdatedAt int64 UpdaterUUID string }
Folder table model
type Log ¶
type Log struct { UUID string Date int64 Type string IPAddr string SessionID string TargetUUID string TargetFDID string ExtDataID int64 }
Log table model
type LogExtLoginPassReset ¶
LogExtLoginPassReset table model
type Profile ¶
type Profile struct { UUID string Name string Bio string IconURI string CreateAt int64 Attr string Lang string }
Profile table model
type Session ¶
type Session struct { UUID string SessionID string LoginDate int64 LastDate int64 ExpireDate int64 IPAddr string DeviceData string }
Session table model
type TeamMember ¶
TeamMember table model