Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tus endpoints may return malformed expiry header #4379

Open
butonic opened this issue Nov 30, 2023 · 0 comments
Open

Tus endpoints may return malformed expiry header #4379

butonic opened this issue Nov 30, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@butonic
Copy link
Contributor

butonic commented Nov 30, 2023

The pkg/rhttp/datatx/manager/tus/tus.go setHeaders() function returns the expires metadata as the Tus Upload-Expires header:

	expires := info.MetaData["expires"]
	if expires != "" {
		w.Header().Set(net.HeaderTusUploadExpires, expires)
	}

The storageprovider.go sets expires as a unix timestamp in InitiateFileUpload():

	var expirationTimestamp *typesv1beta1.Timestamp
	if s.conf.UploadExpiration > 0 {
		expirationTimestamp = &typesv1beta1.Timestamp{
			Seconds: uint64(time.Now().UTC().Add(time.Duration(s.conf.UploadExpiration) * time.Second).Unix()),
		}
		metadata["expires"] = strconv.Itoa(int(expirationTimestamp.Seconds))
	}

This violates the Tus spec: Upload-Expires MUST be RFC 7231 datetime format, see https://tus.io/protocols/resumable-upload#upload-expires

We need to parste the timestamp and convert it. Aaaaand we should not use the tus metadata to transport the expiry. That is just a hacky workaround, anyway.

@butonic butonic added the bug Something isn't working label Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant