3 ms·
Hi, I haven't had time to write up about this, however, I have dumped the majority of the related code here for you and others who are interested in this soluti
by chocolatkey 7y ago
Hi, I haven't had time to write up about this, however, I have dumped the majority of the related code here for you and others who are interested in this solution: https://gist.github.com/chocolatkey/a7ef0364e357629e9875521ddc8bc03a https://gist.github.com/chocolatkey/a7ef0364e357629e9875521d.... That should help you get started. It includes HMACSHA256 shared secret URL signatures based on IP, expiry, and optional path scope restriction, caching, ETAGs, sentry error reports, access to non-B2 data from a server w/ basic auth, and more... URLs look like this: https://example.com/delivery/UNIQUE_ID/p-001.jpg?token=16fb4112744c20a1f71f2730072f9457612a90ce00cdb6a1ccdf639e4b31966e&expires=5e450200&scope=%2Fdelivery%2FUNIQUE_ID%2F https://example.com/delivery/UNIQUE_ID/p-001.jpg?token=16fb4... . My B2 bucket is public, however the requested path is also hmac'd with a secret known only to the CF worker to derive the path of the resources in the bucket. It is optimized for my use case of serving EPUB data. I do not guarantee it to be free of flaws, but it's worked well so far.
- SergeAx 7y agoThanks a lot!