Secured vs. Non-secured libraries

Media libraries on your site can be secured or non-secured. To ensure the required functionality, several settings need to be done as described below.

 

 

 

Please note!

 

By default, files in media libraries are not secured and can be accessed directly by anybody who knows the exact link to the file. If you want to prevent this behavior, please set up your media library as a secured one.

 

 

Secured libraries

 

Secured media libraries allow viewing of their content only to members of authorized roles or only to authenticated users, based on the settings made on the library's Security tab. Secured libraries are also slower than the non-secured ones, as permission checking involves some processing overhead.

 

To set up a media library to behave as a secured library, you have to take the following steps:

 

1. IIS setup

 

You have to set up your IIS so that files can not be downloaded directly from the library by typing the link to the file like <site url>/media/file.jpg into the browser.

 

a) Locate the media library folder in IIS tree, right-click it and choose Properties.

 

clip0299

 

b) Switch to the Directory security tab and click Edit.

 

clip0300

 

c) Uncheck the Anonymous access and Integrated windows authentication check-boxes and click OK.

 

clip0302

 

 

2) Media library security settings

 

You have to assign the See media library content permission to the appropriate roles or all authenticated users on the media library's Security tab.

 

clip0293

 

You also have to make sure that the Check files permissions option is enabled in Site Manager -> Settings -> Media libraries. With this option disabled, permission checks would not be performed.

 

3) Media gallery web part settings

 

a) You need to enable the Use secure links web part property.

 

b) When writing your transformations for the Media gallery web part, you should stick to the following rules:

 

File previews and file details should be displayed using the following control:

 

<cc1:MediaFilePreview ID="filePreview" runat="server" maxsidesize="117" />

 

Download links should be obtained using the following method:

 

<%# MediaLibraryFunctions.GetMediaFileUrl(Eval("FileLibraryID") ,Eval("FilePath"), Eval("FileGUID"), Eval("FileName"), GetDataControlValue<bool>("UseSecureLinks")) %>

 

You can see an example of a real-world use of this web part, including the defined the transformations, on the sample Community Starter site, in the Media section.

 

 

Non-secured libraries

 

Content of non-secured media libraries is accessible to all site users or visitors. These libraries are also faster than the secured ones, as no permissions need to be checked.

 

1. IIS setup

 

You have to set up your IIS so that files in the library can be accessed directly by anonymous users.

 

a) Locate the media library folder in IIS tree, right-click it and choose Properties.

 

clip0299

 

b) Switch to the Directory security tab and click Edit.

 

clip0300

 

c) Make sure that the Anonymous access check-box is enabled and click OK.

 

clip0303

 

 

2) Media library security settings

 

You have to assign the See media library content permission to All users on the media library's Security tab.

 

clip0294

 

Alternatively, if all media libraries on the site are non-secured, you can disable the Check files permissions option in Site Manager -> Settings -> Media libraries. This disables all permission checks for all media libraries on on the site, which enables all users to see the libraries' content.

 

clip0295

 

3) Media gallery web part settings

 

a) The Use secured links web part property should be disabled for the file requesting to be faster.

 

b) When writing your transformations for the Media gallery web part, you should stick to the following rules:

 

Image previews and image details should be obtained using the following method because they need to be resized:

 

<cc1:MediaFilePreview ID="filePreview" runat="server" maxsidesize="117" />

 

Other file types' previews and details should can be obtained using direct links. Download links can be obtained directly too.