Copied to clipboard

Flag this post as spam?

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


  • Jessica-Kroner 9 posts 77 karma points
    May 25, 2023 @ 06:54
    Jessica-Kroner
    0

    pdf for logged in users only

    The PDF that I uploaded should only be available for logged-in users. However, I don't know how to implement this. Does somebody has any idea?

  • Marc Goodson 2148 posts 14353 karma points MVP 8x c-trib
    May 25, 2023 @ 07:49
    Marc Goodson
    0

    Hi Jessica

    The quick answer is there is a third party plugin that would do this called Media Protect

    https://our.umbraco.com/packages/website-utilities/media-protect/

    This allows you to protect media and folders by the same membership groups that are built into Umbraco's Members system, so if yo have a Member Group for 'Logged in' you can protect a particular PDF files to be only downloaded by people in that group.

    It is a paid for package, and in order for it to work, it does have to look at all requests coming in the pattern of /media/* and looking to see if it's protected by member groups, so there is a little overhead (but usually that's not a deal breaker!)

    If you want to write code to handle this yourself, then you could create your own IhttpModule and look for the requests yourself - which might be preferable if you only want to protect this one PDF, etc and don't want to introduce the package.

    There is an example here of something similar at the old place I worked: https://github.com/Moriyama-Umbraco/Moriyama-Authorised-Media/blob/master/src/Moriyama.AuthorisedMedia/Application/AuthorisedMediaHttpModule.cs Where we had the concept of protecting anything that was 'in' a special Media Folder Type, that could be a source of inspiration.

    regards

    Marc

  • Jessica-Kroner 9 posts 77 karma points
    May 25, 2023 @ 10:47
    Jessica-Kroner
    0

    Hello Marc,

    it's about several pdf.

    regards

    Jessica

  • Marc Goodson 2148 posts 14353 karma points MVP 8x c-trib
    May 25, 2023 @ 12:08
    Marc Goodson
    0

    Hi Jessica

    More information about Media Protect here: https://soetemansoftware.nl/media-protect

    or you can roll your own IHttpModule to suit your needs, in the example one I linked to we, just went with a convention, eg Umbraco allows to create different MediaTypes other than the default so we created a ProtectedFolder MediaType, and then any requests from images that were in that folder needed to be logged in... but there are a number of ways of doing it.

    or MediaProtect might be just what you need.

    regards

    marc

Please Sign in or register to post replies

Write your reply to:

Draft