Goal:
- When user enters the web page display image created specifically for that user
- Make that image "secure": Prevent user from copying image url and sending it to another user
- print screen is not in consideration because it was thoroughly discussed here on Stop User from using “Print Scrn” / “Printscreen” key of the Keyboard for any Web Page
- It is also possible to check credentials if we redirect user to download file as discussed here on How to restrict user access the file on the HTTP Server?. But I want to display image as part of my web page.
- challenge: make it possible for unlogged users
I know that there always will be the way to get info from browser if we have displayed it, but I am looking for the most convenient way to prevent that.
Solutions I already have in mind:
- If we check Instagram we will see that it displays image and covers it with transparent
div
. It will prevent user from right clicking on image. But you can access image usingdev tools
(network tab). - I don't remember where I saw that method but: you can
slice
your image on backend, send two pieces on front end and display twodiv
s close to each other in order to display whole image. User still have access to the image usingdev tools
(network tab) but it is splitted image. - Encode image as
base64
and send string instead of file. User will not be able to get image usingdev tools
(network tab, only if he specifically looking for string but string can be encoded on backend and decoded on frontend). But still can be copied usingdev tools
(elements tab)
More exotic way:
- Encode image as
base64
and send string instead of file. UsingJS
check if userhover
sbody
element, if yes paste image (usingbackground-image
css attribute). In that case user won't be able to access image indevtools
right away. He could intercept that string only if he addEvent listener
breakpoint onhover
. Which is harder.