Skip to content

Commit

Permalink
Support for token acquisition 1p features - AzureAD/microsoft-identit…
Browse files Browse the repository at this point in the history
  • Loading branch information
bgavrilMS committed Aug 12, 2024
1 parent 042cd37 commit 737d808
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace Microsoft.Identity.Abstractions
{
Expand Down Expand Up @@ -30,6 +31,7 @@ public AcquireTokenOptions(AcquireTokenOptions other)
CorrelationId = other.CorrelationId;
ExtraQueryParameters = other.ExtraQueryParameters;
ExtraHeadersParameters = other.ExtraHeadersParameters;
ExtraParameters = other.ExtraParameters;
ForceRefresh = other.ForceRefresh;
Claims = other.Claims;
PopPublicKey = other.PopPublicKey;
Expand Down Expand Up @@ -58,6 +60,15 @@ public AcquireTokenOptions(AcquireTokenOptions other)
/// </summary>
public IDictionary<string, string>? ExtraQueryParameters { get; set; }

/// <summary>
/// An property bag used for extensiblity.
/// </summary>
/// <remarks>
/// Not meant to be used by application developers, but by other SDKs.
/// </remarks>
[EditorBrowsable(EditorBrowsableState.Never)]
public IDictionary<string, object>? ExtraParameters { get; set; }

/// Sets extra headers in the HTTP request to the STS "/token" endpoint.
public IDictionary<string, string>? ExtraHeadersParameters { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public void CloneClonesAllProperties()
CorrelationId = Guid.NewGuid(),
ExtraHeadersParameters = new Dictionary<string, string> { { "slice", "test" } },
ExtraQueryParameters = new Dictionary<string, string> { { "slice", "test" } },
ExtraParameters = new Dictionary<string, object> { { "param1", "value1" }, { "param2", "value2" } },
ForceRefresh = true,
LongRunningWebApiSessionKey = AcquireTokenOptions.LongRunningWebApiSessionKeyAuto,
ManagedIdentity = new ManagedIdentityOptions(),
Expand Down Expand Up @@ -81,6 +82,7 @@ public void CloneClonesAllProperties()
Assert.Equal(downstreamApiOptions.AcquireTokenOptions.CorrelationId, downstreamApiClone.AcquireTokenOptions.CorrelationId);
Assert.Equal(downstreamApiOptions.AcquireTokenOptions.ExtraHeadersParameters, downstreamApiClone.AcquireTokenOptions.ExtraHeadersParameters);
Assert.Equal(downstreamApiOptions.AcquireTokenOptions.ExtraQueryParameters, downstreamApiClone.AcquireTokenOptions.ExtraQueryParameters);
Assert.Equal(downstreamApiOptions.AcquireTokenOptions.ExtraParameters, downstreamApiClone.AcquireTokenOptions.ExtraParameters);
Assert.Equal(downstreamApiOptions.AcquireTokenOptions.ForceRefresh, downstreamApiClone.AcquireTokenOptions.ForceRefresh);
Assert.Equal(downstreamApiOptions.AcquireTokenOptions.LongRunningWebApiSessionKey, downstreamApiClone.AcquireTokenOptions.LongRunningWebApiSessionKey);
Assert.Equal(downstreamApiOptions.AcquireTokenOptions.ManagedIdentity.UserAssignedClientId, downstreamApiClone.AcquireTokenOptions.ManagedIdentity?.UserAssignedClientId);
Expand All @@ -93,7 +95,7 @@ public void CloneClonesAllProperties()

// If this fails, think of also adding a line to test the new property
Assert.Equal(12, typeof(DownstreamApiOptions).GetProperties().Length);
Assert.Equal(13, typeof(AcquireTokenOptions).GetProperties().Length);
Assert.Equal(14, typeof(AcquireTokenOptions).GetProperties().Length);

DownstreamApiOptionsReadOnlyHttpMethod options = new DownstreamApiOptionsReadOnlyHttpMethod(downstreamApiOptions, HttpMethod.Delete.ToString());
Assert.Equal(HttpMethod.Delete.ToString(), options.HttpMethod);
Expand Down

0 comments on commit 737d808

Please sign in to comment.