Api Key Authorization for Web API
Install-Package ApiKeyAuth
Statrup.cs
using ApiKeyAuth;
public void ConfigureServices(IServiceCollection services)
{
services.AddApiKeyAuth("ApiKeyPolicy", new[] { "secretkey" }, "API-KEY");
services.AddMvc()
.AddApplicationPart(typeof(ApiKeyAuth.ServicesConfiguration).Assembly);
}
Controller:
[HttpGet]
[Authorize(Policy = "ApiKeyPolicy")]
public ActionResult<IEnumerable<string>> Get()
{
return new string[] { "value1", "value2" };
}
There are many ways you can contribute to ApiKeyAuth. Like most open-source software projects, contributing code is just one of many outlets where you can help improve. Some of the things that you could help out with in ApiKeyAuth are:
- Documentation
- Bug reports
- Bug fixes
- Feature requests
- Feature implementations
- Test coverage
- Code quality
Copyright © 2020 Albert Farhat and contributors
ApiKeyAuth is licensed under MIT. Refer to LICENSE for more information.