2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.Models.Membership;
|
2020-02-09 19:14:19 +01:00
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
namespace Umbraco.Cms.Core.Security
|
2020-02-09 19:14:19 +01:00
|
|
|
{
|
2020-10-21 16:51:00 +11:00
|
|
|
public interface IBackOfficeSecurity
|
2020-02-09 19:14:19 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the current user.
|
|
|
|
|
/// </summary>
|
2020-12-02 14:28:16 +11:00
|
|
|
/// <returns>The current user that has been authenticated for the request.</returns>
|
|
|
|
|
/// <remarks>If authentication hasn't taken place this will be null.</remarks>
|
|
|
|
|
// TODO: This is used a lot but most of it can be refactored to not use this at all since the IUser instance isn't
|
|
|
|
|
// needed in most cases. Where an IUser is required this could be an ext method on the ClaimsIdentity/ClaimsPrincipal that passes in
|
|
|
|
|
// an IUserService, like HttpContext.User.GetUmbracoUser(_userService);
|
|
|
|
|
// This one isn't as easy to remove as the others below.
|
2020-02-09 19:14:19 +01:00
|
|
|
IUser CurrentUser { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the current user's id.
|
|
|
|
|
/// </summary>
|
2020-12-02 14:28:16 +11:00
|
|
|
/// <returns>The current user's Id that has been authenticated for the request.</returns>
|
|
|
|
|
/// <remarks>If authentication hasn't taken place this will be unsuccessful.</remarks>
|
|
|
|
|
// TODO: This should just be an extension method on ClaimsIdentity
|
2020-02-09 19:14:19 +01:00
|
|
|
Attempt<int> GetUserId();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Checks if the specified user as access to the app
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="section"></param>
|
|
|
|
|
/// <param name="user"></param>
|
|
|
|
|
/// <returns></returns>
|
2020-12-02 14:28:16 +11:00
|
|
|
/// <remarks>If authentication hasn't taken place this will be unsuccessful.</remarks>
|
|
|
|
|
// TODO: Should be part of IBackOfficeUserManager
|
2020-02-09 19:14:19 +01:00
|
|
|
bool UserHasSectionAccess(string section, IUser user);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Ensures that a back office user is logged in
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2020-12-02 14:28:16 +11:00
|
|
|
/// <remarks>This does not force authentication, that must be done before calls to this are made.</remarks>
|
|
|
|
|
// TODO: Should be removed, this should not be necessary
|
2020-02-09 19:14:19 +01:00
|
|
|
bool IsAuthenticated();
|
|
|
|
|
}
|
|
|
|
|
}
|