https://github.com/anders130/apilocksmith
Easy integration of ApiKey-based authentication for minimal APIs in ASP.NET Core.
https://github.com/anders130/apilocksmith
Last synced: about 1 year ago
JSON representation
Easy integration of ApiKey-based authentication for minimal APIs in ASP.NET Core.
- Host: GitHub
- URL: https://github.com/anders130/apilocksmith
- Owner: anders130
- License: mit
- Created: 2023-12-05T20:45:20.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-26T15:25:29.000Z (over 2 years ago)
- Last Synced: 2025-02-01T16:26:42.347Z (over 1 year ago)
- Language: C#
- Size: 19.5 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ApiLocksmith
ApiLocksmith is a collection of C# libraries that simplify API development with ASP.NET Core by providing easy integration of ApiKey-based authentication and Swagger documentation.
## ApiLocksmith.Core
The `ApiLocksmith.Core` library allows you to add ApiKey-based authentication to your minimal APIs built with ASP.NET Core. It provides a flexible and easy-to-use solution for securing your APIs.
### Usage
To use `ApiLocksmith.Core`, follow these steps:
1. Install the NuGet package:
```bash
dotnet add package ApiLocksmith.Core
```
2. Configure the ApiKeyOptions inside the `appsettings.json`:
```json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ApiKeySettings": {
"ApiKey": "MySecretApiKey",
"ApiKeyHeaderName": "x-api-key",
"ApiKeySchemeName": "ApiKey"
}
}
```
3. Add this to your `Program.cs`:
```csharp
builder.Services.AddApiKeyAuthenticationScheme(builder.Configuration, "ApiKeySettings");
```
Refer to the [ApiLocksmith.Core documentation](./src/ApiLocksmith.Core/README.md) for detailed configuration options and usage examples.
## ApiLocksmith.Swagger.FastEndpoints
The `ApiLocksmith.Swagger.FastEndpoints` library extends `ApiLocksmith.Core` by providing Swagger documentation integration with the FastEndpoints library for your APIs secured with ApiKey-based authentication.
### Usage
To use `ApiLocksmith.Swagger.FastEndpoints`, follow these steps:
1. Install the NuGet package:
```bash
dotnet add package ApiLocksmith.Swagger.FastEndpoints
```
2. Add this to your `Program.cs`:
```csharp
builder.Services.AddSwaggerDocumentWithApiKeyAuth(builder.Configuration, "ApiKeySettings");
// ...
app.UseSwaggerGen();
```
Refer to the [ApiLocksmith.Swagger.FastEndpoints documentation](./src/ApiLocksmith.Swagger.FastEndpoints/README.md) for detailed configuration options and usage examples.
## Examples
Check out the [examples](./examples) folder for sample projects demonstrating the usage of ApiLocksmith libraries in different scenarios.
## License
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.