0
I’m using Hangfire to manage background tasks, it works normally when I’m on localhost, but in the production environment I’m not being able to set up the authentication needed to open Dashboard
I tried it this way, but I didn’t get good results
Classe Startup
//Politica de autenticação das controllers
services.AddMvc(options =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
options.Filters.Add(new AuthorizeFilter(policy));
})
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
.AddJsonOptions(opt => opt.SerializerSettings.ReferenceLoopHandling =
Newtonsoft.Json.ReferenceLoopHandling.Ignore);
Classe AuthorizationFilterHangfire que eu criei
public class AuthorizationFilterHangfire : IDashboardAuthorizationFilter
{
public bool Authorize([NotNull]DashboardContext context)
{
var httpContext = context.GetHttpContext();
return httpContext.User.Identity.IsAuthenticated;
}
}
}
I am using Identity for authentication with the concepts of Claims. But Identity is always false, someone would know how to solve it?
How are you receiving the information from the logged in user? Cookie or header? You can share the method
Configure
startup-class?– Lutti Coelho
I’ve got it, thank you!
– iago soares
Great. How do you feel about answering your question with the solution you found? This will help other people who might have the same problem.
– Lutti Coelho
Direct url blocked on the server, with VPN-only access ;)
– iago soares