Dashboard Auth for VB.Net

authorization
dashboard
Tags: #<Tag:0x00007f28214851e8> #<Tag:0x00007f2821485080>

#1

I’m trying to get basic dashboard authorization working in my MVC VB.Net app. I just want to be able to add one user “admin” and a basic password “123”. I’ve tried various methods from here and nothing has worked so far (using 1.6.6):

Dim options As New DashboardOptions
options.Authorization = New IDashboardAuthorizationFilter() {
New AuthorizationFilter With {.Users = “some_user”, .Roles = “some_role”}
}

app.UseHangfireDashboard("/hangfire", options)
app.UseHangfireServer()

Whenever I try to run this I get:

Unable to cast object of type ‘Hangfire.Dashboard.AuthorizationFilter’ to type ‘Hangfire.Dashboard.IDashboardAuthorizationFilter’.


#2

+1 same issue here as far.


#3

This is probably really bad form - but this is how I got it to work in VB.net. I ended up breaking apart the sections.

Dim user1 = New BasicAuthAuthorizationUser With {.Login = "admin", .PasswordClear = "mysupersecretpassword"}
Dim userList As New List(Of BasicAuthAuthorizationUser)
userList.Add(user1)

filterOptions.Users = userList

Dim filter = New BasicAuthAuthorizationFilter(filterOptions)
Dim filters As New List(Of BasicAuthAuthorizationFilter)
filters.Add(filter)

Dim options = New DashboardOptions() With {.AuthorizationFilters = filters.AsEnumerable}

app.UseHangfireDashboard("/hangfire", options)
GlobalConfiguration.Configuration.UseConsole()

#4

What will be type of filterOptions ?


#5

Dim filterOptions = New BasicAuthAuthorizationFilterOptions