Skip to content

Commit e28028b

Browse files
authored
Merge pull request #64 from akunzai/dotnet6
Update to .NET 6.0
2 parents 9168f41 + 8dfb0fb commit e28028b

Some content is hidden

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

42 files changed

+210
-303
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"dotnet-reportgenerator-globaltool": {
6-
"version": "4.8.13",
6+
"version": "5.0.0",
77
"commands": [
88
"reportgenerator"
99
]

.github/workflows/cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up .NET SDK
1717
uses: actions/setup-dotnet@v1
1818
with:
19-
dotnet-version: 5.0.x
19+
dotnet-version: 6.0.x
2020
- name: Build packages
2121
run: |
2222
dotnet --info

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
uses: actions/setup-dotnet@v1
2525
with:
2626
dotnet-version: 3.1.x
27-
- name: Set up .NET 5 SDK
27+
- name: Set up .NET 6 SDK
2828
uses: actions/setup-dotnet@v1
2929
with:
30-
dotnet-version: 5.0.x
30+
dotnet-version: 6.0.x
3131
- name: Build
3232
run: |
3333
dotnet --info

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## 2.3.1 (2021-11-14)
6+
7+
- Floating latest dependencies for .NET 6
8+
- [RNGCryptoServiceProvider is obsolete since .NET 6](https://github.com/dotnet/runtime/issues/40169)
9+
- Bump System.ComponentModel.Annotations from 4.5.0 to 4.7.0
10+
511
## 2.3.0 (2021-06-11)
612

713
- Floating latest dependencies for .NET Core 3.1 and .NET 5

OAuth.sln

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ EndProject
3535
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GSS.Authorization.OAuth2.HttpClient.Tests", "test\GSS.Authorization.OAuth2.HttpClient.Tests\GSS.Authorization.OAuth2.HttpClient.Tests.csproj", "{28080D26-3251-4619-AD9D-54381759ED2A}"
3636
EndProject
3737
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{F0FA418E-E9E8-4A7F-835D-A00476B78754}"
38+
ProjectSection(SolutionItems) = preProject
39+
samples\Directory.Build.props = samples\Directory.Build.props
40+
EndProjectSection
3841
EndProject
3942
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OAuth2HttpClientSample", "samples\OAuth2HttpClientSample\OAuth2HttpClientSample.csproj", "{D67C5C98-4344-4E1F-B809-5A91551C90EC}"
4043
EndProject

samples/Directory.Build.props

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project>
2+
3+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
4+
5+
<PropertyGroup>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<IsPackable>false</IsPackable>
9+
</PropertyGroup>
10+
11+
</Project>

samples/OAuth2HttpClientSample/OAuth2HttpClientSample.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<OutputType>Exe</OutputType>
6-
<IsPackable>false</IsPackable>
76
</PropertyGroup>
87

98
<ItemGroup>
Lines changed: 34 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,45 @@
1-
using System;
2-
using System.Collections.Generic;
31
using System.Net;
42
using System.Net.Http.Headers;
5-
using System.Threading.Tasks;
63
using GSS.Authorization.OAuth2;
74
using Microsoft.Extensions.Configuration;
85
using Microsoft.Extensions.DependencyInjection;
96
using Microsoft.Extensions.Hosting;
107

11-
namespace OAuth2HttpClientSample
8+
static void ConfigureAuthorizerOptions(IServiceProvider resolver, AuthorizerOptions options)
129
{
13-
public class Program
14-
{
15-
public static async Task Main(string[] args)
16-
{
17-
var host = Host.CreateDefaultBuilder(args)
18-
.ConfigureServices((hostContext, services) =>
19-
{
20-
var clientBuilder =
21-
hostContext.Configuration.GetValue("OAuth2:GrantFlow", "ClientCredentials")
22-
.Equals("ClientCredentials", StringComparison.OrdinalIgnoreCase)
23-
? services.AddOAuth2HttpClient<OAuth2HttpClient, ClientCredentialsAuthorizer>(
24-
ConfigureAuthorizerOptions)
25-
: services.AddOAuth2HttpClient<OAuth2HttpClient, ResourceOwnerCredentialsAuthorizer>(
26-
ConfigureAuthorizerOptions);
27-
clientBuilder.ConfigureHttpClient(client =>
28-
{
29-
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
30-
});
31-
}).Build();
32-
var configuration = host.Services.GetRequiredService<IConfiguration>();
10+
var configuration = resolver.GetRequiredService<IConfiguration>();
11+
options.AccessTokenEndpoint = configuration.GetValue<Uri>("OAuth2:AccessTokenEndpoint");
12+
options.ClientId = configuration["OAuth2:ClientId"];
13+
options.ClientSecret = configuration["OAuth2:ClientSecret"];
14+
options.Credentials = new NetworkCredential(
15+
configuration["OAuth2:Credentials:UserName"],
16+
configuration["OAuth2:Credentials:Password"]);
17+
options.Scopes = configuration.GetSection("OAuth2:Scopes").Get<IEnumerable<string>>();
18+
options.OnError = (code, message) => Console.Error.Write($"ERROR: [${code}]: {message}");
19+
}
3320

34-
Console.WriteLine("Creating a client...");
35-
var oauth2Client = host.Services.GetRequiredService<OAuth2HttpClient>();
21+
var host = Host.CreateDefaultBuilder(args)
22+
.ConfigureServices((hostContext, services) =>
23+
{
24+
var clientBuilder =
25+
hostContext.Configuration.GetValue("OAuth2:GrantFlow", "ClientCredentials")
26+
.Equals("ClientCredentials", StringComparison.OrdinalIgnoreCase)
27+
? services.AddOAuth2HttpClient<OAuth2HttpClient, ClientCredentialsAuthorizer>(
28+
ConfigureAuthorizerOptions)
29+
: services.AddOAuth2HttpClient<OAuth2HttpClient, ResourceOwnerCredentialsAuthorizer>(
30+
ConfigureAuthorizerOptions);
31+
clientBuilder.ConfigureHttpClient(client => client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")));
32+
}).Build();
33+
var configuration = host.Services.GetRequiredService<IConfiguration>();
34+
35+
Console.WriteLine("Creating a client...");
36+
var oauth2Client = host.Services.GetRequiredService<OAuth2HttpClient>();
37+
38+
Console.WriteLine("Sending a request...");
39+
var response = await oauth2Client.HttpClient.GetAsync(configuration.GetValue<Uri>("OAuth2:ResourceEndpoint")).ConfigureAwait(false);
40+
41+
Console.WriteLine("Response data:");
42+
var data = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
43+
Console.WriteLine(data);
3644

37-
Console.WriteLine("Sending a request...");
38-
var response = await oauth2Client.HttpClient.GetAsync(configuration.GetValue<Uri>("OAuth2:ResourceEndpoint")).ConfigureAwait(false);
39-
var data = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
40-
Console.WriteLine("Response data:");
41-
Console.WriteLine(data);
42-
}
4345

44-
private static void ConfigureAuthorizerOptions(IServiceProvider resolver, AuthorizerOptions options)
45-
{
46-
var configuration = resolver.GetRequiredService<IConfiguration>();
47-
options.AccessTokenEndpoint = configuration.GetValue<Uri>("OAuth2:AccessTokenEndpoint");
48-
options.ClientId = configuration["OAuth2:ClientId"];
49-
options.ClientSecret = configuration["OAuth2:ClientSecret"];
50-
options.Credentials = new NetworkCredential(
51-
configuration["OAuth2:Credentials:UserName"],
52-
configuration["OAuth2:Credentials:Password"]);
53-
options.Scopes = configuration.GetSection("OAuth2:Scopes").Get<IEnumerable<string>>();
54-
options.OnError = (code, message) =>
55-
{
56-
Console.Error.Write($"ERROR: [${code}]: {message}");
57-
};
58-
}
59-
}
60-
}

samples/OAuth2HttpClientSample/appsettings.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
{
22
"Logging": {
3-
"IncludeScopes": false,
43
"LogLevel": {
5-
"Default": "Debug",
6-
"System": "Information",
7-
"Microsoft": "Information"
4+
"Default": "Information"
85
}
96
},
107
"OAuth2": {
11-
"AccessTokenEndpoint": "https://example.com/oauth2/accessToken",
8+
"AccessTokenEndpoint": "https://example.com/oauth2/token",
129
"ResourceEndpoint": "https://example.com/oauth2/profile",
1310
"ClientId": "CHANGE_ME",
1411
"ClientSecret": "CHANGE_ME",

samples/OAuthHttpClientSample/OAuthHttpClientSample.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<OutputType>Exe</OutputType>
6-
<IsPackable>false</IsPackable>
76
</PropertyGroup>
87

98
<ItemGroup>

0 commit comments

Comments
 (0)