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

Identity release archboard feedback #38166

Merged
merged 2 commits into from
Aug 14, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ namespace Azure.Identity.BrokeredAuthentication
public partial class InteractiveBrowserCredentialBrokerOptions : Azure.Identity.InteractiveBrowserCredentialOptions
{
public InteractiveBrowserCredentialBrokerOptions(System.IntPtr parentWindowHandle) { }
public bool? IsMsaPassthroughEnabled { get { throw null; } set { } }
}
public partial class SharedTokenCacheCredentialBrokerOptions : Azure.Identity.SharedTokenCacheCredentialOptions
{
public SharedTokenCacheCredentialBrokerOptions() { }
public SharedTokenCacheCredentialBrokerOptions(Azure.Identity.TokenCachePersistenceOptions tokenCacheOptions) { }
public bool? IsMsaPassthroughEnabled { get { throw null; } set { } }
}
}
2 changes: 1 addition & 1 deletion sdk/identity/Azure.Identity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## 1.10.0-beta.2 (Unreleased)

### Features Added
- Add `BrowserCustomizedOptions` to `InteractiveBrowserCredential` to enable web view customization for interactive authentication.
- Added `BrowserCustomization` property to `InteractiveBrowserCredential` to enable web view customization for interactive authentication.

### Breaking Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ public AzurePowerShellCredentialOptions() { }
}
public partial class BrowserCustomizationOptions
{
public bool? UseEmbeddedWebView;
public BrowserCustomizationOptions() { }
public string HtmlMessageError { get { throw null; } set { } }
public string HtmlMessageSuccess { get { throw null; } set { } }
public string ErrorMessage { get { throw null; } set { } }
public string SuccessMessage { get { throw null; } set { } }
public bool? UseEmbeddedWebView { get { throw null; } set { } }
}
public partial class ChainedTokenCredential : Azure.Core.TokenCredential
{
Expand Down Expand Up @@ -281,7 +281,7 @@ public partial class InteractiveBrowserCredentialOptions : Azure.Identity.TokenC
public InteractiveBrowserCredentialOptions() { }
public System.Collections.Generic.IList<string> AdditionallyAllowedTenants { get { throw null; } }
public Azure.Identity.AuthenticationRecord AuthenticationRecord { get { throw null; } set { } }
public Azure.Identity.BrowserCustomizationOptions BrowserCustomizedOptions { get { throw null; } set { } }
public Azure.Identity.BrowserCustomizationOptions BrowserCustomization { get { throw null; } set { } }
public string ClientId { get { throw null; } set { } }
public bool DisableAutomaticAuthentication { get { throw null; } set { } }
public bool DisableInstanceDiscovery { get { throw null; } set { } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class BrowserCustomizationOptions
/// Specifies if the public client application should used an embedded web browser
/// or the system default browser
/// </summary>
public bool? UseEmbeddedWebView;
public bool? UseEmbeddedWebView { get; set; }

internal SystemWebViewOptions SystemBrowserOptions;

Expand All @@ -34,7 +34,7 @@ private SystemWebViewOptions systemWebViewOptions
/// Property to set HtmlMessageSuccess of SystemWebViewOptions from MSAL,
/// which the browser will show to the user when the user finishes authenticating successfully.
/// </summary>
public string HtmlMessageSuccess
public string SuccessMessage
{
get
{
Expand All @@ -52,7 +52,7 @@ public string HtmlMessageSuccess
/// which the browser will show to the user when the user finishes authenticating, but an error occurred.
/// You can use a string format e.g. "An error has occurred: {0} details: {1}".
/// </summary>
public string HtmlMessageError
public string ErrorMessage
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class InteractiveBrowserCredential : TokenCredential
internal string[] AdditionallyAllowedTenantIds { get; }
internal string ClientId { get; }
internal string LoginHint { get; }
internal BrowserCustomizationOptions BrowserCustomizedOptions { get; }
internal BrowserCustomizationOptions BrowserCustomization { get; }
internal MsalPublicClient Client { get; }
internal CredentialPipeline Pipeline { get; }
internal bool DisableAutomaticAuthentication { get; }
Expand Down Expand Up @@ -91,7 +91,7 @@ internal InteractiveBrowserCredential(string tenantId, string clientId, TokenCre
Client = client ?? new MsalPublicClient(Pipeline, tenantId, clientId, redirectUrl, options);
AdditionallyAllowedTenantIds = TenantIdResolver.ResolveAddionallyAllowedTenantIds((options as ISupportsAdditionallyAllowedTenants)?.AdditionallyAllowedTenants);
Record = (options as InteractiveBrowserCredentialOptions)?.AuthenticationRecord;
BrowserCustomizedOptions = (options as InteractiveBrowserCredentialOptions)?.BrowserCustomizedOptions;
BrowserCustomization = (options as InteractiveBrowserCredentialOptions)?.BrowserCustomization;
}

/// <summary>
Expand Down Expand Up @@ -242,7 +242,7 @@ private async Task<AccessToken> GetTokenViaBrowserLoginAsync(TokenRequestContext

var tenantId = TenantIdResolver.Resolve(TenantId ?? Record?.TenantId, context, AdditionallyAllowedTenantIds);
AuthenticationResult result = await Client
.AcquireTokenInteractiveAsync(context.Scopes, context.Claims, prompt, LoginHint, tenantId, context.IsCaeEnabled, BrowserCustomizedOptions, async, cancellationToken)
.AcquireTokenInteractiveAsync(context.Scopes, context.Claims, prompt, LoginHint, tenantId, context.IsCaeEnabled, BrowserCustomization, async, cancellationToken)
.ConfigureAwait(false);

Record = new AuthenticationRecord(result, ClientId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ public string TenantId
/// <summary>
/// The options for customizing the browser for interactive authentication.
/// </summary>
public BrowserCustomizationOptions BrowserCustomizedOptions { get; set; }
public BrowserCustomizationOptions BrowserCustomization { get; set; }
christothes marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -294,25 +294,25 @@ public async Task InvokesBeforeBuildClientOnExtendedOptions()
}

[Test]
public async Task BrowserCustomizedOptionsHtmlMessage([Values(null, "<p> Login Successfully.</p>")] string htmlMessageSuccess, [Values(null, "<p> An error occured: {0}. Details {1}</p>")] string htmlMessageError)
public async Task BrowserCustomizationsHtmlMessage([Values(null, "<p> Login Successfully.</p>")] string htmlMessageSuccess, [Values(null, "<p> An error occured: {0}. Details {1}</p>")] string htmlMessageError)
christothes marked this conversation as resolved.
Show resolved Hide resolved
{
var mockMsalClient = new MockMsalPublicClient
{
InteractiveAuthFactory = (_, _, _, _, _, _, browserOptions, _) =>
{
Assert.AreEqual(false, browserOptions.UseEmbeddedWebView);
Assert.AreEqual(htmlMessageSuccess, browserOptions.HtmlMessageSuccess);
Assert.AreEqual(htmlMessageError, browserOptions.HtmlMessageError);
Assert.AreEqual(htmlMessageSuccess, browserOptions.SuccessMessage);
Assert.AreEqual(htmlMessageError, browserOptions.ErrorMessage);
return AuthenticationResultFactory.Create(Guid.NewGuid().ToString(), expiresOn: DateTimeOffset.UtcNow.AddMinutes(5));
}
};
var options = new InteractiveBrowserCredentialOptions()
{
BrowserCustomizedOptions = new BrowserCustomizationOptions()
BrowserCustomization = new BrowserCustomizationOptions()
{
UseEmbeddedWebView = false,
HtmlMessageSuccess = htmlMessageSuccess,
HtmlMessageError = htmlMessageError
SuccessMessage = htmlMessageSuccess,
ErrorMessage = htmlMessageError
}
};

Expand All @@ -329,16 +329,16 @@ public async Task BrowserCustomizedUseEmbeddedWebView([Values(null, true, false)
InteractiveAuthFactory = (_, _, _, _, _, _, browserOptions, _) =>
{
Assert.AreEqual(useEmbeddedWebView, browserOptions.UseEmbeddedWebView);
Assert.AreEqual(htmlMessageError, browserOptions.HtmlMessageError);
Assert.AreEqual(htmlMessageError, browserOptions.ErrorMessage);
return AuthenticationResultFactory.Create(Guid.NewGuid().ToString(), expiresOn: DateTimeOffset.UtcNow.AddMinutes(5));
}
};
var options = new InteractiveBrowserCredentialOptions()
{
BrowserCustomizedOptions = new BrowserCustomizationOptions()
BrowserCustomization = new BrowserCustomizationOptions()
{
UseEmbeddedWebView = useEmbeddedWebView,
HtmlMessageError = htmlMessageError
ErrorMessage = htmlMessageError
}
};

Expand Down