Skip to content

Commit

Permalink
minor non-breaking internal refactor, and 1.0.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
orionstudt committed May 1, 2022
1 parent c087ac9 commit 11b6b81
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 72 deletions.
10 changes: 8 additions & 2 deletions DuoSecurity.Auth.Http.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31005.135
# Visual Studio Version 17
VisualStudioVersion = 17.1.32414.318
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DuoSecurity.Auth.Http", "DuoSecurity.Auth.Http\DuoSecurity.Auth.Http.csproj", "{4D8F9F67-1DFE-44E2-8C16-2EECEDF7EF16}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E48D3EC3-9793-4D6B-BE97-B8580C2D54C3}"
ProjectSection(SolutionItems) = preProject
LICENSE = LICENSE
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
16 changes: 8 additions & 8 deletions DuoSecurity.Auth.Http/Core/DuoRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public DuoRequestBuilder(DuoAuthConfig config)
secretKey = config.SecretKey;
}

private HttpRequestMessage buildMessage(HttpMethod method, string endpoint, params KeyValuePair<string, string>[] parameters)
private HttpRequestMessage BuildMessage(HttpMethod method, string endpoint, params KeyValuePair<string, string>[] parameters)
{
// Url Encoded Parameters
var urlParams = string.Empty;
Expand Down Expand Up @@ -72,21 +72,21 @@ public HttpRequestMessage PingRequest()
}

public HttpRequestMessage CheckRequest()
=> buildMessage(HttpMethod.Get, "check");
=> BuildMessage(HttpMethod.Get, "check");

public HttpRequestMessage LogoRequest()
=> buildMessage(HttpMethod.Get, "logo");
=> BuildMessage(HttpMethod.Get, "logo");

public HttpRequestMessage EnrollRequest(string username, int? validSecs)
{
var parameters = new List<KeyValuePair<string, string>>();
if (!string.IsNullOrWhiteSpace(username)) parameters.Add(new KeyValuePair<string, string>("username", username));
if (validSecs.HasValue) parameters.Add(new KeyValuePair<string, string>("valid_secs", validSecs.Value.ToString()));
return buildMessage(HttpMethod.Post, "enroll", parameters.ToArray());
return BuildMessage(HttpMethod.Post, "enroll", parameters.ToArray());
}

public HttpRequestMessage EnrollCheckRequest(string userId, string activationCode)
=> buildMessage(
=> BuildMessage(
HttpMethod.Post,
"enroll_status",
new KeyValuePair<string, string>[]
Expand All @@ -112,7 +112,7 @@ public HttpRequestMessage PreAuthRequest(string userId, string username, string
if (!string.IsNullOrWhiteSpace(trustedDeviceToken))
parameters.Add(new KeyValuePair<string, string>("trusted_device_token", trustedDeviceToken));

return buildMessage(HttpMethod.Post, "preauth", parameters.ToArray());
return BuildMessage(HttpMethod.Post, "preauth", parameters.ToArray());
}

public HttpRequestMessage AuthRequest(string userId, string username, string factor, string ipaddr, string async, string device, string passcode)
Expand Down Expand Up @@ -141,11 +141,11 @@ public HttpRequestMessage AuthRequest(string userId, string username, string fac
if (!string.IsNullOrWhiteSpace(async))
parameters.Add(new KeyValuePair<string, string>("async", async));

return buildMessage(HttpMethod.Post, "auth", parameters.ToArray());
return BuildMessage(HttpMethod.Post, "auth", parameters.ToArray());
}

public HttpRequestMessage AuthStatusRequest(string transactionId)
=> buildMessage(
=> BuildMessage(
HttpMethod.Get,
"auth_status",
new KeyValuePair<string, string>[]
Expand Down
4 changes: 2 additions & 2 deletions DuoSecurity.Auth.Http/DuoAuthClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public class DuoAuthClient : IDisposable

public DuoAuthClient(DuoAuthConfig config, HttpClient client = null)
{
builder = new DuoRequestBuilder(config);
this.builder = new DuoRequestBuilder(config);
if (client == null)
{
ownsClient = true;
this.ownsClient = true;
this.client = new HttpClient();
}
else this.client = client;
Expand Down
3 changes: 1 addition & 2 deletions DuoSecurity.Auth.Http/DuoResponse.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DuoSecurity.Auth.Http.Abstraction;
using DuoSecurity.Auth.Http.Core;
using DuoSecurity.Auth.Http.Core;
using DuoSecurity.Auth.Http.JsonModels;
using Newtonsoft.Json;
using System.Net.Http;
Expand Down
47 changes: 20 additions & 27 deletions DuoSecurity.Auth.Http/DuoSecurity.Auth.Http.csproj
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>1.0.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Joshua Studt</Authors>
<Description>A .NET HttpClient wrapper for interacting with the Duo Security Auth REST API.</Description>
<PackageProjectUrl>https://github.com/orionstudt/DuoSecurity.Auth.Http</PackageProjectUrl>
<RepositoryUrl>https://github.com/orionstudt/DuoSecurity.Auth.Http</RepositoryUrl>
<PackageTags>Duo DuoSecurity REST API Auth TwoFactor 2FA HttpClient</PackageTags>
<PackageReleaseNotes>Ensure request timestamp takes into account time zone offset minutes.</PackageReleaseNotes>
<Copyright>Joshua Studt 2020</Copyright>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>1.0.2</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Joshua Studt</Authors>
<Description>A .NET HttpClient wrapper for interacting with the Duo Security Auth REST API.</Description>
<PackageProjectUrl>https://github.com/orionstudt/DuoSecurity.Auth.Http</PackageProjectUrl>
<RepositoryUrl>https://github.com/orionstudt/DuoSecurity.Auth.Http</RepositoryUrl>
<PackageTags>Duo DuoSecurity REST API Auth TwoFactor 2FA HttpClient</PackageTags>
<PackageReleaseNotes>Resolve issue caused by Newtonsoft.Json &amp; DeserializeObject on .NET Core 3.</PackageReleaseNotes>
<Copyright>Joshua Studt 2022</Copyright>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<ItemGroup>
<None Include="..\$(PackageLicenseFile)" Pack="true" PackagePath="" />
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<LangVersion>7.1</LangVersion>
</PropertyGroup>

<ItemGroup>
<None Include="..\$(PackageLicenseFile)" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup>

</Project>
7 changes: 2 additions & 5 deletions DuoSecurity.Auth.Http/JsonModels/AuthAsyncResultModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DuoSecurity.Auth.Http.Abstraction;
using DuoSecurity.Auth.Http.Results;
using DuoSecurity.Auth.Http.Results;

namespace DuoSecurity.Auth.Http.JsonModels
{
Expand All @@ -8,8 +7,6 @@ public class AuthAsyncResultModel : IJsonModel<AuthAsyncResult>
public string Txid { get; set; }

public AuthAsyncResult ToResult()
{
return new AuthAsyncResult(this);
}
=> new(this);
}
}
7 changes: 2 additions & 5 deletions DuoSecurity.Auth.Http/JsonModels/AuthResultModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DuoSecurity.Auth.Http.Abstraction;
using DuoSecurity.Auth.Http.Results;
using DuoSecurity.Auth.Http.Results;

namespace DuoSecurity.Auth.Http.JsonModels
{
Expand All @@ -14,8 +13,6 @@ internal class AuthResultModel : IJsonModel<AuthResult>
public string Trusted_Device_Token { get; set; }

public AuthResult ToResult()
{
return new AuthResult(this);
}
=> new(this);
}
}
7 changes: 2 additions & 5 deletions DuoSecurity.Auth.Http/JsonModels/AuthStatusResultModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DuoSecurity.Auth.Http.Abstraction;
using DuoSecurity.Auth.Http.Results;
using DuoSecurity.Auth.Http.Results;

namespace DuoSecurity.Auth.Http.JsonModels
{
Expand All @@ -14,8 +13,6 @@ internal class AuthStatusResultModel : IJsonModel<AuthStatusResult>
public string Trusted_Device_Token { get; set; }

public AuthStatusResult ToResult()
{
return new AuthStatusResult(this);
}
=> new(this);
}
}
7 changes: 2 additions & 5 deletions DuoSecurity.Auth.Http/JsonModels/EnrollResultModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DuoSecurity.Auth.Http.Abstraction;
using DuoSecurity.Auth.Http.Results;
using DuoSecurity.Auth.Http.Results;

namespace DuoSecurity.Auth.Http.JsonModels
{
Expand All @@ -16,8 +15,6 @@ internal class EnrollResultModel : IJsonModel<EnrollResult>
public string Username { get; set; }

public EnrollResult ToResult()
{
return new EnrollResult(this);
}
=> new(this);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace DuoSecurity.Auth.Http.Abstraction
namespace DuoSecurity.Auth.Http.JsonModels
{
internal interface IJsonModel<T>
{
Expand Down
7 changes: 2 additions & 5 deletions DuoSecurity.Auth.Http/JsonModels/PingResultModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DuoSecurity.Auth.Http.Abstraction;
using DuoSecurity.Auth.Http.Results;
using DuoSecurity.Auth.Http.Results;

namespace DuoSecurity.Auth.Http.JsonModels
{
Expand All @@ -8,8 +7,6 @@ internal class PingResultModel : IJsonModel<PingResult>
public long Time { get; set; }

public PingResult ToResult()
{
return new PingResult(this);
}
=> new(this);
}
}
7 changes: 2 additions & 5 deletions DuoSecurity.Auth.Http/JsonModels/PreAuthResultModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DuoSecurity.Auth.Http.Abstraction;
using DuoSecurity.Auth.Http.Results;
using DuoSecurity.Auth.Http.Results;
using System.Collections.Generic;

namespace DuoSecurity.Auth.Http.JsonModels
Expand All @@ -21,8 +20,6 @@ public ICollection<DeviceModel> Devices
public string Enroll_Portal_Url { get; set; }

public PreAuthResult ToResult()
{
return new PreAuthResult(this);
}
=> new(this);
}
}

0 comments on commit 11b6b81

Please sign in to comment.