Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Armitage 414 posts 1655 karma points
    Jan 29, 2020 @ 00:51
    David Armitage
    0

    Umbraco 7 | Authorization on Media Items | Restrict specific media to members only

    Hi Guys,

    I have a requirement to restrict specific media items from been opened by non members.

    I have already made a start by.

    1. Creating a restricted folder within the media which I intend to pop all the restricted media.

    2. I I've created a dynamic robots.txt to disallow search engines from indexing these types of documents.

    I now need to figure out how to restrict access to these files unless a member is logged in. I'm guessing I need to somehow hijack the route to these files and add some authorisation checks somewhere in between. I am thinking it might actually be better to add a custom property on the media item to enable and disable restricted access.

    Has anyone done anything like this before with Umbraco 7 and might have some code to share? I'm looking for any tips on the who route hijack and authorisation part.

    Thanks in advanced.

    David

  • Dennis Adolfi 1072 posts 6378 karma points MVP 2x c-trib
    Jan 29, 2020 @ 05:55
    Dennis Adolfi
    100

    Hi David. I’ve done something like this before, using a custom HttpHandler that intercepted the media file request and validate. In my case I didn’t validate on a member group but instead I needed to validate against an external auth provider, but I guess the principal is the same.

    Have a look at this blog post, it’s probably at least half of what you are looking for: https://codeshare.co.uk/blog/how-to-protect-media-items-in-umbraco/

    Best of luck! Cheers

  • David Armitage 414 posts 1655 karma points
    Jan 29, 2020 @ 06:02
    David Armitage
    1

    Hi Dennis,

    Just want I am looking for. Thanks

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies