models

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ApiPermView is the permission for viewing metadata of all uploaded files
	ApiPermView = 1 << iota
	// ApiPermUpload is the permission for creating new files
	ApiPermUpload
	// ApiPermDelete is the permission for deleting files
	ApiPermDelete
	// ApiPermApiMod is the permission for adding / removing API key permissions
	ApiPermApiMod
	// ApiPermEdit is the permission for editing parameters of uploaded files
	ApiPermEdit
)
View Source
const ApiPermAll = 31

ApiPermAll means all permission granted

View Source
const ApiPermAllNoApiMod = 23

ApiPermAllNoApiMod means all permission granted, except ApiPermApiMod

View Source
const ApiPermNone = 0

ApiPermNone means no permission granted

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiKey

type ApiKey struct {
	Id             string `json:"Id"`
	FriendlyName   string `json:"FriendlyName"`
	LastUsedString string `json:"LastUsedString"`
	LastUsed       int64  `json:"LastUsed"`
	Permissions    uint8  `json:"Permissions"`
}

ApiKey contains data of a single api key

func (*ApiKey) HasPermission added in v1.8.0

func (key *ApiKey) HasPermission(permission uint8) bool

HasPermission returns true if the key has the permission(s)

func (*ApiKey) HasPermissionApiMod added in v1.8.0

func (key *ApiKey) HasPermissionApiMod() bool

HasPermissionApiMod returns true if ApiPermApiMod is granted

func (*ApiKey) HasPermissionDelete added in v1.8.0

func (key *ApiKey) HasPermissionDelete() bool

HasPermissionDelete returns true if ApiPermDelete is granted

func (*ApiKey) HasPermissionEdit added in v1.8.0

func (key *ApiKey) HasPermissionEdit() bool

HasPermissionEdit returns true if ApiPermEdit is granted

func (*ApiKey) HasPermissionUpload added in v1.8.0

func (key *ApiKey) HasPermissionUpload() bool

HasPermissionUpload returns true if ApiPermUpload is granted

func (*ApiKey) HasPermissionView added in v1.8.0

func (key *ApiKey) HasPermissionView() bool

HasPermissionView returns true if ApiPermView is granted

func (*ApiKey) RemovePermission added in v1.8.0

func (key *ApiKey) RemovePermission(permission uint8)

RemovePermission revokes one or more permissions

func (*ApiKey) SetPermission added in v1.8.0

func (key *ApiKey) SetPermission(permission uint8)

SetPermission grants one or more permissions

type ApiKeyOutput added in v1.8.1

type ApiKeyOutput struct {
	Result string
	Id     string
}

type AuthenticationConfig

type AuthenticationConfig struct {
	Method               int      `json:"Method"`
	SaltAdmin            string   `json:"SaltAdmin"`
	SaltFiles            string   `json:"SaltFiles"`
	Username             string   `json:"Username"`
	Password             string   `json:"Password"`
	HeaderKey            string   `json:"HeaderKey"`
	OAuthProvider        string   `json:"OauthProvider"`
	OAuthClientId        string   `json:"OAuthClientId"`
	OAuthClientSecret    string   `json:"OAuthClientSecret"`
	OAuthUserScope       string   `json:"OauthUserScope"`
	OAuthGroupScope      string   `json:"OauthGroupScope"`
	OAuthRecheckInterval int      `json:"OAuthRecheckInterval"`
	HeaderUsers          []string `json:"HeaderUsers"`
	OAuthGroups          []string `json:"OAuthGroups"`
	OAuthUsers           []string `json:"OauthUsers"`
}

AuthenticationConfig holds configuration on how to authenticate to Gokapi admin menu

type AwsConfig

type AwsConfig struct {
	Bucket    string `yaml:"Bucket"`
	Region    string `yaml:"Region"`
	KeyId     string `yaml:"KeyId"`
	KeySecret string `yaml:"KeySecret"`
	Endpoint  string `yaml:"Endpoint"`
}

AwsConfig contains all configuration values / credentials for AWS cloud storage

func (*AwsConfig) IsAllProvided

func (c *AwsConfig) IsAllProvided() bool

IsAllProvided returns true if all required variables have been set for using AWS S3 / Backblaze

type Configuration

type Configuration struct {
	Authentication      AuthenticationConfig `json:"Authentication"`
	Port                string               `json:"Port"`
	ServerUrl           string               `json:"ServerUrl"`
	RedirectUrl         string               `json:"RedirectUrl"`
	PublicName          string               `json:"PublicName"`
	ConfigVersion       int                  `json:"ConfigVersion"`
	LengthId            int                  `json:"LengthId"`
	DataDir             string               `json:"DataDir"`
	MaxMemory           int                  `json:"MaxMemory"`
	UseSsl              bool                 `json:"UseSsl"`
	MaxFileSizeMB       int                  `json:"MaxFileSizeMB"`
	Encryption          Encryption           `json:"Encryption"`
	PicturesAlwaysLocal bool                 `json:"PicturesAlwaysLocal"`
	SaveIp              bool                 `json:"SaveIp"`
}

Configuration is a struct that contains the global configuration

func (Configuration) ToJson

func (c Configuration) ToJson() []byte

ToJson returns an idented JSon representation

func (Configuration) ToString

func (c Configuration) ToString() string

ToString returns the object as an unidented Json string used for test units

type DownloadStatus

type DownloadStatus struct {
	Id       string
	FileId   string
	ExpireAt int64
}

DownloadStatus contains current downloads, so they do not get removed during cleanup

type E2EFile added in v1.6.0

type E2EFile struct {
	Uuid     string `json:"uuid"`
	Id       string `json:"id"`
	Filename string `json:"filename"`
	Cipher   []byte `json:"cipher"`
}

E2EFile contains information about a stored e2e file

type E2EHashContent added in v1.6.0

type E2EHashContent struct {
	Filename string `json:"f"`
	Cipher   string `json:"c"`
}

E2EHashContent contains the info that is added after the hash for an e2e link

type E2EInfoEncrypted added in v1.6.0

type E2EInfoEncrypted struct {
	// Version of the E2E used, must be at least 1
	Version int `json:"version"`
	// Nonce used for encryption
	Nonce []byte `json:"nonce"`
	// Content that is encrypted
	Content []byte `json:"content"`
	// AvailableFiles contains a list of all files on the webserver and will be populated
	// when reading from the database, but will not be saved to the database
	AvailableFiles []string `json:"availablefiles"`
}

E2EInfoEncrypted is the struct that is stored on the server and decrypted locally

func (*E2EInfoEncrypted) HasBeenSetUp added in v1.6.0

func (e *E2EInfoEncrypted) HasBeenSetUp() bool

HasBeenSetUp returns true if E2E setup has been run

type E2EInfoPlainText added in v1.6.0

type E2EInfoPlainText struct {
	Files []E2EFile `json:"files"`
}

E2EInfoPlainText is stored locally and will be encrypted before storing on server

type Encryption

type Encryption struct {
	Level        int
	Cipher       []byte
	Salt         string
	Checksum     string
	ChecksumSalt string
}

Encryption hold information about the encryption used on this file

type EncryptionInfo

type EncryptionInfo struct {
	IsEncrypted         bool   `json:"IsEncrypted"`
	IsEndToEndEncrypted bool   `json:"IsEndToEndEncrypted"`
	DecryptionKey       []byte `json:"DecryptionKey"`
	Nonce               []byte `json:"Nonce"`
}

EncryptionInfo holds information about the encryption used on the file

type File

type File struct {
	Id                 string         `json:"Id"`
	Name               string         `json:"Name"`
	Size               string         `json:"Size"`
	SHA1               string         `json:"SHA1"`
	ExpireAt           int64          `json:"ExpireAt"`
	SizeBytes          int64          `json:"SizeBytes"`
	ExpireAtString     string         `json:"ExpireAtString"`
	DownloadsRemaining int            `json:"DownloadsRemaining"`
	DownloadCount      int            `json:"DownloadCount"`
	PasswordHash       string         `json:"PasswordHash"`
	HotlinkId          string         `json:"HotlinkId"`
	ContentType        string         `json:"ContentType"`
	AwsBucket          string         `json:"AwsBucket"`
	Encryption         EncryptionInfo `json:"Encryption"`
	UnlimitedDownloads bool           `json:"UnlimitedDownloads"`
	UnlimitedTime      bool           `json:"UnlimitedTime"`
}

File is a struct used for saving information about an uploaded file

func (*File) IsLocalStorage added in v1.6.0

func (f *File) IsLocalStorage() bool

IsLocalStorage returns true if the file is not stored on a remote storage

func (*File) RequiresClientDecryption added in v1.7.0

func (f *File) RequiresClientDecryption() bool

RequiresClientDecryption checks if the file needs to be decrypted by the client (if remote storage or end-to-end encryption)

func (*File) ToFileApiOutput added in v1.6.0

func (f *File) ToFileApiOutput() (FileApiOutput, error)

ToFileApiOutput returns a json object without sensitive information

func (*File) ToJsonResult

func (f *File) ToJsonResult(serverUrl string) string

ToJsonResult converts the file info to a json String used for returning a result for an upload

type FileApiOutput added in v1.6.0

type FileApiOutput struct {
	Id                           string `json:"Id"`
	Name                         string `json:"Name"`
	Size                         string `json:"Size"`
	HotlinkId                    string `json:"HotlinkId"`
	ContentType                  string `json:"ContentType"`
	ExpireAt                     int64  `json:"ExpireAt"`
	SizeBytes                    int64  `json:"SizeBytes"`
	ExpireAtString               string `json:"ExpireAtString"`
	DownloadsRemaining           int    `json:"DownloadsRemaining"`
	DownloadCount                int    `json:"DownloadCount"`
	UnlimitedDownloads           bool   `json:"UnlimitedDownloads"`
	UnlimitedTime                bool   `json:"UnlimitedTime"`
	RequiresClientSideDecryption bool   `json:"RequiresClientSideDecryption"`
	IsEncrypted                  bool   `json:"IsEncrypted"`
	IsPasswordProtected          bool   `json:"IsPasswordProtected"`
	IsSavedOnLocalStorage        bool   `json:"IsSavedOnLocalStorage"`
}

FileApiOutput will be displayed for public outputs from the ID, hiding sensitive information

type LastUploadValues

type LastUploadValues struct {
	Downloads         int
	TimeExpiry        int
	Password          string
	UnlimitedDownload bool
	UnlimitedTime     bool
}

LastUploadValues is used to save the last used values for uploads in the database

type Result

type Result struct {
	Result            string        `json:"Result"`
	FileInfo          FileApiOutput `json:"FileInfo"`
	Url               string        `json:"Url"`
	HotlinkUrl        string        `json:"HotlinkUrl"`
	GenericHotlinkUrl string        `json:"GenericHotlinkUrl"`
}

Result is the struct used for the result after an upload swagger:model UploadResult

type Session

type Session struct {
	RenewAt    int64
	ValidUntil int64
}

Session contains cookie parameter

type UploadRequest

type UploadRequest struct {
	AllowedDownloads    int
	Expiry              int
	ExpiryTimestamp     int64
	Password            string
	ExternalUrl         string
	MaxMemory           int
	UnlimitedDownload   bool
	UnlimitedTime       bool
	IsEndToEndEncrypted bool
	RealSize            int64
}

UploadRequest is used to set an upload request

type UploadStatus added in v1.7.0

type UploadStatus struct {
	// ChunkId is the identifier for the chunk
	ChunkId string `json:"chunkid"`
	// CurrentStatus indicates if the chunk is currently being processed (e.g. encrypting or
	// hashing) or being moved/uploaded to the file storage
	// See processingstatus for definition
	CurrentStatus int `json:"currentstatus"`
	// LastUpdate indicates the last status change
	LastUpdate int64 `json:"lastupdate"`
}

UploadStatus contains information about the current status of a file upload

func (*UploadStatus) ToJson added in v1.7.0

func (u *UploadStatus) ToJson() ([]byte, error)

ToJson returns the struct as a Json byte array

Jump to

Keyboard shortcuts

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