package classes import ( "context" "errors" "time" "git.golem15.com/golem15/summercms/modules/cooler" ) // UploadTTL is how long an upload URL is valid. const UploadTTL = 10 * time.Minute var ( // ErrUploadTicket is every refused upload ticket. ErrUploadTicket = errors.New("bm: invalid or expired upload ticket") // ErrUploadKeyMissing means no key to sign upload tickets with. ErrUploadKeyMissing = errors.New("bm: upload key is not configured") ) // UploadTicket is what a signed upload URL grants. type UploadTicket struct { Kind string Target uint User uint Expires time.Time Nonce string } // UploadKey is the signing key from the app key. func UploadKey(appKey string) []byte { return nil } // SignUpload signs t. func SignUpload(key []byte, t UploadTicket) (string, error) { return "", nil } // VerifyUpload checks a ticket. func VerifyUpload(key []byte, ticket string, now time.Time) (UploadTicket, error) { return UploadTicket{}, nil } // IssueUpload signs and registers a ticket. func IssueUpload(ctx context.Context, cache cooler.Cache, key []byte, kind string, target, user uint, now time.Time) (string, time.Time, error) { return "", time.Time{}, nil } // RedeemUpload verifies and consumes a ticket. func RedeemUpload(ctx context.Context, cache cooler.Cache, key []byte, ticket string, now time.Time) (UploadTicket, error) { return UploadTicket{}, nil }