umbraco / Announcements

Subscribe to this repo to be notified about major changes in Umbraco-CMS, Deploy and Forms
MIT License
21 stars 0 forks source link

[Breaking change]: Access claims will be removed from `ClaimsIdentity` in V15 #18

Open kjac opened 3 months ago

kjac commented 3 months ago

Description

The following claims will be removed from ClaimsIdentity in V15:

These claims correspond to these (now obsolete) security constants:

Version

Umbraco 15

Previous behavior

The mentioned claims would be readily available for interpretation on ClaimsIdentity.

New behavior

The mentioned claims are no longer available on ClaimsIdentity.

Type of breaking change

Reason for change

First and foremost, this change allows for smoother access changes for users of the Management API. At this time we're forced to revoke tokens when access changes, which is not an ideal behaviour for currently logged-in users.

Secondly, this change paves the way for facilitating external authorization for specific operations that are currently tied to the ClaimsIdentity claims.

Recommended action

To access the allowed sections of a user, go directly to IUser:

private readonly IUserService _userService;

private async Task<IEnumerable<string>?> GetAllowedSections(Guid userKey)
{
  IUser? user = await _userService.GetAsync(userKey);
  return user?.AllowedSections;
}

To access the calculated user start nodes, use the UserExtensions:

private readonly IEntityService _entityService;
private readonly AppCaches _appCaches;

private IEnumerable<int>? UserContentStartNodeIds(IUser user)
  => user.CalculateContentStartNodeIds(_entityService, _appCaches);

private IEnumerable<int>? UserMediaStartNodeIds(IUser user)
  => user.CalculateContentStartNodeIds(_entityService, _appCaches);

Affected APIs