Demo implementation of API key-based authentication in the JsonApiDotNetCore framework.
- Restore NuGet packages with
dotnet restore
(or let your IDE handle this for you). - Spin up a postgres docker container.
- Replace the connection string placeholders with the right values; for the username, database name and password.
- Run the
JsonApiDotNetCore.Demo.Auth.Api
project withdotnet run
(or run it through your IDE). - Send an HTTP request through your favorite browser or API client software to
https://localhost:5001/api/cars/{id}
Enable authentication by supplying an API key with the request.
https://localhost:5001/api/cars/{id}?apiKey={VALUE}
Authorization: 'Bearer {VALUE}'
HpjtmVYExiltL1lmtGbvqUr0mUQ1Ngke
pTXohlfeqMCWxyTqtfNqb6QeeAWgdEpV
See KeyRepository
for the implementation of this key store.