Discourse plugin that would prevent non-authenticated users from accessing uploaded images.
- Add these lines to your container's
app.yml
underenv
. Replacerandom-string
with your own.
IGUARD_COOKIE: random-string
-
Create
public-images
folder under container's shared directory (default/var/discourse/shared/standalone
) -
Add these lines to your container's
app.yml
undervolumes
. Replacepath-to-public-images
with an absolute path topublic-images
folder (default/var/discourse/shared/standalone/public-images
)
- volume:
host: path-to-public-images
guest: /var/www/discourse/public/public-images
- Add these lines to your container's
app.yml
underhooks
- git clone https://github.com/muhlisbc/discourse-images-guardian.git
- erb /var/www/discourse/plugins/discourse-images-guardian/nginx.sample.conf.erb > /var/www/discourse/config/nginx.sample.conf
- Rebuild your container
./launcher rebuild app
- Add the forum domain to
disabled image download domains
setting in the admin interface (underSettings
>Files
)
You can disable/enable this plugin on-the-fly in the admin interface (enabled by default).
When this plugin is enabled, all uploaded images (user's custom avatar, user's card background, user's profile background, image embedded in a post) will return 404
for non logged-in users.
If you want an image to be publicly accessible in a post, you have to upload it to public-images
folder (default /var/discourse/shared/standalone/public-images
) and then enter the url (http(s)://yourdomain.com/public-images/${image-filename}
) while creating a post.
- Non logged-in user
- Can see user default avatar
- Can't see attached image
- HTTP response 404
- Logged-in user
- Can see attached image
- HTTP response 200
- Non logged-in user
- Can't see user's uploaded avatar
- Can't see user's card background
- HTTP response 404
- Logged-in user
- Can see user's uploaded avatar
- Can see user's card background
- HTTP response 200
- Non logged-in user
- Can't see user's profile background
- HTTP response 404
- Logged-in user
- Can see user's profile background
- HTTP response 200
Non logged-in user
- Can see attached image uploaded to
public-images
folder - HTTP response 200
Non logged-in user
- Can't see attached image
- HTTP response 404
GPLv2