https://github.com/malantin/aspnetcoreapikeymiddleware
Just a simple middleware for your ASP.Net Core application to check for an API Key in incoming requests.
https://github.com/malantin/aspnetcoreapikeymiddleware
Last synced: 2 months ago
JSON representation
Just a simple middleware for your ASP.Net Core application to check for an API Key in incoming requests.
- Host: GitHub
- URL: https://github.com/malantin/aspnetcoreapikeymiddleware
- Owner: malantin
- License: mit
- Created: 2018-05-18T09:56:48.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-18T10:56:44.000Z (about 7 years ago)
- Last Synced: 2025-01-21T06:29:23.135Z (4 months ago)
- Language: C#
- Size: 58.6 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# A simple middleware to check for API Keys in your ASP.Net Core APIs
This is a simple ASP.Net middleware you can use to check for API keys in each request to you services. It is intended to be used in a microservice architecture where each (group of) service(s) is a seperate project.
Just configure the middleware in your Startup.cs:
```csharp
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}// Check for a valid API key using the API Key Middleware
app.UseAPIKey();app.UseMvc();
}
}
```Try the demo project. When authorized you will get a correct response:

Otherwise you will get a status code 400 or 401:

Just modify the project for you convenience.
**The API key should not be stored in your code for production applications!**