Merge pull request #9833 from umbraco/9622-remove-backofficeidentity
Netcore: Remove UmbracoBackOfficeIdentity
This commit is contained in:
@@ -26,14 +26,22 @@ namespace Umbraco.Core.Compose
|
||||
private readonly IUserService _userService;
|
||||
private readonly IEntityService _entityService;
|
||||
private readonly IIpResolver _ipResolver;
|
||||
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
|
||||
public AuditEventsComponent(IAuditService auditService, IUserService userService, IEntityService entityService, IIpResolver ipResolver, IOptions<GlobalSettings> globalSettings)
|
||||
public AuditEventsComponent(
|
||||
IAuditService auditService,
|
||||
IUserService userService,
|
||||
IEntityService entityService,
|
||||
IIpResolver ipResolver,
|
||||
IOptions<GlobalSettings> globalSettings,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor)
|
||||
{
|
||||
_auditService = auditService;
|
||||
_userService = userService;
|
||||
_entityService = entityService;
|
||||
_ipResolver = ipResolver;
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
_globalSettings = globalSettings.Value;
|
||||
}
|
||||
|
||||
@@ -73,7 +81,7 @@ namespace Umbraco.Core.Compose
|
||||
{
|
||||
get
|
||||
{
|
||||
var identity = Thread.CurrentPrincipal?.GetUmbracoIdentity();
|
||||
var identity = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser;
|
||||
var user = identity == null ? null : _userService.GetUserById(Convert.ToInt32(identity.Id));
|
||||
return user ?? UnknownUser(_globalSettings);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Cms.Core.Security;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Core.Security
|
||||
{
|
||||
@@ -26,7 +26,7 @@ namespace Umbraco.Core.Security
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <remarks>
|
||||
/// Returns a custom <see cref="UmbracoBackOfficeIdentity"/> and allows flowing claims from the external identity
|
||||
/// Returns a ClaimsIdentity that has the required claims, and allows flowing of claims from external identity
|
||||
/// </remarks>
|
||||
public override async Task<ClaimsPrincipal> CreateAsync(BackOfficeIdentityUser user)
|
||||
{
|
||||
@@ -43,10 +43,7 @@ namespace Umbraco.Core.Security
|
||||
baseIdentity.AddClaim(new Claim(claim.ClaimType, claim.ClaimValue));
|
||||
}
|
||||
|
||||
// TODO: We want to remove UmbracoBackOfficeIdentity and only rely on ClaimsIdentity, once
|
||||
// that is done then we'll create a ClaimsIdentity with all of the requirements here instead
|
||||
var umbracoIdentity = new UmbracoBackOfficeIdentity(
|
||||
baseIdentity,
|
||||
baseIdentity.AddRequiredClaims(
|
||||
user.Id,
|
||||
user.UserName,
|
||||
user.Name,
|
||||
@@ -57,7 +54,7 @@ namespace Umbraco.Core.Security
|
||||
user.AllowedSections,
|
||||
user.Roles.Select(x => x.RoleId).ToArray());
|
||||
|
||||
return new ClaimsPrincipal(umbracoIdentity);
|
||||
return new ClaimsPrincipal(baseIdentity);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in New Issue
Block a user