ctrager/budoco

I don't know how to allow a post from a "foreign" source (for posting screenshots from separate app)

ctrager opened this issue · 5 comments

020-12-12 17:25:29.676 -06:00 [INF] 4 Startup.cs URL: http://localhost:5000/CreateIssue
2020-12-12 17:25:29.683 -06:00 [INF] Executing endpoint '/CreateIssue'
2020-12-12 17:25:29.700 -06:00 [DBG] Registered model binder providers, in the following order: ["Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinderProvider","Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ServicesModelBinderProvider","Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinderProvider","Microsoft.AspNetCore.Mvc.ModelBinding.Binders.HeaderModelBinderProvider","Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FloatingPointTypeModelBinderProvider","Microsoft.AspNetCore.Mvc.ModelBinding.Binders.EnumTypeModelBinderProvider","Microsoft.AspNetCore.Mvc.ModelBinding.Binders.DateTimeModelBinderProvider","Microsoft.AspNetCore.Mvc.ModelBinding.Binders.SimpleTypeModelBinderProvider","Microsoft.AspNetCore.Mvc.ModelBinding.Binders.CancellationTokenModelBinderProvider","Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ByteArrayModelBinderProvider","Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FormFileModelBinderProvider","Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FormCollectionModelBinderProvider","Microsoft.AspNetCore.Mvc.ModelBinding.Binders.KeyValuePairModelBinderProvider","Microsoft.AspNetCore.Mvc.ModelBinding.Binders.DictionaryModelBinderProvider","Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ArrayModelBinderProvider","Microsoft.AspNetCore.Mvc.ModelBinding.Binders.CollectionModelBinderProvider","Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ComplexObjectModelBinderProvider"]
2020-12-12 17:25:29.742 -06:00 [INF] Route matched with {page = "/CreateIssue"}. Executing page /CreateIssue
2020-12-12 17:25:29.743 -06:00 [DBG] Execution plan of authorization filters (in the following order): ["Microsoft.AspNetCore.Mvc.ViewFeatures.Filters.AutoValidateAntiforgeryTokenAuthorizationFilter"]
2020-12-12 17:25:29.744 -06:00 [DBG] Execution plan of resource filters (in the following order): ["Microsoft.AspNetCore.Mvc.ViewFeatures.Filters.SaveTempDataFilter"]
2020-12-12 17:25:29.744 -06:00 [DBG] Execution plan of action filters (in the following order): ["Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilter (Order: -3000)"]
2020-12-12 17:25:29.745 -06:00 [DBG] Execution plan of exception filters (in the following order): ["None"]
2020-12-12 17:25:29.746 -06:00 [DBG] Execution plan of result filters (in the following order): ["Microsoft.AspNetCore.Mvc.ViewFeatures.Filters.SaveTempDataFilter"]
2020-12-12 17:25:29.754 -06:00 [DBG] Connection id "0HM4UUKRB9TAU", Request id "0HM4UUKRB9TAU:00000002": started reading request body.
2020-12-12 17:25:29.755 -06:00 [DBG] Connection id "0HM4UUKRB9TAU", Request id "0HM4UUKRB9TAU:00000002": done reading request body.
2020-12-12 17:25:29.760 -06:00 [INF] Antiforgery token validation failed. The required antiforgery cookie ".AspNetCore.Antiforgery.uO77BpFhTRE" is not present.
Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The required antiforgery cookie ".AspNetCore.Antiforgery.uO77BpFhTRE" is not present.
at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.ValidateRequestAsync(HttpContext httpContext)
at Microsoft.AspNetCore.Mvc.ViewFeatures.Filters.ValidateAntiforgeryTokenAuthorizationFilter.OnAuthorizationAsync(AuthorizationFilterContext context)
2020-12-12 17:25:29.778 -06:00 [INF] Authorization failed for the request at filter 'Microsoft.AspNetCore.Mvc.ViewFeatures.Filters.AutoValidateAntiforgeryTokenAuthorizationFilter'.
2020-12-12 17:25:29.785 -06:00 [INF] Executing HttpStatusCodeResult, setting HTTP status code 400
202

@ivangrek - I can't figure out the magic words to either 1) turn OFF the checking for one specific endpoint or 2) generate the tokens before Razor pages routing sees them.

See my failed attempts in Startup.cs
069a36c

I keep googling for the magic words, but so far no luck.

@ivangrek NEVERMIND, sorry to bother you. I figured it out.

CSRF-TOKEN is required to prevent CSRF attack.

Try doing GET request to get token and then POST request with token.