Skip to content

Commit 3635a6a

Browse files
authored
Merge pull request #47 from mihirdilip/9.0.0
Net9.0 support added
2 parents 5bc5191 + 90b7814 commit 3635a6a

File tree

59 files changed

+1348
-715
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1348
-715
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Setup .NET Core SDK
3636
uses: actions/[email protected]
3737
with:
38-
dotnet-version: 8.x.x
38+
dotnet-version: 9.x.x
3939

4040
# Initializes the CodeQL tools for scanning.
4141
- name: Initialize CodeQL

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Mihir Dilip
3+
Copyright (c) 2025 Mihir Dilip
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Easy to use and very light weight Microsoft style API Key Authentication Impleme
77

88
## .NET (Core) Frameworks Supported
99
.NET Framework 4.6.1 and/or NetStandard 2.0 onwards
10-
Multi targeted: net8.0; net7.0; net6.0; net5.0; netcoreapp3.1; netcoreapp3.0; netstandard2.0; net461
10+
Multi targeted: net9.0; net8.0; net7.0; net6.0; net5.0; netcoreapp3.1; netcoreapp3.0; netstandard2.0; net461
1111

1212
<br/>
1313

@@ -384,6 +384,7 @@ public void ConfigureServices(IServiceCollection services)
384384
## Release Notes
385385
| Version | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Notes |
386386
|---------|-------|
387+
|9.0.0 | <ul><li>net9.0 support added</li><li>Sample project for net9.0 added</li><li>Readme updated</li><li>Nullable reference types enabled</li><li>Language version set to latest</li><li>Implicit usings enabled</li><li>AOT support added</li></ul> |
387388
|8.0.1 | <ul><li>Added support to have ApiKey in request route identified by route pattern key from netcoreapp3.0 onwards [#41](https://github.com/mihirdilip/aspnetcore-authentication-apikey/issues/41)</li><li>Readme updated</li></ul> |
388389
|8.0.0 | <ul><li>net8.0 support added</li><li>Sample project for net8.0 added</li><li>ApiKeySamplesClient.http file added for testing sample projects</li><li>Readme updated</li></ul> |
389390
|7.0.0 | <ul><li>net7.0 support added</li><li>Information log on handler is changed to Debug log when API Key is not found on the request</li><li>Added package validations</li><li>Sample project for net7.0 added</li><li>Readme updated</li><li>Readme added to package</li></ul> |

samples/SampleWebApi.Shared/Services/ApiKeyProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public ApiKeyProvider(ILogger<IApiKeyProvider> logger, IApiKeyRepository apiKeyR
1616
_apiKeyRepository = apiKeyRepository;
1717
}
1818

19-
public async Task<IApiKey> ProvideAsync(string key)
19+
public async Task<IApiKey?> ProvideAsync(string key)
2020
{
2121
try
2222
{

samples/SampleWebApi_2_0/SampleWebApi_2_0.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<TargetFramework>netcoreapp2.0</TargetFramework>
55
<CheckEolTargetFramework>false</CheckEolTargetFramework>
66
<NuGetAudit>false</NuGetAudit>
7+
<LangVersion>latest</LangVersion>
8+
<Nullable>enable</Nullable>
79
</PropertyGroup>
810

911
<ItemGroup>

samples/SampleWebApi_2_2/SampleWebApi_2_2.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
66
<CheckEolTargetFramework>false</CheckEolTargetFramework>
77
<NuGetAudit>false</NuGetAudit>
8+
<LangVersion>latest</LangVersion>
9+
<Nullable>enable</Nullable>
810
</PropertyGroup>
911

1012
<ItemGroup>

samples/SampleWebApi_3_1/SampleWebApi_3_1.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<Nullable>enable</Nullable>
56
<CheckEolTargetFramework>false</CheckEolTargetFramework>
67
</PropertyGroup>
78

samples/SampleWebApi_5_0/SampleWebApi_5_0.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
5+
<Nullable>enable</Nullable>
56
<CheckEolTargetFramework>false</CheckEolTargetFramework>
67
</PropertyGroup>
78

samples/SampleWebApi_7_0/SampleWebApi_7_0.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFramework>net7.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
7+
<CheckEolTargetFramework>false</CheckEolTargetFramework>
78
</PropertyGroup>
89

910
<Import Project="..\SampleWebApi.Shared\SampleWebApi.Shared.projitems" Label="Shared" />
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Mvc;
3+
using System.Text;
4+
5+
namespace SampleWebApi_9_0.Controllers
6+
{
7+
[Route("api/[controller]")]
8+
[ApiController]
9+
public class ValuesController : ControllerBase
10+
{
11+
// GET api/values
12+
[AllowAnonymous]
13+
[HttpGet]
14+
public ActionResult<IEnumerable<string>> Get()
15+
{
16+
return new string[] { "value1", "value2" };
17+
}
18+
19+
[HttpGet("claims")]
20+
public ActionResult<string> Claims()
21+
{
22+
var sb = new StringBuilder();
23+
foreach (var claim in User.Claims)
24+
{
25+
sb.AppendLine($"{claim.Type}: {claim.Value}");
26+
}
27+
return sb.ToString();
28+
}
29+
30+
[HttpGet("forbid")]
31+
public new IActionResult Forbid()
32+
{
33+
return base.Forbid();
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)