Skip to content

Commit

Permalink
Updating the parameter name to audience_for_saml_response (#41)
Browse files Browse the repository at this point in the history
* .NET Framework 471 architecture added. Version bump to 1.2.3

* renaming the audience for saml response parameter

* fixing the wrong casing

* version bump
  • Loading branch information
yevgenkre authored Jun 11, 2024
1 parent 7281f68 commit 408da61
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions DuoUniversal.Tests/TestGenerateAuthUrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void TestSuccess(string username)
[TestCase("[email protected]")]
public void TestSuccessWithIssuer(string username)
{
Client clientWithIssuer = new ClientBuilder(CLIENT_ID, CLIENT_SECRET, API_HOST, REDIRECT_URI).UseAudienceIssuer("http://issuer").Build();
Client clientWithIssuer = new ClientBuilder(CLIENT_ID, CLIENT_SECRET, API_HOST, REDIRECT_URI).UseAudienceForSamlResponse("http://issuer").Build();
string authUri = clientWithIssuer.GenerateAuthUri(username, STATE);
Assert.True(Uri.IsWellFormedUriString(authUri, UriKind.Absolute));
Assert.True(authUri.StartsWith($"https://{API_HOST}"));
Expand All @@ -46,15 +46,15 @@ public void TestSuccessWithIssuer(string username)
[TestCase(" ")]
public void TestInvalidIssuer(string issuer)
{
Client clientWithIssuer = new ClientBuilder(CLIENT_ID, CLIENT_SECRET, API_HOST, REDIRECT_URI).UseAudienceIssuer(issuer).Build();
Client clientWithIssuer = new ClientBuilder(CLIENT_ID, CLIENT_SECRET, API_HOST, REDIRECT_URI).UseAudienceForSamlResponse(issuer).Build();
Assert.Throws<DuoException>(() => clientWithIssuer.GenerateAuthUri("username", STATE));
}

[Test]
[TestCase(null)]
public void TestNullIssuer(string issuer)
{
Client clientWithIssuer = new ClientBuilder(CLIENT_ID, CLIENT_SECRET, API_HOST, REDIRECT_URI).UseAudienceIssuer(issuer).Build();
Client clientWithIssuer = new ClientBuilder(CLIENT_ID, CLIENT_SECRET, API_HOST, REDIRECT_URI).UseAudienceForSamlResponse(issuer).Build();
string authUri = clientWithIssuer.GenerateAuthUri("username", STATE);
Assert.True(Uri.IsWellFormedUriString(authUri, UriKind.Absolute));
}
Expand Down
20 changes: 10 additions & 10 deletions DuoUniversal/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class Client

internal bool UseDuoCodeAttribute { get; set; } = false;

internal string AudienceIssuer { get; set; } = null;
internal string AudienceForSamlResponse { get; set; } = null;

internal Client()
{
Expand Down Expand Up @@ -85,7 +85,7 @@ public async Task<bool> DoHealthCheck(bool handleException = true)
/// <returns>A URL to redirect the user's browser to</returns>
public string GenerateAuthUri(string username, string state)
{
ValidateAuthUriInputs(username, state, AudienceIssuer);
ValidateAuthUriInputs(username, state, AudienceForSamlResponse);

string authEndpoint = CustomizeApiUri(AUTH_ENDPOINT);

Expand Down Expand Up @@ -203,9 +203,9 @@ private string GenerateAuthJwt(string username, string state, string authEndpoin
};

// issuer parameter is used for the Epic Hyperdrive integration only
if (AudienceIssuer != null)
if (AudienceForSamlResponse != null)
{
additionalClaims[Labels.AUDIENCE_ISSUER] = AudienceIssuer;
additionalClaims[Labels.AUDIENCE_FOR_SAML_RESPONSE] = AudienceForSamlResponse;
}

if (UseDuoCodeAttribute)
Expand Down Expand Up @@ -311,7 +311,7 @@ public class ClientBuilder
private bool _sslCertValidation = true;
private X509Certificate2Collection _customRoots = null;
private IWebProxy proxy = null;
private string _audienceIssuer = null;
private string _audienceForSamlResponse = null;


// For testing only
Expand Down Expand Up @@ -425,13 +425,13 @@ public ClientBuilder UseHttpProxy(IWebProxy proxy)
}

/// <summary>
/// Set an audienceIssuer value to generate a SAML response for the Epic integration
/// Set an audienceForSamlResponse value to generate a SAML response for the Epic integration
/// </summary>
/// <param name="audienceIssuer">Specific parameter for the Epic integration for the SAML response generation</param>
/// <param name="audienceForSamlResponse">Specific parameter for the Epic integration for the SAML response generation</param>
/// <returns>The ClientBuilder</returns>
public ClientBuilder UseAudienceIssuer(string audienceIssuer)
public ClientBuilder UseAudienceForSamlResponse(string audienceForSamlResponse)
{
_audienceIssuer = audienceIssuer;
_audienceForSamlResponse = audienceForSamlResponse;

return this;
}
Expand All @@ -451,7 +451,7 @@ public Client Build()
ApiHost = _apiHost,
RedirectUri = _redirectUri,
UseDuoCodeAttribute = _useDuoCodeAttribute,
AudienceIssuer = _audienceIssuer
AudienceForSamlResponse = _audienceForSamlResponse
};

var httpClient = BuildHttpClient();
Expand Down
6 changes: 3 additions & 3 deletions DuoUniversal/DuoUniversal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net471</TargetFrameworks>
<PackageId>DuoUniversal</PackageId>
<Version>1.2.4</Version>
<Version>1.2.5</Version>
<Authors>Duo Security</Authors>
<Company>Duo Security</Company>
<Copyright>Cisco Systems, Inc. and/or its affiliates</Copyright>
Expand All @@ -26,9 +26,9 @@
<PackageReference Include="System.Text.Json" Version="5.0.2" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
<Reference Include="System.Web" />
</ItemGroup>
</ItemGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
Expand Down
2 changes: 1 addition & 1 deletion DuoUniversal/Labels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ internal class Labels
public const string DUO_UNAME = "duo_uname";
public const string PREFERRED_USERNAME = "preferred_username";
public const string USE_DUO_CODE_ATTRIBUTE = "use_duo_code_attribute";
public const string AUDIENCE_ISSUER = "issuer";
public const string AUDIENCE_FOR_SAML_RESPONSE = "audience_for_saml_response";
}
}

0 comments on commit 408da61

Please sign in to comment.