Files
sm-bm-plugin/classes/uploads.go
Jakub Zych ce6ac0a78e test: expect signed one-time material uploads
- TestUploadTicket: HMAC under the jz.bm.upload.v1: label, expiry,
  malformed and foreign tickets, single use through the cache
- TestSignedMaterialUploadRefusesBadTickets, TestCreateMaterialUploadNeedsCaller
- TestRoutes, TestBMMCP and TestManageBucketKey expect the upload-url
  route, the uploads route with its two buckets and the upload tool
- compile-only stubs
2026-10-28 15:07:30 +01:00

50 lines
1.4 KiB
Go

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
}