Documentation ¶
Index ¶
- Constants
- Variables
- func DirExists(path string) bool
- func GetDefaultConfig() string
- type Config
- func (config *Config) Check() bool
- func (config Config) GetDefaultRole() *Role
- func (config Config) GetHTMLFile(fileName string) string
- func (config Config) GetStaticFile(fileName string) string
- func (config Config) GetStorageFile(fileName string) string
- func (config Config) GetTemplateFile(fileName string) string
- func (config Config) IsRawUseragent(agent string) bool
- type CountResponse
- type CredentialsRequest
- type IDsResponse
- type LoginResponse
- type LoginSession
- type Namespaceinfo
- type Permission
- type PingRequest
- type ResponseStatus
- type Role
- type StringResponse
- type StringSliceResponse
- type UploadType
- type User
- func (user User) AllowedToUploadURLs() bool
- func (user User) CanCreateNamespaces() bool
- func (user User) CanReadForeignNamespace() bool
- func (user User) CanUploadFiles() bool
- func (user User) CanWriteForeignNamespace() bool
- func (user *User) GetUsername() string
- func (user *User) Has(db *gorm.DB, checkPass bool) (bool, error)
- func (user User) HasUploadLimit() bool
- func (user *User) Login(db *gorm.DB, machineID string) (*LoginSession, error)
- func (user User) Register(db *gorm.DB, config *Config) error
- type UserAttributeDataResponse
- type UserAttributesRequest
Constants ¶
const ( // NotFoundError error from server NotFoundError string = "Not found" // ActionNotAllowed error from server ActionNotAllowed string = "Action not allowed" // WrongLength error from server WrongLength string = "Wrong length" // ServerError error from server ServerError string = "Server Error" // WrongInputFormatError wrong user input WrongInputFormatError string = "Wrong inputFormat!" // InvalidTokenError token is not valid InvalidTokenError string = "Token not valid" // InvalidCallbackURL token is not valid InvalidCallbackURL string = "Callback url is invalid" // BatchSizeTooLarge batch is too large BatchSizeTooLarge string = "BatchSize soo large!" // WrongIntegerFormat integer is probably no integer WrongIntegerFormat string = "Number is string" // MultipleSourceNameErr err name already exists MultipleSourceNameErr string = "You can't have multiple sources with the same name" // UserIsInvalidErr err if user is invalid UserIsInvalidErr string = "user is invalid" )
const ( // HeaderStatus headername for status in response HeaderStatus string = "X-Response-Status" // HeaderStatusMessage headername for status in response HeaderStatusMessage string = "X-Response-Message" // HeaderContentType contenttype of response HeaderContentType string = "Content-Type" // HeaderFileName filename header HeaderFileName string = "X-Filename" // HeaderFileID fileid header HeaderFileID string = "X-FileID" // HeaderEncryption encryption header HeaderEncryption string = "X-Encryption" // HeaderRequest request content HeaderRequest string = "Request" // HeaderContentLength request content length HeaderContentLength string = "ContentLength" // HeaderChecksum files checksum HeaderChecksum string = "Checksum" )
const SessionTokenLength = 64
SessionTokenLength length of session token
Variables ¶
var ErrorUserAlreadyExists = errors.New("user already exists")
ErrorUserAlreadyExists error if user exists
Functions ¶
func GetDefaultConfig ¶
func GetDefaultConfig() string
GetDefaultConfig gets the default config path
Types ¶
type Config ¶
type Config struct { Server configServer Webserver webserverConf }
Config config for the server
func InitConfig ¶
InitConfig inits the config Returns true if system should exit
func (Config) GetDefaultRole ¶
GetDefaultRole return the path and file for an uploaded file
func (Config) GetHTMLFile ¶
GetHTMLFile return path of html file
func (Config) GetStaticFile ¶
GetStaticFile return path of html file
func (Config) GetStorageFile ¶
GetStorageFile return the path and file for an uploaded file
func (Config) GetTemplateFile ¶
GetTemplateFile return path of html file
func (Config) IsRawUseragent ¶
IsRawUseragent return true if file should be raw depending on useragent
type CountResponse ¶
type CountResponse struct {
Count uint32 `json:"count"`
}
CountResponse response containing a count of changed items
type CredentialsRequest ¶
type CredentialsRequest struct { MachineID string `json:"mid,omitempty"` Username string `json:"username"` Password string `json:"pass"` }
CredentialsRequest request containing credentials
type IDsResponse ¶
type IDsResponse struct {
IDs []uint `json:"ids"`
}
IDsResponse response containing a list of ids
type LoginResponse ¶
type LoginResponse struct {
Token string `json:"token"`
}
LoginResponse response for login
type LoginSession ¶
type LoginSession struct { gorm.Model User *User `gorm:"association_autoupdate:false;association_autocreate:false"` UserID uint Token string Requests int64 MachineID string }
LoginSession session for loggedin user
func NewSession ¶
func NewSession(user *User, machineID string) *LoginSession
NewSession create new login session
type Namespaceinfo ¶
Namespaceinfo info for namespace
type Permission ¶
type Permission uint8
Permission permission for roles
const ( NoPermission Permission = iota ReadPermission Writepermission )
Permissions
type ResponseStatus ¶
type ResponseStatus uint8
ResponseStatus the status of response
const ( //ResponseError if there was an error ResponseError ResponseStatus = 0 //ResponseSuccess if the response is successful ResponseSuccess ResponseStatus = 1 )
type Role ¶
type Role struct { ID uint `gorm:"pk"` RoleName string `gorm:"not null"` IsAdmin bool `gorm:"default:false"` AccesForeignNamespaces Permission `gorm:"type:smallint"` MaxURLcontentSize int64 MaxUploadFileSize int64 CreateNamespaces bool }
Role roles for user
type StringResponse ¶
type StringResponse struct {
String string `json:"content"`
}
StringResponse response containing only one string
type StringSliceResponse ¶
type StringSliceResponse struct {
Slice []string `json:"slice"`
}
StringSliceResponse response containing only one string slice
type UploadType ¶
type UploadType uint8
UploadType type of upload
const ( FileUploadType UploadType = iota URLUploadType )
Available upload types
type User ¶
type User struct { gorm.Model Username string Password string RoleID uint `sql:"index"` Role *Role `gorm:"association_autoupdate:false;association_autocreate:false"` }
User user in db
func GetUserFromSession ¶
GetUserFromSession return user from session
func (User) AllowedToUploadURLs ¶
AllowedToUploadURLs gets upload limit
func (User) CanCreateNamespaces ¶
CanCreateNamespaces return true if user can create user namespaces
func (User) CanReadForeignNamespace ¶
CanReadForeignNamespace return true if user is allowed to read in foreign namespaces
func (User) CanUploadFiles ¶
CanUploadFiles return true if user can upload files
func (User) CanWriteForeignNamespace ¶
CanWriteForeignNamespace return true if user is allowed to write in foreign namespaces
func (User) HasUploadLimit ¶
HasUploadLimit gets upload limit
type UserAttributeDataResponse ¶
type UserAttributeDataResponse struct {
Namespace []Namespaceinfo `json:"nsData"`
}
UserAttributeDataResponse response for userattribute data
type UserAttributesRequest ¶
type UserAttributesRequest struct {
Mode uint `json:"m"`
}
UserAttributesRequest request for getting namespaces and groups