ApiKeyFilter 1.0.3

Install-Package ApiKeyFilter -Version 1.0.3
dotnet add package ApiKeyFilter --version 1.0.3
<PackageReference Include="ApiKeyFilter" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ApiKeyFilter --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ApiKeyFilter, 1.0.3"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install ApiKeyFilter as a Cake Addin
#addin nuget:?package=ApiKeyFilter&version=1.0.3

// Install ApiKeyFilter as a Cake Tool
#tool nuget:?package=ApiKeyFilter&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Changes in 1.0.3

  • apiKeys.sqlite is now created in a ./database folder to enable docker integration

ApiKey Filter

The package adds an ApiKey filter to your Asp.Net Core Application.

The API Keys are organized in an SQLite database. The Roles can be defined as string.

Installation

Make sure that your ConfigureServices contains the following lines. You have to specify a master key

public void ConfigureServices(IServiceCollection services) {
    services.AddControllers(
        e => e.Filters.Add<ApiFilter>()
    );
    services.AddApiKeyController("00000000-0000-0000-0000-000000000000");
}

Usage

To apply a filter to a controller just add the filter attribute to your controller

    [ApiKeyFilter.LevelFilter("weather")]
    public class WeatherForecastController : ControllerBase {

Access control

To add a new API key call the url

POST http://{baseUrlOfHostProject}/api/accessControl/ApiKey

{
	"description": "New Api Key"
}

as a response you get the new API Key

{
  "description": "New Api Key",
  "roles": null,
  "id": "a86b941b-0000-0000-0000-d1c7f68b5022",
  "created": "2020-10-09T05:24:54.1935783+00:00",
  "deleted": null
}

To add an API key to a specific role call

POST http://{baseUrlOfHostProject}/api/accessControl/ApiKey/a86b941b-0000-0000-0000-d1c7f68b5022/role/<NameOfRole>

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 171 10/12/2020
1.0.2 142 10/9/2020