Skip to content

Commit 54ad6ab

Browse files
committed
Merge 7.0.11
2 parents 38d0b00 + eb9b4ad commit 54ad6ab

18 files changed

+2107
-122
lines changed

Directory.Build.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
<Product>Myvas.AspNetCore.Authentication</Product>
77
<Copyright>© $([System.DateTime]::Now.Year) Myvas Foundation</Copyright>
88
</PropertyGroup>
9-
9+
1010
<PropertyGroup>
11-
<MinVerVersion>6.0.3</MinVerVersion>
12-
<MinVerDefaultPreReleasePhase>alpha</MinVerDefaultPreReleasePhase>
11+
<MinVerVersion>7.0.11</MinVerVersion>
12+
<MinVerDefaultPreReleaseIdentifiers>alpha</MinVerDefaultPreReleaseIdentifiers>
1313
</PropertyGroup>
1414
<Target Name="CustomFileVersion" AfterTargets="MinVer">
1515
<PropertyGroup>

Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
22
<ItemGroup>
3-
<PackageReference Include="MinVer" Version="3.1.0" PrivateAssets="All"/>
3+
<PackageReference Include="MinVer" Version="4.3.0" PrivateAssets="All"/>
44
</ItemGroup>
55
</Project>

LICENSE.md renamed to LICENSE

File renamed without changes.

WeixinAuth.sln

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{672FEA18-F07
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_", "_", "{E9754587-13F5-4E3A-9F3F-71C98EF97990}"
99
ProjectSection(SolutionItems) = preProject
10-
.gitattributes = .gitattributes
1110
.gitignore = .gitignore
1211
Changelog.md = Changelog.md
1312
delete_all_bin_and_obj.cmd = delete_all_bin_and_obj.cmd
1413
Directory.Build.props = Directory.Build.props
1514
Directory.Build.targets = Directory.Build.targets
15+
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
1616
global.json = global.json
17-
LICENSE.md = LICENSE.md
18-
NuGet.Config = NuGet.Config
17+
LICENSE = LICENSE
1918
README.md = README.md
2019
EndProjectSection
2120
EndProject
@@ -29,6 +28,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeixinAuth.UnitTest_3_1", "
2928
EndProject
3029
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeixinAuth.UnitTest_5_0", "test\WeixinAuth.UnitTest_5_0\WeixinAuth.UnitTest_5_0.csproj", "{B812C99A-70DF-4EB6-95B6-E3B8CECE5A3A}"
3130
EndProject
31+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeixinAuth.UnitTest_6_0", "test\WeixinAuth.UnitTest_6_0\WeixinAuth.UnitTest_6_0.csproj", "{97F5B4DD-9362-4363-9EB8-2B6C027DCA39}"
32+
EndProject
3233
Global
3334
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3435
Debug|Any CPU = Debug|Any CPU
@@ -51,6 +52,10 @@ Global
5152
{B812C99A-70DF-4EB6-95B6-E3B8CECE5A3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
5253
{B812C99A-70DF-4EB6-95B6-E3B8CECE5A3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
5354
{B812C99A-70DF-4EB6-95B6-E3B8CECE5A3A}.Release|Any CPU.Build.0 = Release|Any CPU
55+
{97F5B4DD-9362-4363-9EB8-2B6C027DCA39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
56+
{97F5B4DD-9362-4363-9EB8-2B6C027DCA39}.Debug|Any CPU.Build.0 = Debug|Any CPU
57+
{97F5B4DD-9362-4363-9EB8-2B6C027DCA39}.Release|Any CPU.ActiveCfg = Release|Any CPU
58+
{97F5B4DD-9362-4363-9EB8-2B6C027DCA39}.Release|Any CPU.Build.0 = Release|Any CPU
5459
EndGlobalSection
5560
GlobalSection(SolutionProperties) = preSolution
5661
HideSolutionNode = FALSE
@@ -60,6 +65,7 @@ Global
6065
{94ABBE67-3755-4DD1-A25E-2407FB32C60E} = {73FCFCF4-3A1C-4D4D-939A-9CABDC2341DC}
6166
{688F627F-FF2D-4FE4-BAA7-BD94C139798B} = {73FCFCF4-3A1C-4D4D-939A-9CABDC2341DC}
6267
{B812C99A-70DF-4EB6-95B6-E3B8CECE5A3A} = {73FCFCF4-3A1C-4D4D-939A-9CABDC2341DC}
68+
{97F5B4DD-9362-4363-9EB8-2B6C027DCA39} = {73FCFCF4-3A1C-4D4D-939A-9CABDC2341DC}
6369
EndGlobalSection
6470
GlobalSection(ExtensibilityGlobals) = postSolution
6571
SolutionGuid = {2AEDFD1F-BBE1-4727-9978-2FB04DCE84AF}

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": "6.0.100",
3+
"version": "7.0.100",
44
"rollForward": "latestFeature"
55
}
66
}
Lines changed: 86 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,86 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.IO.Compression;
5-
using System.Linq;
6-
using System.Runtime.Serialization.Formatters.Binary;
7-
using System.Text;
8-
using System.Threading.Tasks;
9-
10-
namespace Myvas.AspNetCore.Authentication.WeixinAuth.Internal
11-
{
12-
/// <summary>
13-
/// ref. https://stackoverflow.com/questions/7343465/compression-decompression-string-with-c-sharp
14-
/// </summary>
15-
static internal class CompressionExtensions
16-
{
17-
public static async Task<IEnumerable<byte>> Zip(this object obj)
18-
{
19-
byte[] bytes = obj.Serialize();
20-
21-
using (MemoryStream msi = new MemoryStream(bytes))
22-
using (MemoryStream mso = new MemoryStream())
23-
{
24-
using (var gs = new GZipStream(mso, CompressionMode.Compress))
25-
await msi.CopyToAsync(gs);
26-
27-
return mso.ToArray().AsEnumerable();
28-
}
29-
}
30-
31-
public static async Task<object> Unzip(this byte[] bytes)
32-
{
33-
using (MemoryStream msi = new MemoryStream(bytes))
34-
using (MemoryStream mso = new MemoryStream())
35-
{
36-
using (var gs = new GZipStream(msi, CompressionMode.Decompress))
37-
{
38-
//gs.CopyTo(mso);
39-
await gs.CopyToAsync(mso);
40-
}
41-
42-
return mso.ToArray().Deserialize();
43-
}
44-
}
45-
}
46-
47-
internal static class SerializerExtensions
48-
{
49-
/// <summary>
50-
/// Writes the given object instance to a binary file.
51-
/// <para>Object type (and all child types) must be decorated with the [Serializable] attribute.</para>
52-
/// <para>To prevent a variable from being serialized, decorate it with the [NonSerialized] attribute; cannot be applied to properties.</para>
53-
/// </summary>
54-
/// <typeparam name="T">The type of object being written to the XML file.</typeparam>
55-
/// <param name="filePath">The file path to write the object instance to.</param>
56-
/// <param name="objectToWrite">The object instance to write to the XML file.</param>
57-
/// <param name="append">If false the file will be overwritten if it already exists. If true the contents will be appended to the file.</param>
58-
public static byte[] Serialize<T>(this T objectToWrite)
59-
{
60-
using (MemoryStream stream = new MemoryStream())
61-
{
62-
BinaryFormatter binaryFormatter = new BinaryFormatter();
63-
binaryFormatter.Serialize(stream, objectToWrite);
64-
65-
return stream.GetBuffer();
66-
}
67-
}
68-
69-
/// <summary>
70-
/// Reads an object instance from a binary file.
71-
/// </summary>
72-
/// <typeparam name="T">The type of object to read from the XML.</typeparam>
73-
/// <param name="filePath">The file path to read the object instance from.</param>
74-
/// <returns>Returns a new instance of the object read from the binary file.</returns>
75-
public static async Task<T> _Deserialize<T>(this byte[] arr)
76-
{
77-
using (MemoryStream stream = new MemoryStream())
78-
{
79-
BinaryFormatter binaryFormatter = new BinaryFormatter();
80-
await stream.WriteAsync(arr, 0, arr.Length);
81-
stream.Position = 0;
82-
83-
return (T)binaryFormatter.Deserialize(stream);
84-
}
85-
}
86-
87-
public static async Task<object> Deserialize(this byte[] arr)
88-
{
89-
object obj = await arr._Deserialize<object>();
90-
return obj;
91-
}
92-
}
93-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.IO.Compression;
5+
using System.Linq;
6+
using System.Runtime.Serialization.Formatters.Binary;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using System.Xml.Serialization;
10+
11+
namespace Myvas.AspNetCore.Authentication.WeixinAuth.Internal
12+
{
13+
/// <summary>
14+
/// ref. https://stackoverflow.com/questions/7343465/compression-decompression-string-with-c-sharp
15+
/// </summary>
16+
static internal class CompressionExtensions
17+
{
18+
public static async Task<IEnumerable<byte>> Zip(this object obj)
19+
{
20+
byte[] bytes = obj.Serialize();
21+
22+
using (MemoryStream msi = new MemoryStream(bytes))
23+
using (MemoryStream mso = new MemoryStream())
24+
{
25+
using (var gs = new GZipStream(mso, CompressionMode.Compress))
26+
await msi.CopyToAsync(gs);
27+
28+
return mso.ToArray().AsEnumerable();
29+
}
30+
}
31+
32+
public static async Task<object> Unzip(this byte[] bytes)
33+
{
34+
using (MemoryStream msi = new MemoryStream(bytes))
35+
using (MemoryStream mso = new MemoryStream())
36+
{
37+
using (var gs = new GZipStream(msi, CompressionMode.Decompress))
38+
{
39+
//gs.CopyTo(mso);
40+
await gs.CopyToAsync(mso);
41+
}
42+
43+
return mso.ToArray().Deserialize();
44+
}
45+
}
46+
}
47+
48+
internal static class SerializerExtensions
49+
{
50+
/// <summary>
51+
/// Writes the given object instance to a binary file.
52+
/// <para>Object type (and all child types) must be decorated with the [Serializable] attribute.</para>
53+
/// <para>To prevent a variable from being serialized, decorate it with the [NonSerialized] attribute; cannot be applied to properties.</para>
54+
/// </summary>
55+
/// <typeparam name="T">The type of object being written to the XML file.</typeparam>
56+
/// <param name="filePath">The file path to write the object instance to.</param>
57+
/// <param name="objectToWrite">The object instance to write to the XML file.</param>
58+
/// <param name="append">If false the file will be overwritten if it already exists. If true the contents will be appended to the file.</param>
59+
public static byte[] Serialize<T>(this T objectToWrite)
60+
{
61+
using var stream = new MemoryStream();
62+
var serializer = new XmlSerializer(typeof(T));
63+
serializer.Serialize(stream, objectToWrite);
64+
return stream.GetBuffer();
65+
}
66+
67+
/// <summary>
68+
/// Reads an object instance from a binary file.
69+
/// </summary>
70+
/// <typeparam name="T">The type of object to read from the XML.</typeparam>
71+
/// <param name="filePath">The file path to read the object instance from.</param>
72+
/// <returns>Returns a new instance of the object read from the binary file.</returns>
73+
public static async Task<T> _Deserialize<T>(this byte[] arr)
74+
{
75+
using var stream = new MemoryStream(arr);
76+
var serializer = new XmlSerializer(typeof(T));
77+
return await Task.FromResult((T)serializer.Deserialize(stream));
78+
}
79+
80+
public static async Task<object> Deserialize(this byte[] arr)
81+
{
82+
object obj = await arr._Deserialize<object>();
83+
return obj;
84+
}
85+
}
86+
}

src/WeixinAuth/WeixinAuth.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1</TargetFrameworks>
3+
<TargetFrameworks>net7.0;net6.0;net5.0;netcoreapp3.1</TargetFrameworks>
44
<ImplicitUsings>enable</ImplicitUsings>
55
<!--<Nullable>enable</Nullable>-->
66
<PackageId>Myvas.AspNetCore.Authentication.WeixinAuth</PackageId>
@@ -18,6 +18,10 @@
1818
<Product>Myvas.AspNetCore.Authentication</Product>
1919
</PropertyGroup>
2020

21+
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
22+
<PackageReference Include="Microsoft.AspNetCore.Authentication.Twitter" Version="7.0.0" />
23+
</ItemGroup>
24+
2125
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
2226
<PackageReference Include="Microsoft.AspNetCore.Authentication.Twitter" Version="6.0.0" />
2327
</ItemGroup>

test/WeixinAuth.UnitTest/WeixinAuth.UnitTest.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net7.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.2.0" />
10-
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.3" />
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
12-
<PackageReference Include="xunit" Version="2.4.1" />
13-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
9+
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.0.*" />
10+
<PackageReference Include="Microsoft.CodeCoverage" Version="17.7.*" />
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.*" />
12+
<PackageReference Include="xunit" Version="2.5.*" />
13+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.*">
1414
<PrivateAssets>all</PrivateAssets>
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1616
</PackageReference>

test/WeixinAuth.UnitTest/WeixinAuthTests.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ public async Task ChallengeWillTriggerApplyRedirectEvent()
736736
}
737737

738738
[Fact]
739-
public async Task AuthenticateWithoutCookieWillFail()
739+
public async Task AuthenticateWithoutCookieWillReturnNone()
740740
{
741741
var server = CreateServer(o =>
742742
{
@@ -748,9 +748,10 @@ public async Task AuthenticateWithoutCookieWillFail()
748748
var res = context.Response;
749749
if (req.Path == new PathString("/auth"))
750750
{
751-
var result = await context.AuthenticateAsync("WeixinAuth");
752-
Assert.NotNull(result.Failure);
753-
}
751+
var result = await context.AuthenticateAsync("WeixinAuth");
752+
//Assert.NotNull(result.Failure);
753+
Assert.True(result.None);
754+
}
754755
});
755756
var transaction = await server.SendAsync("https://example.com/auth");
756757
Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode);

test/WeixinAuth.UnitTest_3_1/WeixinAuth.UnitTest_3_1.csproj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.2.0" />
10-
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.23" />
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
12-
<PackageReference Include="xunit" Version="2.4.1" />
13-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
9+
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.*" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.*" />
11+
<PackageReference Include="xunit" Version="2.4.*" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.*">
1413
<PrivateAssets>all</PrivateAssets>
1514
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1615
</PackageReference>

0 commit comments

Comments
 (0)