Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Authorization Delegate that can be used instead of the Authorization Filter #2427

Open
Banner-Keith opened this issue Jul 23, 2024 · 0 comments

Comments

@Banner-Keith
Copy link

Banner-Keith commented Jul 23, 2024

While configuring hangfire dashboard I was thinking it would be nice to provide an authorization delegate that can be used instead of using the authorization filter. Under the hood it could still do the same thing, but the way the user wires it up would be simpler.

app.UseHangfireDashboard(options: new DashboardOptions
{
	// Authorization = [new HangfireDashboardAuthorizationFilter()],
	AuthorizationDelegate = context =>
	{
		HttpContext httpContext = context.GetHttpContext();

		return httpContext.User.IsInRole("Developer");
	}
});

Under the hood the authorization delegate could be provided to a default internal AuthorizationFilter. And the existing Authorization property could take priority if someone provides both. Or as mentioned in the documentation "The second step is to pass it to the UseHangfireDashboard method. You can pass multiple filters, and the access will be granted only if all of them return true." we could make sure that all (not including the default local only filter) return true.

I would be willing to open a PR with the change if you are open to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant