I want to protect the /metrics endpoint with my own auth attribute.
public class MyAuthAttribute : AuthorizeAttribute
{
public override void OnAuthorization(HttpActionContext actionContext)
{
... // stuff here
}
}
However, I'm not sure how to cleanly apply this to PrometheusMetricsController. The cleanest I could come up with was inheriting it & applying it to the child:
[MyAuth]
public class TestController : PrometheusMetricsController
{
}
Then replacing the WebApiConfig.cs line
PrometheusConfig.UseMetricsServer(config, "metrics");
with
config.Routes.MapHttpRoute("Prometheus", "metrics", new { controller = "Test" });
I want to protect the
/metrics
endpoint with my own auth attribute.However, I'm not sure how to cleanly apply this to
PrometheusMetricsController
. The cleanest I could come up with was inheriting it & applying it to the child:Then replacing the
WebApiConfig.cs
linePrometheusConfig.UseMetricsServer(config, "metrics");
withconfig.Routes.MapHttpRoute("Prometheus", "metrics", new { controller = "Test" });
Do you have any better ideas?
Thank you.