Skip to content

Commit 75af987

Browse files
Add support for .NET 6 (#188)
* Update `Microsoft.AspNetCore.Authentication.JwtBearer` and `Microsoft.AspNetCore.Authentication.OpenIdConnect` dependencies to the latest version of each target framework supported by the SDK. (#199) Co-authored-by: Laura Rodriguez <[email protected]>
1 parent bc09cf5 commit 75af987

File tree

10 files changed

+133
-71
lines changed

10 files changed

+133
-71
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ sudo: required
44
dist: xenial
55
dotnet: 5.0
66
before_install:
7+
- sudo apt-get install dotnet-sdk-6.0
78
- sudo apt-get install dotnet-sdk-3.1
89
script:
910
- ./build.sh
10-
11-

Okta.AspNet.Test/Okta.AspNet.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<ItemGroup>
1010
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
1111
<PackageReference Include="FluentAssertions" Version="5.3.0" />
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
1313
<PackageReference Include="NSubstitute" Version="4.2.0" />
1414
<PackageReference Include="xunit" Version="2.4.1" />
1515
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">

Okta.AspNetCore.Mvc.IntegrationTest/Okta.AspNetCore.Mvc.IntegrationTest.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
55
</PropertyGroup>
66

77
<ItemGroup>
@@ -10,6 +10,7 @@
1010

1111
<ItemGroup>
1212
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.0.0" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
1314
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
1415
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0">
1516
<PrivateAssets>all</PrivateAssets>

Okta.AspNetCore.Test/Okta.AspNetCore.Test.csproj

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
@@ -11,14 +11,8 @@
1111
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
1212
<PackageReference Include="NSubstitute" Version="4.2.2" />
1313
<PackageReference Include="xunit" Version="2.4.1" />
14-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
15-
<PrivateAssets>all</PrivateAssets>
16-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17-
</PackageReference>
18-
<PackageReference Include="coverlet.collector" Version="3.1.0">
19-
<PrivateAssets>all</PrivateAssets>
20-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21-
</PackageReference>
14+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"/>
15+
<PackageReference Include="coverlet.collector" Version="1.0.1" />
2216
</ItemGroup>
2317

2418
<ItemGroup>

Okta.AspNetCore.Test/OpenIdConnectOptionsHelperShould.cs

Lines changed: 72 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,40 @@ public class OpenIdConnectOptionsHelperShould
2929
[Theory]
3030
[InlineData(true)]
3131
[InlineData(false)]
32-
public void SetOpenIdConnectsOptions(bool getClaimsFromUserInfoEndpoint)
32+
public async Task SetOpenIdConnectsOptions(bool getClaimsFromUserInfoEndpoint)
3333
{
34-
var mockTokenValidatedEvent = Substitute.For<Func<OpenIdConnectTokenValidatedContext, Task>>();
35-
var mockUserInfoReceivedEvent = Substitute.For<Func<UserInformationReceivedContext, Task>>();
36-
var mockOktaExceptionEvent = Substitute.For<Func<RemoteFailureContext, Task>>();
37-
var mockAuthenticationFailedEvent = Substitute.For<Func<OpenIdConnectAuthenticationFailedContext, Task>>();
38-
var mockRedirectToIdentityProvider = Substitute.For<Func<RedirectContext, Task>>();
34+
bool invoked = false;
35+
36+
Func<OpenIdConnectTokenValidatedContext, Task> mockTokenValidatedEvent = context =>
37+
{
38+
invoked = true;
39+
return Task.CompletedTask;
40+
};
41+
42+
Func<UserInformationReceivedContext, Task> mockUserInfoReceivedEvent = context =>
43+
{
44+
invoked = true;
45+
return Task.CompletedTask;
46+
};
47+
48+
Func<RemoteFailureContext, Task> mockOktaExceptionEvent = context =>
49+
{
50+
invoked = true;
51+
return Task.CompletedTask;
52+
};
53+
54+
Func<OpenIdConnectAuthenticationFailedContext, Task> mockAuthenticationFailedEvent = context =>
55+
{
56+
invoked = true;
57+
return Task.CompletedTask;
58+
};
59+
60+
Func<RedirectContext, Task> mockRedirectToIdentityProvider = context =>
61+
{
62+
invoked = true;
63+
return Task.CompletedTask;
64+
};
65+
3966
var mockHttpHandler = Substitute.For<HttpMessageHandler>();
4067

4168
var oktaMvcOptions = new OktaMvcOptions
@@ -88,30 +115,51 @@ public void SetOpenIdConnectsOptions(bool getClaimsFromUserInfoEndpoint)
88115
oidcOptions.CallbackPath.Value.Should().Be(oktaMvcOptions.CallbackPath);
89116

90117
// Check the event was call once with a null parameter
91-
oidcOptions.Events.OnTokenValidated(null);
92-
mockTokenValidatedEvent.Received(1).Invoke(null);
93-
oidcOptions.Events.OnAuthenticationFailed(null);
94-
mockAuthenticationFailedEvent.Received(1).Invoke(null);
95-
oidcOptions.Events.OnRemoteFailure(null);
96-
mockOktaExceptionEvent.Received(1).Invoke(null);
97-
oidcOptions.Events.OnRedirectToIdentityProvider(null);
98-
mockRedirectToIdentityProvider.Received(1).Invoke(null);
118+
await oidcOptions.Events.OnTokenValidated(default);
119+
invoked.Should().BeTrue();
120+
invoked = false;
121+
122+
await oidcOptions.Events.OnAuthenticationFailed(default);
123+
invoked.Should().BeTrue();
124+
invoked = false;
125+
126+
127+
await oidcOptions.Events.OnRemoteFailure(default);
128+
invoked.Should().BeTrue();
129+
invoked = false;
130+
131+
132+
await oidcOptions.Events.OnRedirectToIdentityProvider(default);
133+
invoked.Should().BeTrue();
134+
invoked = false;
99135

100136
// UserInfo event is mapped only when GetClaimsFromUserInfoEndpoint = true
101137
if (oidcOptions.GetClaimsFromUserInfoEndpoint)
102138
{
103139
// Check the event was call once with a null parameter
104-
oidcOptions.Events.OnUserInformationReceived(null);
105-
mockUserInfoReceivedEvent.Received(1).Invoke(null);
140+
await oidcOptions.Events.OnUserInformationReceived(default);
141+
invoked.Should().BeTrue();
142+
invoked = false;
106143
}
107144
}
108145

109146
[Fact]
110-
public void SetJwtBearerOptions()
147+
public async Task SetJwtBearerOptions()
111148
{
112-
var mockTokenValidatedEvent = Substitute.For<Func<JwtTokenValidatedContext, Task>>();
113-
var mockAuthenticationFailedEvent = Substitute.For<Func<JwtAuthenticationFailedContext, Task>>();
114149
var mockHttpHandler = Substitute.For<HttpMessageHandler>();
150+
bool invoked = false;
151+
152+
Func<JwtTokenValidatedContext, Task> mockTokenValidatedEvent = context =>
153+
{
154+
invoked = true;
155+
return Task.CompletedTask;
156+
};
157+
158+
Func<JwtAuthenticationFailedContext, Task> mockAuthenticationFailedEvent = context =>
159+
{
160+
invoked = true;
161+
return Task.CompletedTask;
162+
};
115163

116164
var oktaWebApiOptions = new OktaWebApiOptions
117165
{
@@ -136,10 +184,11 @@ public void SetJwtBearerOptions()
136184
jwtBearerOptions.BackchannelTimeout.Should().Be(TimeSpan.FromMinutes(5));
137185
((DelegatingHandler)jwtBearerOptions.BackchannelHttpHandler).InnerHandler.Should().Be(mockHttpHandler);
138186

139-
jwtBearerOptions.Events.OnTokenValidated(null);
140-
mockTokenValidatedEvent.Received().Invoke(null);
141-
jwtBearerOptions.Events.OnAuthenticationFailed(null);
142-
mockAuthenticationFailedEvent.Received().Invoke(null);
187+
await jwtBearerOptions.Events.OnTokenValidated(default);
188+
invoked.Should().BeTrue();
189+
invoked = false;
190+
await jwtBearerOptions.Events.OnAuthenticationFailed(default);
191+
invoked.Should().BeTrue();
143192
}
144193
}
145194
}

Okta.AspNetCore.WebApi.IntegrationTest/Okta.AspNetCore.WebApi.IntegrationTest.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.0.0" />
8+
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.21" />
99
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
1010
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0">
1111
<PrivateAssets>all</PrivateAssets>
1212
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
</PackageReference>
1414
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
1516
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
1617
<PackageReference Include="xunit" Version="2.4.1" />
17-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
18+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
1819
<PrivateAssets>all</PrivateAssets>
1920
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2021
</PackageReference>

Okta.AspNetCore/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Changelog
22
Running changelog of releases since `3.2.0`
33

4+
## v4.1.0
5+
6+
### Features
7+
8+
- Add support for .NET 6.0 framework
9+
- Update `Microsoft.AspNetCore.Authentication.JwtBearer` and `Microsoft.AspNetCore.Authentication.OpenIdConnect` dependencies to the latest version of each target framework supported by the SDK. (#199)
10+
411
## v4.0.0
512

613
### Features
Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,45 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
5-
</PropertyGroup>
3+
<PropertyGroup>
4+
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
5+
</PropertyGroup>
66

7-
<PropertyGroup>
8-
<Description>Official Okta middleware for ASP.NET Core 3.0+. Easily add authentication and authorization to ASP.NET Core applications.</Description>
9-
<Copyright>(c) 2020 Okta, Inc.</Copyright>
10-
<VersionPrefix>4.0.0</VersionPrefix>
11-
<Authors>Okta, Inc.</Authors>
12-
<AssemblyName>Okta.AspNetCore</AssemblyName>
13-
<PackageId>Okta.AspNetCore</PackageId>
14-
<PackageTags>okta,token,authentication,authorization</PackageTags>
15-
<PackageIconUrl>https://raw.githubusercontent.com/okta/okta-sdk-dotnet/master/icon.png</PackageIconUrl>
16-
<PackageProjectUrl>https://github.com/okta/okta-aspnet</PackageProjectUrl>
17-
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
18-
<RepositoryUrl>https://github.com/okta/okta-aspnet</RepositoryUrl>
19-
</PropertyGroup>
7+
<PropertyGroup>
8+
<Description>Official Okta middleware for ASP.NET Core 3.1+. Easily add authentication and authorization to ASP.NET Core applications.</Description>
9+
<Copyright>(c) 2020 - present Okta, Inc. All rights reserved.</Copyright>
10+
<VersionPrefix>4.1.0</VersionPrefix>
11+
<Authors>Okta, Inc.</Authors>
12+
<AssemblyName>Okta.AspNetCore</AssemblyName>
13+
<PackageId>Okta.AspNetCore</PackageId>
14+
<PackageTags>okta,token,authentication,authorization</PackageTags>
15+
<PackageIconUrl>https://raw.githubusercontent.com/okta/okta-sdk-dotnet/master/icon.png</PackageIconUrl>
16+
<PackageProjectUrl>https://github.com/okta/okta-aspnet</PackageProjectUrl>
17+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
18+
<RepositoryUrl>https://github.com/okta/okta-aspnet</RepositoryUrl>
19+
<Version>4.1.0</Version>
20+
</PropertyGroup>
2021

21-
<ItemGroup>
22-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.1" />
23-
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="3.1.1" />
24-
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
25-
<PrivateAssets>all</PrivateAssets>
26-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
27-
</PackageReference>
28-
<AdditionalFiles Include="..\stylecop.json" />
29-
</ItemGroup>
30-
31-
<ItemGroup>
32-
<ProjectReference Include="..\Okta.AspNet.Abstractions\Okta.AspNet.Abstractions.csproj" />
33-
</ItemGroup>
22+
<ItemGroup>
23+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.23" />
24+
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="3.1.23" />
25+
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
26+
<PrivateAssets>all</PrivateAssets>
27+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
28+
</PackageReference>
29+
<AdditionalFiles Include="..\stylecop.json" />
30+
</ItemGroup>
31+
32+
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
33+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.3" />
34+
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.3" />
35+
</ItemGroup>
36+
37+
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
38+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.15" />
39+
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.15" />
40+
</ItemGroup>
41+
42+
<ItemGroup>
43+
<ProjectReference Include="..\Okta.AspNet.Abstractions\Okta.AspNet.Abstractions.csproj" />
44+
</ItemGroup>
3445
</Project>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ We also publish these other libraries for .NET:
2323

2424
This library uses semantic versioning and follows Okta's [library version policy](https://developer.okta.com/code/library-versions/).
2525

26-
:heavy_check_mark: The current stable major version series is: 1.x
26+
:heavy_check_mark: The current stable major version series is: 4.x for Okta.AspNetCore and 2.x for Okta.AspNet.
2727

2828
|Package| Version | Status | Compatibility|
2929
| ------- | ------- | ------------------------- | ----------------------- |
3030
|`Okta.AspNet.Abstractions`| 4.x | heavy_check_mark: Stable | .NET Standard 2.0 and .NET Framework 4.5.2 or higher.|
3131
|`Okta.AspNet.Abstractions`| 3.x | :warning: Retiring | .NET Standard 2.0 and .NET Framework 4.5.2 or higher.|
3232
|`Okta.AspNet`| 2.x | :heavy_check_mark: Stable | .NET Framework 4.5.2 |
3333
|`Okta.AspNet`| 1.x | :warning: Retiring | .NET Framework 4.5.2 |
34-
|`Okta.AspNetCore`| 4.x | :heavy_check_mark: Stable | .NET Core 3.x and .NET 5.0 |
34+
|`Okta.AspNetCore`| 4.x | :heavy_check_mark: Stable | .NET Core 3.x, .NET 5.0 and .NET 6.0 |
3535
|`Okta.AspNetCore`| 3.x | :warning: Retiring | .NET Standard 2.0 and .NET Core 2.x |
3636

3737

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "5.0.301",
3+
"version": "6.0.0",
44
"rollForward": "latestMajor"
55
}
66
}

0 commit comments

Comments
 (0)