Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.5 release candidate #104

Merged
merged 1 commit into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Google.Authenticator/Google.Authenticator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Description>Google Authenticator Two-Factor Authentication Library (Not officially affiliated with Google.)</Description>
<Authors>Brandon Potter</Authors>
<Company>Brandon Potter</Company>
<Version>2.4.0</Version>
<Version>2.5.0</Version>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/BrandonPotter/GoogleAuthenticator</PackageProjectUrl>
<PackageId>GoogleAuthenticator</PackageId>
Expand Down
9 changes: 7 additions & 2 deletions Google.Authenticator/TwoFactorAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ public SetupCode GenerateSetupCode(string issuer,
throw new NullReferenceException("Account Title is null");
}

// MS wants us to change this to use EscapeDataString - https://docs.microsoft.com/en-us/dotnet/fundamentals/syslib-diagnostics/syslib0013
// But that changes the output. Specifically "[email protected]" becomes "a%40b.com"
// See issue https://github.com/BrandonPotter/GoogleAuthenticator/issues/103
#pragma warning disable SYSLIB0013
accountTitleNoSpaces = RemoveWhitespace(Uri.EscapeUriString(accountTitleNoSpaces));
#pragma warning restore SYSLIB0013

var encodedSecretKey = Base32Encoding.ToString(accountSecretKey);

var provisionUrl = string.IsNullOrWhiteSpace(issuer)
Expand All @@ -81,7 +87,7 @@ private static string GenerateQrCodeUrl(int qrPixelsPerModule, string provisionU
var qrCodeUrl = "";
try
{
using (var qrGenerator = new QRCodeGenerator())
using (var qrGenerator = new QRCodeGenerator())
using (var qrCodeData = qrGenerator.CreateQrCode(provisionUrl, QRCodeGenerator.ECCLevel.Q))
#if NET6_0
using (var qrCode = new PngByteQRCode(qrCodeData))
Expand All @@ -98,7 +104,6 @@ private static string GenerateQrCodeUrl(int qrPixelsPerModule, string provisionU
qrCodeUrl = $"data:image/png;base64,{Convert.ToBase64String(ms.ToArray())}";
}
#endif

}
catch (TypeInitializationException e)
{
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ TwoFactorAuthenticator tfa = new TwoFactorAuthenticator();
bool result = tfa.ValidateTwoFactorPIN(key, txtCode.Text)
```

## Updates

### 2.5.0
Now runs on .Net 6.0.
Technically the QR Coder library we rely on still does not fully support .Net 6.0 so it is possible there will be other niggling issues, but for now all tests pass for .Net 6.0 on both Windows and Linux.

## Common Pitfalls

* Old documentation indicated specifying width and height for the QR code, but changes in QR generation now uses pixels per module (QR "pixel") so using a value too high will result in a huge image that can overrun memory allocations
Expand Down