Copied to clipboard

Flag this post as spam?

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


  • David Conlisk 432 posts 1008 karma points
    Jun 07, 2018 @ 08:04
    David Conlisk
    0

    Checking media access in a http module

    Hi all,

    I've been tasked with updating an existing site which has protected media on it. When a user requests a protected item, the permissions are checked and then the file is served (if the user has access) like so:

    var fileBytes = System.IO.File.ReadAllBytes(filepath);
    return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, downloadItem.FileName);
    

    Otherwise the user is bounced to a login page.

    But now we've moved the site to use blob storage for media this no longer works.

    The solution that springs to mind is to use a http module to handle the permissions checking, and then let Umbraco serve the file when the logging is complete. However, I don't have context in the http module and I'm struggling to use the MediaProtect library HasAccess method.

    Is it possible to use MediaProtect in this way, or is there a better solution?

    Cheers,

    David

  • Richard Soeteman 4054 posts 12927 karma points MVP 2x
    Jun 07, 2018 @ 09:08
    Richard Soeteman
    1

    Hi David,

    Not sure I understand but with V2 of Media protect BLOB is already supported see chapter 7 of the manual https://soetemansoftware.nl/media-protect/downloads

    Is this what you are after?

    Best,

    Richard

  • David Conlisk 432 posts 1008 karma points
    Jun 07, 2018 @ 10:23
    David Conlisk
    100

    Hi Richard,

    Yeah I could have kept that question a bit shorter, the blob storage is a bit of a red herring.

    I was struggling to use the MediaProtect library functions in a HTTP module. The reason is I was using the BeginRequest method, which is too early in the pipeline. Using the PostAuthenticateRequest method solved my problem.

    Now method calls like MediaProtect.Library.Library.GetCurrentUserName() work correctly and I can try and deal with the other issues ;)

    Thanks,

    David

  • 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