Documentation
¶
Index ¶
- Constants
- type ApiKey
- func (key *ApiKey) GetReadableDate() string
- func (key *ApiKey) HasPermission(permission uint8) bool
- func (key *ApiKey) HasPermissionApiMod() bool
- func (key *ApiKey) HasPermissionDelete() bool
- func (key *ApiKey) HasPermissionEdit() bool
- func (key *ApiKey) HasPermissionReplace() bool
- func (key *ApiKey) HasPermissionUpload() bool
- func (key *ApiKey) HasPermissionView() bool
- func (key *ApiKey) RemovePermission(permission uint8)
- func (key *ApiKey) SetPermission(permission uint8)
- type ApiKeyOutput
- type AuthenticationConfig
- type AwsConfig
- type Configuration
- type DbConnection
- type DownloadStatus
- type E2EFile
- type E2EHashContent
- type E2EInfoEncrypted
- type E2EInfoPlainText
- type Encryption
- type EncryptionInfo
- type File
- type FileApiOutput
- type Result
- type Session
- type UploadRequest
- type UploadStatus
Constants ¶
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 // ApiPermReplace is the permission for replacing the content of uploaded files ApiPermReplace )
const ApiPermAll = 63
ApiPermAll means all permission granted
const ApiPermAllNoApiMod = ApiPermAll - ApiPermApiMod - ApiPermReplace
ApiPermAllNoApiMod means all permission granted, except ApiPermApiMod and ApiPermReplace This is the default for new API keys that are created from the UI
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" redis:"Id"`
FriendlyName string `json:"FriendlyName" redis:"FriendlyName"`
LastUsed int64 `json:"LastUsed" redis:"LastUsed"`
Permissions uint8 `json:"Permissions" redis:"Permissions"`
Expiry int64 `json:"Expiry" redis:"Expiry"` // Does not expire if 0
IsSystemKey bool `json:"IsSystemKey" redis:"IsSystemKey"`
}
ApiKey contains data of a single api key
func (*ApiKey) GetReadableDate ¶ added in v1.9.0
GetReadableDate returns the date as YYYY-MM-DD HH:MM:SS
func (*ApiKey) HasPermission ¶ added in v1.8.0
HasPermission returns true if the key has the permission(s)
func (*ApiKey) HasPermissionApiMod ¶ added in v1.8.0
HasPermissionApiMod returns true if ApiPermApiMod is granted
func (*ApiKey) HasPermissionDelete ¶ added in v1.8.0
HasPermissionDelete returns true if ApiPermDelete is granted
func (*ApiKey) HasPermissionEdit ¶ added in v1.8.0
HasPermissionEdit returns true if ApiPermEdit is granted
func (*ApiKey) HasPermissionReplace ¶ added in v1.9.6
HasPermissionReplace returns true if ApiPermReplace is granted
func (*ApiKey) HasPermissionUpload ¶ added in v1.8.0
HasPermissionUpload returns true if ApiPermUpload is granted
func (*ApiKey) HasPermissionView ¶ added in v1.8.0
HasPermissionView returns true if ApiPermView is granted
func (*ApiKey) RemovePermission ¶ added in v1.8.0
RemovePermission revokes one or more permissions
func (*ApiKey) SetPermission ¶ added in v1.8.0
SetPermission grants one or more permissions
type ApiKeyOutput ¶ added in v1.8.1
ApiKeyOutput is the output that is used after a new key is created
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"`
ProxyDownload bool `yaml:"ProxyDownload"`
}
AwsConfig contains all configuration values / credentials for AWS cloud storage
func (*AwsConfig) IsAllProvided ¶
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"`
DataDir string `json:"DataDir"`
DatabaseUrl string `json:"DatabaseUrl"`
ConfigVersion int `json:"ConfigVersion"`
LengthId int `json:"LengthId"`
MaxFileSizeMB int `json:"MaxFileSizeMB"`
MaxMemory int `json:"MaxMemory"`
ChunkSize int `json:"ChunkSize"`
MaxParallelUploads int `json:"MaxParallelUploads"`
Encryption Encryption `json:"Encryption"`
UseSsl bool `json:"UseSsl"`
PicturesAlwaysLocal bool `json:"PicturesAlwaysLocal"`
SaveIp bool `json:"SaveIp"`
IncludeFilename bool `json:"IncludeFilename"`
}
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 DbConnection ¶ added in v1.9.0
type DbConnection struct {
HostUrl string
RedisPrefix string
Username string
Password string
RedisUseSsl bool
Type int
}
DbConnection is a struct that contains the database configuration for connecting
type DownloadStatus ¶
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
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" redis:"version"`
// Nonce used for encryption
Nonce []byte `json:"nonce" redis:"nonce"`
// Content that is encrypted
Content []byte `json:"content" redis:"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" redis:"-"`
}
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 ¶
Encryption hold information about the encryption used on this file
type EncryptionInfo ¶
type EncryptionInfo struct {
IsEncrypted bool `json:"IsEncrypted" redis:"IsEncrypted"`
IsEndToEndEncrypted bool `json:"IsEndToEndEncrypted" redis:"IsEndToEndEncrypted"`
DecryptionKey []byte `json:"DecryptionKey" redis:"DecryptionKey"`
Nonce []byte `json:"Nonce" redis:"Nonce"`
}
EncryptionInfo holds information about the encryption used on the file
type File ¶
type File struct {
Id string `json:"Id" redis:"Id"` // The internal ID of the file
Name string `json:"Name" redis:"Name"` // The filename. Will be 'Encrypted file' for end-to-end encrypted files
Size string `json:"Size" redis:"Size"` // Filesize in a human-readable format
SHA1 string `json:"SHA1" redis:"SHA1"` // The hash of the file, used for deduplication
PasswordHash string `json:"PasswordHash" redis:"PasswordHash"` // The hash of the password (if the file is password protected)
HotlinkId string `json:"HotlinkId" redis:"HotlinkId"` // If file is a picture file and can be hotlinked, this is the ID for the hotlink
ContentType string `json:"ContentType" redis:"ContentType"` // The MIME type for the file
AwsBucket string `json:"AwsBucket" redis:"AwsBucket"` // If the file is stored in the cloud, this is the bucket that is being used
ExpireAtString string `json:"ExpireAtString" redis:"ExpireAtString"` // Time expiry in a human-readable format in local time
ExpireAt int64 `json:"ExpireAt" redis:"ExpireAt"` // "UTC timestamp of file expiry
SizeBytes int64 `json:"SizeBytes" redis:"SizeBytes"` // Filesize in bytes
DownloadsRemaining int `json:"DownloadsRemaining" redis:"DownloadsRemaining"` // The remaining downloads for this file
DownloadCount int `json:"DownloadCount" redis:"DownloadCount"` // The amount of times the file has been downloaded
Encryption EncryptionInfo `json:"Encryption" redis:"-"` // If the file is encrypted, this stores all info for decrypting
UnlimitedDownloads bool `json:"UnlimitedDownloads" redis:"UnlimitedDownloads"` // True if the uploader did not limit the downloads
UnlimitedTime bool `json:"UnlimitedTime" redis:"UnlimitedTime"` // True if the uploader did not limit the time
InternalRedisEncryption []byte `redis:"EncryptionRedis"` // This field is an internal field, used to store the EncryptionInfo in a Redis Hashmap
}
File is a struct used for saving information about an uploaded file
func (*File) IsLocalStorage ¶ added in v1.6.0
IsLocalStorage returns true if the file is not stored on a remote storage
func (*File) RequiresClientDecryption ¶ added in v1.7.0
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(serverUrl string, useFilenameInUrl bool) (FileApiOutput, error)
ToFileApiOutput returns a json object without sensitive information
type FileApiOutput ¶ added in v1.6.0
type FileApiOutput struct {
Id string `json:"Id"` // The internal ID of the file
Name string `json:"Name"` // The filename. Will be 'Encrypted file' for end-to-end encrypted files
Size string `json:"Size"` // Filesize in a human-readable format
HotlinkId string `json:"HotlinkId"` // If file is a picture file and can be hotlinked, this is the ID for the hotlink
ContentType string `json:"ContentType"` // The MIME type for the file
ExpireAtString string `json:"ExpireAtString"` // Time expiry in a human-readable format in local time
UrlDownload string `json:"UrlDownload"` // The public download URL for the file
UrlHotlink string `json:"UrlHotlink"` // The public hotlink URL for the file
ExpireAt int64 `json:"ExpireAt"` // "UTC timestamp of file expiry
SizeBytes int64 `json:"SizeBytes"` // Filesize in bytes
DownloadsRemaining int `json:"DownloadsRemaining"` // The remaining downloads for this file
DownloadCount int `json:"DownloadCount"` // The amount of times the file has been downloaded
UnlimitedDownloads bool `json:"UnlimitedDownloads"` // True if the uploader did not limit the downloads
UnlimitedTime bool `json:"UnlimitedTime"` // True if the uploader did not limit the time
RequiresClientSideDecryption bool `json:"RequiresClientSideDecryption"` // True if the file has to be decrypted client-side
IsEncrypted bool `json:"IsEncrypted"` // True if the file is encrypted
IsEndToEndEncrypted bool `json:"IsEndToEndEncrypted"` // True if the file is end-to-end encrypted
IsPasswordProtected bool `json:"IsPasswordProtected"` // True if a password has to be entered before downloading the file
IsSavedOnLocalStorage bool `json:"IsSavedOnLocalStorage"` // True if the file does not use cloud storage
}
FileApiOutput will be displayed for public outputs from the ID, hiding sensitive information
type Result ¶
type Result struct {
Result string `json:"Result"`
FileInfo FileApiOutput `json:"FileInfo"`
IncludeFilename bool `json:"IncludeFilename"`
}
Result is the struct used for the result after an upload swagger:model UploadResult
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
// 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
// FileId is populated, once a file has been created from a chunk
FileId string
// ErrorMessage is empty, unless an error occurred
ErrorMessage string `json:"errormessage"`
// Creation is the unix time when the status was created and is populated automatically
Creation int64
}
UploadStatus contains information about the current status of a file upload