Scala Rise - A Reliable Way To Protect Files From Hotlinking

I am trying to implement a way to stop hotlinking and / or unauthorized access to resources in my application.

The method I'm trying to add is what I used to use in PHP applications before. Basically, a session is established the first time a page is called. Images are added to the page using an image tag indicating the session value as a parameter:

<img src="/files/image/image1.jpg?session=12345" /> 

When requesting an image, the script checks to see if the session is established and the provided value matches. If the condition is not met, the service page returns null. Right at the end of the code, I disconnected the session, so further requests from outside the page area return null.

What would be the best implementation of this method within the elevator?

Thanks in advance for any help, really appreciate :)

+4
source share
1 answer

For this purpose you can use SessionVar . In SessionVar youd store a Map[SessionImageId, RealImageId] and when you initialize the session (that is, When the page loads) you produce a random SessionImageId that you would map to the identifier of the real image. In your html, you set only the hidden SessionImageId so that no one can trace the image from the identifier. When an image is requested, you simply look at the real identifier in Map .

Information: Elevator Learning , Raise a Wiki

Of course, if identifier shading is not important, you can simply use SessionVar[Boolean] .

0
source

Source: https://habr.com/ru/post/1435804/


All Articles