CrLfTab
This commit is contained in:
@@ -39,9 +39,9 @@ namespace Umbraco.Web.WebApi
|
||||
|
||||
var effectiveEncoding = SelectCharacterEncoding(content == null ? null : content.Headers);
|
||||
|
||||
using (var streamWriter = new StreamWriter(writeStream, effectiveEncoding,
|
||||
using (var streamWriter = new StreamWriter(writeStream, effectiveEncoding,
|
||||
//we are only writing a few chars so we don't need to allocate a large buffer
|
||||
128,
|
||||
128,
|
||||
//this is important! We don't want to close the stream, the base class is in charge of stream management, we just want to write to it.
|
||||
leaveOpen:true))
|
||||
{
|
||||
@@ -50,7 +50,7 @@ namespace Umbraco.Web.WebApi
|
||||
streamWriter.Write(XsrfPrefix);
|
||||
streamWriter.Flush();
|
||||
await base.WriteToStreamAsync(type, value, writeStream, content, transportContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,4 +14,4 @@ namespace Umbraco.Web.WebApi
|
||||
actionContext.ControllerContext.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,6 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
cookieToken == null ? null : cookieToken,
|
||||
out failedReason);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Web.Http.Filters;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -50,7 +50,7 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
var actionContext = actionExecutedContext.ActionContext;
|
||||
if (actionContext.ActionArguments[_userIdParameter] == null)
|
||||
{
|
||||
throw new InvalidOperationException("No argument found for the current action with the name: " + _userIdParameter);
|
||||
throw new InvalidOperationException("No argument found for the current action with the name: " + _userIdParameter);
|
||||
}
|
||||
|
||||
var user = UmbracoContext.Current.Security.CurrentUser;
|
||||
@@ -73,4 +73,4 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
throw new InvalidOperationException("The id type: " + parameterValue.GetType() + " is not a supported id");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -33,7 +33,7 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
|
||||
//we need new tokens and append the custom header if changes have been made
|
||||
if (actionExecutedContext.ActionContext.Request.Properties.ContainsKey(typeof(CheckIfUserTicketDataIsStaleAttribute).Name))
|
||||
{
|
||||
{
|
||||
var tokenFilter = new SetAngularAntiForgeryTokensAttribute();
|
||||
tokenFilter.OnActionExecuted(actionExecutedContext);
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
|
||||
var user = Current.Services.UserService.GetUserById(userId.Result);
|
||||
if (user == null) return;
|
||||
|
||||
|
||||
//a list of checks to execute, if any of them pass then we resync
|
||||
var checks = new Func<bool>[]
|
||||
{
|
||||
@@ -74,7 +74,7 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
{
|
||||
var culture = UserExtensions.GetUserCulture(user, Current.Services.TextService);
|
||||
return culture != null && culture.ToString() != identity.Culture;
|
||||
},
|
||||
},
|
||||
() => user.AllowedSections.UnsortedSequenceEqual(identity.AllowedApplications) == false,
|
||||
() => user.Groups.Select(x => x.Alias).UnsortedSequenceEqual(identity.Roles) == false,
|
||||
() =>
|
||||
@@ -91,7 +91,7 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
|
||||
if (checks.Any(check => check()))
|
||||
{
|
||||
await ReSync(user, actionContext);
|
||||
await ReSync(user, actionContext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,8 +115,8 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
await signInManager.SignInAsync(backOfficeIdentityUser, isPersistent: true, rememberBrowser: false);
|
||||
|
||||
//flag that we've made changes
|
||||
actionContext.Request.Properties[typeof(CheckIfUserTicketDataIsStaleAttribute).Name] = true;
|
||||
actionContext.Request.Properties[typeof(CheckIfUserTicketDataIsStaleAttribute).Name] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,8 +91,8 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
actionContext.Request.Properties,
|
||||
UmbracoContext.Current.Security.CurrentUser,
|
||||
Current.Services.UserService,
|
||||
Current.Services.ContentService,
|
||||
Current.Services.EntityService,
|
||||
Current.Services.ContentService,
|
||||
Current.Services.EntityService,
|
||||
nodeId, _permissionToCheck.HasValue ? new[]{_permissionToCheck.Value}: null))
|
||||
{
|
||||
base.OnActionExecuting(actionContext);
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
actionContext.Request.Properties,
|
||||
UmbracoContext.Current.Security.CurrentUser,
|
||||
Current.Services.MediaService,
|
||||
Current.Services.EntityService,
|
||||
Current.Services.EntityService,
|
||||
nodeId))
|
||||
{
|
||||
base.OnActionExecuting(actionContext);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
private readonly IEntityService _entityService;
|
||||
private readonly char _permissionToCheck;
|
||||
|
||||
public FilterAllowedOutgoingContentAttribute(Type outgoingType)
|
||||
public FilterAllowedOutgoingContentAttribute(Type outgoingType)
|
||||
: this(outgoingType, Current.Services.UserService, Current.Services.EntityService)
|
||||
{
|
||||
_permissionToCheck = ActionBrowse.Instance.Letter;
|
||||
|
||||
@@ -19,10 +19,10 @@ namespace Umbraco.Web.WebApi
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
internal static Attempt<IOwinContext> TryGetOwinContext(this HttpRequestMessage request)
|
||||
{
|
||||
{
|
||||
// occurs in unit tests?
|
||||
if (request.Properties.TryGetValue("MS_OwinContext", out var o) && o is IOwinContext owinContext)
|
||||
return Attempt.Succeed(owinContext);
|
||||
return Attempt.Succeed(owinContext);
|
||||
|
||||
var httpContext = request.TryGetHttpContext();
|
||||
try
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Umbraco.Web.WebApi
|
||||
|
||||
public UmbracoAuthorizeAttribute() : this(true)
|
||||
{ }
|
||||
|
||||
|
||||
public UmbracoAuthorizeAttribute(bool requireApproval)
|
||||
{
|
||||
_requireApproval = requireApproval;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Umbraco.Web.WebApi
|
||||
{
|
||||
private BackOfficeUserManager<BackOfficeIdentityUser> _userManager;
|
||||
private bool _userisValidated = false;
|
||||
|
||||
|
||||
protected BackOfficeUserManager<BackOfficeIdentityUser> UserManager
|
||||
=> _userManager ?? (_userManager = TryGetOwinContext().Result.GetBackOfficeUserManager());
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Umbraco.Web.WebApi
|
||||
protected User UmbracoUser
|
||||
{
|
||||
get
|
||||
{
|
||||
{
|
||||
//throw exceptions if not valid (true)
|
||||
if (!_userisValidated)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Umbraco.Web.WebApi
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Important to note that the <see cref="UnhandledExceptionLogger"/> will only be called if the controller has an ExceptionFilter applied
|
||||
/// to it, so to kill two birds with one stone, this class inherits from ExceptionFilterAttribute purely to force webapi to use the
|
||||
/// to it, so to kill two birds with one stone, this class inherits from ExceptionFilterAttribute purely to force webapi to use the
|
||||
/// IExceptionLogger (strange)
|
||||
/// </remarks>
|
||||
public class UnhandedExceptionLoggerConfigurationAttribute : ExceptionFilterAttribute, IControllerConfiguration
|
||||
@@ -24,6 +24,6 @@ namespace Umbraco.Web.WebApi
|
||||
{
|
||||
controllerSettings.Services.Add(typeof(IExceptionLogger), new UnhandledExceptionLogger());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ namespace Umbraco.Web.WebApi
|
||||
&& context.Exception != null)
|
||||
{
|
||||
_logger.Error(context.ExceptionContext.ActionContext.ControllerContext.Controller.GetType(), "Unhandled controller exception occurred", context.Exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user