title: Dashboard Authorization (self-hosted as a Windows service)
body: <p>I have a Hangfire instance hosted in a windows service using Topshelf:</p>
  
  <pre><code>static void Main()
  {
      HostFactory.Run(x =&gt;
      {
          x.Service&lt;Application&gt;(s =&gt;
          {
              s.ConstructUsing(name =&gt; new Application());
              s.WhenStarted(tc =&gt; tc.Start());
              s.WhenStopped(tc =&gt; tc.Stop());
          });
          x.RunAsLocalSystem();
  
          x.SetDescription("Hangfire Windows Service Sample");
          x.SetDisplayName("Hangfire Windows Service Sample");
          x.SetServiceName("hangfire-sample");
      });
  }
  
  private class Application
  {
      private IDisposable host;
  
      public void Start()
      {
          host = WebApp.Start&lt;Startup&gt;("http://localhost:12345");
  
          Console.WriteLine();
          Console.WriteLine("Hangfire Server started.");
          Console.WriteLine("Dashboard is available at {0}/hangfire", configSettings.Jobs.EndPoint);
          Console.WriteLine();
      }
  
      public void Stop()
      {
          host.Dispose();
      }
  }
  </code></pre>
  
  <p>My StartUp class is pretty basic:</p>
  
  <pre><code>public void Configuration(IAppBuilder app)
  {
      GlobalConfiguration.Configuration.UseSqlServerStorage(
          "DefaultConnection",
          new SqlServerStorageOptions {QueuePollInterval = TimeSpan.FromMinutes(1)});    
  
      app.UseHangfireDashboard("/hangfire", new DashboardOptions
      {
          AuthorizationFilters = new[] { new AuthorizationFilter() }
      });
  
      app.UseHangfireServer();
  }
  </code></pre>
  
  <p>I'm trying to use a custom authorization filter:</p>
  
  <pre><code>public class AuthorizationFilter : IAuthorizationFilter
  {
      public bool Authorize(IDictionary&lt;string, object&gt; owinEnvironment)
      {
          var context = new OwinContext(owinEnvironment);
  
          return context.Authentication.User.Identity.IsAuthenticated;
      }
  }
  </code></pre>
  
  <p>I was hoping to use <code>context.Authentication.User</code> to authenticate but it always returns null. </p>
  
  <p>Is there any way to make this work for a self-hosted hangfire service?</p>