Documentation
¶
Overview ¶
Package client implements a client library for OTS supporting the OTSMeta content format for file upload support
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAttachmentsDisabled signalizes the instance has attachments // disabled but the checked secret contains attachments ErrAttachmentsDisabled = errors.New("attachments are disabled on this instance") // ErrAttachmentsTooLarge signalizes the size of the attached files // exceeds the configured maximum size of the given instance ErrAttachmentsTooLarge = errors.New("attachment size exceeds allowed size") // ErrAttachmentTypeNotAllowed signalizes any file does not match // the allowed extensions / mime types ErrAttachmentTypeNotAllowed = errors.New("attachment type is not allowed") )
var KeyDerivationFunc = openssl.NewPBKDF2Generator(sha512.New, 300000) //nolint:mnd // that's the definition
KeyDerivationFunc defines the key derivation algorithm used in OTS to derive the key / iv from the password for encryption. You only should change this if you are running an OTS instance with modified parameters.
The corresponding settings are found in `/src/crypto.js` in the OTS source code.
var Logger *logrus.Entry
Logger can be set to enable logging from the library. By default all log-messages will be discarded.
var PasswordLength = 20
PasswordLength defines the length of the generated encryption password
var RequestTimeout = 5 * time.Second
RequestTimeout defines how long the request to the OTS instance for create and fetch may take
var UserAgent = "ots-client/1.x +https://github.com/Luzifer/ots"
UserAgent defines the user-agent to send when interacting with an OTS instance. When using this library please set this to something the operator of the instance can determine your client from and provide an URL to useful information about your tool.
Functions ¶
func Create ¶
Create serializes the secret and creates a new secret on the instance given by its URL.
The given URL should point to the frontend of the instance. Do not include the API paths, they are added automatically. For the expireIn parameter zero value can be used to use server-default.
So for OTS.fyi you'd use `New("https://ots.fyi/")`
func SanityCheck ¶
SanityCheck fetches the instance settings and validates the secret against those settings (matching file size, disabled attachments, allowed file types, ...)
Types ¶
type HTTPClientIntf ¶
HTTPClientIntf describes a minimal interface to be fulfilled by the given HTTP client. This can be used for mocking and to pass in authenticated clients
var HTTPClient HTTPClientIntf = http.DefaultClient
HTTPClient defines the client to use for create and fetch requests and can be overwritten to provide authentication
type Secret ¶
type Secret struct { Secret string `json:"secret"` Attachments []SecretAttachment `json:"attachments,omitempty"` }
Secret represents a secret parsed from / prepared for serialization to the OTS API
type SecretAttachment ¶
type SecretAttachment struct { Name string `json:"name"` Type string `json:"type"` Data string `json:"data"` Content []byte `json:"-"` }
SecretAttachment represents a file attached to a Secret. The Data property must be the plain content (binary / text / ...) of the file to attach. The base64 en-/decoding is done transparently. The Name is the name of the file shown to the user (so ideally should be the file-name on the source system). The Type should contain the mime time of the file or an empty string.