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

Basic Authentication for Standalone HTTP Handler #261

Closed
ethanshea-ms opened this issue Oct 23, 2020 · 2 comments
Closed

Basic Authentication for Standalone HTTP Handler #261

ethanshea-ms opened this issue Oct 23, 2020 · 2 comments
Milestone

Comments

@ethanshea-ms
Copy link

From #92 I see it is possible to use Basic Auth for the ASP.NET HTTP Handler. Is this also possible for the standalone HTTP Handler?

Example:

var metricServer = new MetricServer(port: 1234);
// How do I apply basic authentication here?
metricServer.Start();
@sandersaares
Copy link
Member

This is not currently supported, though could likely be added.

The first design that comes to mind is a request filtering callback such as:

metricServer.RequestFilter = request => IsAuthorized(request.Headers.Authorization);

Would this satisfy your use case? What is the authorization logic you would like to apply? That is, where do the credentials come from and how would they be validated?

I would also be interested to hear more about your usage of MetricServer. It is the oldest mechanism for publishing metrics in the library and over the years is moving ever more into the "legacy" category, so it would be good to better understand the needs of people who still want to use it, to keep it getting the attention it needs. What makes you prefer this mechanism over the others available?

@ethanshea-ms
Copy link
Author

Yes, that sort of a design would work. The design you proposed is reminiscent of SslOptions.RemoteCertificateValidationCallback.

My use case involves shipping code to be run in Azure IoT Edge. Direct method calls are used for interacting with IoT Edge modules, so there is no need for ASP.NET/Kestrel. We are trying to avoid taking a dependency on it if possible.

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

No branches or pull requests

2 participants