-
Notifications
You must be signed in to change notification settings - Fork 75
Image Camo extension #332
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
base: master
Are you sure you want to change the base?
Image Camo extension #332
Conversation
Thanks 👍🏻 |
Co-authored-by: Alexandre Alapetite <[email protected]>
I've added references in the README and the JSON file. |
I have not checked the differences with the existing https://github.com/FreshRSS/Extensions/tree/master/xExtension-ImageProxy |
Ping @Frenzie |
I don't really know why this Camo would need a fully separate extension. Maybe something about authentication didn't fit into the existing setup very well and it couldn't be elegantly added. It sounds like it's basically go for ImageProxy unless you specifically want to use Camo. |
The software I'm using is https://github.com/cactus/go-camo. The main difference compared to the existing image proxies it means you're not just running an open proxy - which isn't really the greatest security idea. It's a separate extension primarily because of the config, although it could have the image URL replacement logic shared. It's not that complex though, so I didn't think it was worth it. |
The camo former is not specific to this software though, GitHub's implementation was in JS I think? The important part is this URL format: private static function generateBase64CamoUrl(string $hmacKey, string $camoUrl, string $imageUrl): string {
// Generate HMAC-SHA1
$hmac = hash_hmac('sha1', $imageUrl, $hmacKey, true);
// Base64 encode without padding (camo style)
$b64Hmac = rtrim(strtr(base64_encode($hmac), '+/', '-_'), '=');
$b64Url = rtrim(strtr(base64_encode($imageUrl), '+/', '-_'), '=');
return rtrim($camoUrl, '/') . '/' . $b64Hmac . '/' . $b64Url;
} hmacKey being a shared secret |
Mind, the Apache config in the README contains this:
Which is to say, any proxy is only as open as you want.
From a maintenance perspective that sounds a bit backwards to me, but perhaps from a UI perspective it could become confusing. In any event, that particular logic is basically the only logic likely to change anytime soon (unless someone wants to add support for some different format like Camo). |
This saves me from running a public proxy to any arbitrary URL, and lets me share infrastructure (with my forgejo instance, for example)