It shows you how to create a simple handler for serving the media items.
That handler first checks with an api call to see if the media item is protected or not. Does it have id of the protected media folder in its path?
If it does, then check if the current user is allowed to see it.
thx a lot for your blog post. I'm using it in an Umbraco v8 project and it works like a charm. The only thing I didn't find a solution for is:
When I want to access a media file I check in the MediaHandler if the request comes from a logged in member and that check works flawlessly. But now I also want to allow backoffice users (mind you - NOT members!) to access those files. Do you have any idea how I would check, if the request comes from a logged in backoffice user in the MediaHandler?
thanks for the advice! I tried that, but ran into a problem there. The "GetUmbracoAuthTicket()" method doesn't seem to be available in v8. Do I need to reference an assembly to get access to that method? Or is it simply not available in v8?
Really nice article as i wanted to protect media folder and it works fine but i have found an issue when image processor module get in first and serves the image.
example.com/media/1001/368639.jpg - is protected
example.com/media/1001/368639.jpg?anchor=center&mode=crop&width=1600&height=500&rnd=131765692800000000 - not protected.
probably not working because the method only accepts the media url parameter. When you have more parameters, stop working (anchor,mode,width, height and rnd, etc).
Protected Media Folder
Hello Community
What is the easiest way to create protected media folder?
Child media items should be protected from not authenticated members.
Thanks,
Alex
https://our.umbraco.org/projects/website-utilities/media-protect/
I wrote a simple blog post to show you how to do it easily yourself.
http://www.codeshare.co.uk/blog/how-to-protect-media-items-in-umbraco/
It shows you how to create a simple handler for serving the media items. That handler first checks with an api call to see if the media item is protected or not. Does it have id of the protected media folder in its path?
If it does, then check if the current user is allowed to see it.
Hope it helps.
Hi Paul
Thank you very much, really nice article, can you provide "ApiHelper" class also?
It's in "CodeShare.Library.Helpers" I think.
Thanks,
Alex
Hi Paul,
thx a lot for your blog post. I'm using it in an Umbraco v8 project and it works like a charm. The only thing I didn't find a solution for is:
When I want to access a media file I check in the MediaHandler if the request comes from a logged in member and that check works flawlessly. But now I also want to allow backoffice users (mind you - NOT members!) to access those files. Do you have any idea how I would check, if the request comes from a logged in backoffice user in the MediaHandler?
Cheers, David
Hi David
This post will help you with that for v7, maybe you can get it working and share it in here after?
https://codeshare.co.uk/blog/how-to-get-the-current-logged-in-umbraco-user-and-restrict-front-end-content/
Cheers
Paul
Hey,
thanks for the advice! I tried that, but ran into a problem there. The "GetUmbracoAuthTicket()" method doesn't seem to be available in v8. Do I need to reference an assembly to get access to that method? Or is it simply not available in v8?
David
Hi Alex Thanks I'm glad you like it and that someone might use it lol.
I put a link to the ApiHelper class article in the post.
Here it is again.
http://www.codeshare.co.uk/blog/simple-web-api-helper-for-umbraco-and-mvc/
Cheers
Paul
Hi Paul
Really nice article as i wanted to protect media folder and it works fine but i have found an issue when image processor module get in first and serves the image.
example.com/media/1001/368639.jpg - is protected
example.com/media/1001/368639.jpg?anchor=center&mode=crop&width=1600&height=500&rnd=131765692800000000 - not protected.
Any ideal ?
Thanks Bhavesh
Same here, have you found a solution?
Edit: I wrote a little article to address the issue => https://giacomodeliberali.com/blog/umbraco-protect-media-items
Hi Giacomo
Do you need a protected media folder?
Protected media items - https://codeshare.co.uk/blog/how-to-protect-media-items-in-umbraco/
Alex
there are also these two options
https://martincarlsen.com/securing-media-files-in-umbraco/
https://www.steadygo.digital/blog/securing-media-files-umbraco-7-5-2/
probably not working because the method only accepts the media url parameter. When you have more parameters, stop working (anchor,mode,width, height and rnd, etc).
you doing it this way:
https://martincarlsen.com/securing-media-files-in-umbraco/
You can work around creating actions with these parameters anchor,mode,width, height and rnd
I could easily applied Martin Carlsen's method. Thanks :)
merhabalar Osman Bey Türkiye'de mi umbraco development yapmaktasınız?
Evet. Ankara'dayım.
is working on a reply...