Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elmah.MVC 2.0.1 - securing the elmah logs

Setup:

For an ASP.NET MVC 4 app I am using Elmah.MVC 2.0.1 to log errors.

I installed Elmah.MVC using NuGet. It works fine.

Problem:

The Elmah.MVC package installs no controller or area, so I can see no obvious way to apply security via Authorize attributes, as is recommended for ASP.NET MVC.

Question:

I only want users in the Admin role to be able to view the Elmah page.

How do I do this?

like image 846
awrigley Avatar asked Oct 26 '12 15:10

awrigley


People also ask

Where are Elmah logs stored?

You can view the logging information in folder App_Data/Sitefinity/Logs. For more information about the Enterprise Library, see The Logging Application Block on the MSDN. ELMAH logs the following: ErrorLog.

How do I check Elmah logs?

Build the application, run it in the browser, and navigate to http://www.yoursite.com/elmah.axd. You are prompted to log in before you see the content. After a successful authentication, you see a web page to remotely view the entire log of recorded exceptions.


1 Answers

Ouch!

Just found the answer;

Elmah MVC 2.0.1 NuGet package adds the following into <appSettings> (in web.config):

<add key="elmah.mvc.requiresAuthentication" value="false" />
<add key="elmah.mvc.allowedRoles" value="*" />

To achieve what I want simply:

<add key="elmah.mvc.requiresAuthentication" value="true" />
<add key="elmah.mvc.allowedRoles" value="Admin" />
like image 197
awrigley Avatar answered Sep 19 '22 22:09

awrigley