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

v14: Remove UI settings from BackOfficeExternalLoginProviderOptions #16064

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,103 +1,22 @@
using Umbraco.Cms.Core.Models;

namespace Umbraco.Cms.Api.Management.Security;

/// <summary>
/// Options used to configure back office external login providers
/// </summary>
public class BackOfficeExternalLoginProviderOptions
{
private string _buttonStyle = string.Empty;

public BackOfficeExternalLoginProviderOptions(
string buttonStyle,
string icon,
ExternalSignInAutoLinkOptions? autoLinkOptions = null,
bool denyLocalLogin = false,
bool autoRedirectLoginToExternalProvider = false,
string? customBackOfficeView = null)
bool denyLocalLogin = false)
{
ButtonStyle = buttonStyle;
Icon = icon;
AutoLinkOptions = autoLinkOptions ?? new ExternalSignInAutoLinkOptions();
DenyLocalLogin = denyLocalLogin;

Check notice on line 13 in src/Umbraco.Cms.Api.Management/Security/BackOfficeExternalLoginProviderOptions.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v14/dev)

✅ No longer an issue: Constructor Over-Injection

BackOfficeExternalLoginProviderOptions is no longer above the threshold for number of arguments
AutoRedirectLoginToExternalProvider = autoRedirectLoginToExternalProvider;
CustomBackOfficeView = customBackOfficeView;
}

public BackOfficeExternalLoginProviderOptions()
{
}

/// <summary>
/// Gets or sets the style of the login button.
/// </summary>
/// <remarks>
/// The default look is an outlined button, which has been optimized for the login screen.
/// </remarks>
[Obsolete("This is no longer used and will be removed in V15. Please set the ButtonLook and ButtonColor properties instead.")]
public string ButtonStyle
{
get => _buttonStyle;
set
{
_buttonStyle = value;

// Map cases from buttons.less
switch (value.ToLowerInvariant())
{
case "btn-primary":
ButtonColor = UuiButtonColor.Default;
ButtonLook = UuiButtonLook.Primary;
break;
case "btn-warning":
ButtonColor = UuiButtonColor.Warning;
ButtonLook = UuiButtonLook.Primary;
break;
case "btn-danger":
ButtonColor = UuiButtonColor.Danger;
ButtonLook = UuiButtonLook.Primary;
break;
case "btn-success":
ButtonColor = UuiButtonColor.Positive;
ButtonLook = UuiButtonLook.Primary;
break;
default:
ButtonColor = UuiButtonColor.Default;
ButtonLook = UuiButtonLook.Outline;
break;
}
}
}

/// <summary>
/// Gets or sets the look to use for the login button.
/// See the UUI documentation for more details: https://uui.umbraco.com/?path=/story/uui-button--looks-and-colors.
/// </summary>
/// <remarks>
/// The default value is <see cref="UuiButtonLook.Outline" />, which has been optimized for the login screen.
/// </remarks>
public UuiButtonLook ButtonLook { get; set; } = UuiButtonLook.Outline;

/// <summary>
/// Gets or sets the color to use for the login button.
/// See the UUI documentation for more details: https://uui.umbraco.com/?path=/story/uui-button--looks-and-colors.
/// </summary>
/// <remarks>
/// The default value is <see cref="UuiButtonColor.Default" />, which has been optimized for the login screen.
/// </remarks>
public UuiButtonColor ButtonColor { get; set; } = UuiButtonColor.Default;

/// <summary>
/// Gets or sets the icon to use for the login button.
/// The standard icons of the Backoffice is available.
/// </summary>
/// <remarks>
/// It is possible to add custom icons to your provider by adding the icons to the
/// <c>~/App_Plugins/{providerAlias}/icons</c> folder as SVG files. The icon name should be the same as the file name.
/// </remarks>
public string Icon { get; set; } = "icon-user";

/// <summary>
/// Gets or sets options used to control how users can be auto-linked/created/updated based on the external login provider
/// </summary>
Expand All @@ -108,26 +27,4 @@
/// This is useful if you want to force users to login with an external provider.
/// </summary>
public bool DenyLocalLogin { get; set; }

/// <summary>
/// Gets or sets a value indicating whether when specified this will automatically redirect to the OAuth login provider instead of prompting the user to click
/// on the OAuth button first.
/// </summary>
/// <remarks>
/// This is generally used in conjunction with <see cref="DenyLocalLogin" />. If more than one OAuth provider specifies
/// this, the last registered
/// provider's redirect settings will win.
/// </remarks>
public bool AutoRedirectLoginToExternalProvider { get; set; }

/// <summary>
/// Gets or sets a virtual path to a custom JavaScript module that will be rendered in place of the default OAuth login buttons.
/// The view can optionally replace the entire login screen if the <see cref="DenyLocalLogin"/> option is set to true.
/// </summary>
/// <remarks>
/// If this view is specified it is 100% up to the user to render the html responsible for rendering the link/un-link
/// buttons along with showing any errors that occur.
/// This overrides what Umbraco normally does by default.
/// </remarks>
public string? CustomBackOfficeView { get; set; }
}
Expand Up @@ -38,13 +38,6 @@ public class BackOfficeExternalLoginProviders : IBackOfficeExternalLoginProvider
return new BackOfficeExternaLoginProviderScheme(provider, associatedScheme);
}

/// <inheritdoc />
public string? GetAutoLoginProvider()
{
var found = _externalLogins.Values.Where(x => x.Options.AutoRedirectLoginToExternalProvider).ToList();
return found.Count > 0 ? found[0].AuthenticationType : null;
}

/// <inheritdoc />
public async Task<IEnumerable<BackOfficeExternaLoginProviderScheme>> GetBackOfficeProvidersAsync()
{
Expand Down
Expand Up @@ -18,13 +18,6 @@ public interface IBackOfficeExternalLoginProviders
/// <returns></returns>
Task<IEnumerable<BackOfficeExternaLoginProviderScheme>> GetBackOfficeProvidersAsync();

/// <summary>
/// Returns the authentication type for the last registered external login (oauth) provider that specifies an
/// auto-login redirect option
/// </summary>
/// <returns></returns>
string? GetAutoLoginProvider();

/// <summary>
/// Returns true if there is any external provider that has the Deny Local Login option configured
/// </summary>
Expand Down
15 changes: 0 additions & 15 deletions src/Umbraco.Core/Models/UuiButtonColor.cs

This file was deleted.

16 changes: 0 additions & 16 deletions src/Umbraco.Core/Models/UuiButtonLook.cs

This file was deleted.