Support proxying chat images via camo
Camo: https://github.com/atmos/camo. This has a couple advantages over just allowing images to be dumped as-is: - Prevents mixed-content warnings by allowing the server to proxy HTTP images to an HTTPS camo instance - Protects users' privacy by not exposing their browser directly to the image host - Allows the camo proxy to intercept and reject bad image sources (URLs that are not actually images, gigapixel-sized images likely to DoS users' browsers, etc.) Whitelisting specific domains is supported for cases where the source is known to be trustworthy.
This commit is contained in:
parent
f968521936
commit
22a9acfc90
8 changed files with 194 additions and 4 deletions
26
src/configuration/camoconfig.js
Normal file
26
src/configuration/camoconfig.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
class CamoConfig {
|
||||
constructor(config = { camo: { enabled: false } }) {
|
||||
this.config = config.camo;
|
||||
if (this.config.server) {
|
||||
this.config.server = this.config.server.replace(/\/+$/, '');
|
||||
}
|
||||
}
|
||||
|
||||
isEnabled() {
|
||||
return this.config.enabled;
|
||||
}
|
||||
|
||||
getKey() {
|
||||
return this.config.key;
|
||||
}
|
||||
|
||||
getServer() {
|
||||
return this.config.server;
|
||||
}
|
||||
|
||||
getWhitelistedDomains() {
|
||||
return this.config['whitelisted-domains'] || [];
|
||||
}
|
||||
}
|
||||
|
||||
export { CamoConfig };
|
||||
Loading…
Add table
Add a link
Reference in a new issue