Documentation
¶
Overview ¶
Package proxy implements a storage proxy that provides presigned URL generation
Index ¶
- Constants
- Variables
- func ComposeShareToken(orgID, signature string) string
- func ComposeShareURL(baseURL, shareID, tokenString string) string
- func GenerateDownloadURL(ctx context.Context, file *storagetypes.File, duration time.Duration, ...) (string, error)
- func GenerateDownloadURLWithSecret(file *storagetypes.File, secret []byte, duration time.Duration, ...) (string, error)
- func NewShareVerifiedToken(tm *tokens.TokenManager, issuer, shareID, recipientHash string) (string, error)
- func NormalizeRecipientEmail(email string) string
- func RecipientHash(email string) string
- func ShouldBypassPresignInterceptor(ctx context.Context) bool
- func SplitShareToken(token string) (string, string, bool)
- func VerifyShareVerifiedToken(tm *tokens.TokenManager, issuer, tokenString string) (string, string, error)
- func WithPresignInterceptorBypass(ctx context.Context) context.Context
Constants ¶
const ( // DefaultPresignDuration is the default duration for presigned URLs DefaultPresignDurationMinutes = 15 // SecretDivisor is used to split the secret into nonce and key components SecretDivisor = 2 )
const ( // DownloadAudience is the audience claim carried by every share-verified token; it must differ from the // session audience so a share-verified token is never accepted as a session and vice versa DownloadAudience = "openlane-files" ShareVerifiedTokenType = "share-verified" ShareVerifiedDuration = 15 * time.Minute MaxShareDuration = 30 * 24 * time.Hour MaxShareFiles = 20 UnlimitedShareUses = 0 // ClaimType is the claim naming the token type ClaimType = "typ" ClaimShareID = "sid" // ClaimRecipient is the claim carrying the sha256 hex of the normalized recipient email ClaimRecipient = "rcp" )
Variables ¶
var ( // ErrMissingFileID indicates that the file ID is missing ErrMissingFileID = errors.New("missing file id") // ErrMissingObjectURI indicates that the file metadata is missing the object URI ErrMissingObjectURI = errors.New("file metadata missing object URI") // ErrInvalidSecretLength indicates that the secret must be 128 bytes when provided ErrInvalidSecretLength = errors.New("secret must be 128 bytes when provided") // ErrCallerRequired indicates that a caller is required in the context. ErrCallerRequired = errors.New("caller required in context") ErrShareVerifiedTokenInvalid = errors.New("invalid share verified token") ErrShareVerifiedTokenType = errors.New("share verified token type mismatch") )
var ( // ErrTokenManagerRequired indicates proxy signing is impossible without a token manager. ErrTokenManagerRequired = errors.New("proxy presign requires token manager") // ErrEntClientRequired indicates storing secrets requires an ent client. ErrEntClientRequired = errors.New("storing secrets requires ent client") )
Functions ¶
func ComposeShareToken ¶
ComposeShareToken builds the share token carried by the share URL from the owning organization id and the signature
func ComposeShareURL ¶
ComposeShareURL builds the share URL under the storage links base URL carrying the share token
func GenerateDownloadURL ¶
func GenerateDownloadURL(ctx context.Context, file *storagetypes.File, duration time.Duration, cfg *storage.ProxyPresignConfig) (string, error)
GenerateDownloadURL builds a proxy download URL and persists the signing secret for validation.
func GenerateDownloadURLWithSecret ¶
func GenerateDownloadURLWithSecret(file *storagetypes.File, secret []byte, duration time.Duration, cfg *storage.ProxyPresignConfig) (string, error)
GenerateDownloadURLWithSecret builds a proxy download URL using the provided secret for testing.
func NewShareVerifiedToken ¶
func NewShareVerifiedToken(tm *tokens.TokenManager, issuer, shareID, recipientHash string) (string, error)
NewShareVerifiedToken mints the token proving the recipient of a share verified their email
func NormalizeRecipientEmail ¶
NormalizeRecipientEmail returns the trimmed, lowercased form of a recipient email
func RecipientHash ¶
RecipientHash returns the sha256 hex of the normalized recipient email
func ShouldBypassPresignInterceptor ¶
ShouldBypassPresignInterceptor reports whether presign interceptors should be skipped.
func SplitShareToken ¶
SplitShareToken returns the organization id and the signature carried by a share token
func VerifyShareVerifiedToken ¶
func VerifyShareVerifiedToken(tm *tokens.TokenManager, issuer, tokenString string) (string, string, error)
VerifyShareVerifiedToken checks the signature, issuer, audience, expiry, and type of a share-verified token and returns its share id and recipient hash
Types ¶
This section is empty.