Skip to content

custom pipeline #8

@leungkimming

Description

@leungkimming

//app.Use((context, next) =>
//{
// IAntiforgery antiforgery = app.Services.GetServices().FirstOrDefault();
// var user = context.User.Identity.Name;

// if (context.Request.Path.Value.Equals("/"))
// {
// return next(context);
// }

// if (!context.Request.Path.Value.EndsWith("login", StringComparison.InvariantCultureIgnoreCase))
// {
// var theaders = context.Request.Headers["X-CSRF-TOKEN-HEADER"];
// string theader = "";
// if (theaders.Count() > 0)
// {
// theader = theaders[0];
// }
// System.Diagnostics.Debug.WriteLine($"Path={context.Request.Path.Value} User={user}, Token={theader}");
// try
// {
// antiforgery.ValidateRequestAsync(context);
// }
// catch (AntiforgeryValidationException ex)
// {
// context.Response.StatusCode = 400;
// System.Diagnostics.Debug.WriteLine($"Invalid antiforgery token: {ex.Message}");
// throw new BadHttpRequestException($"Invalid antiforgery token: {ex.Message}");
// }
// }

// var tokens = antiforgery.GetAndStoreTokens(context);
// System.Diagnostics.Debug.WriteLine($"Path={context.Request.Path.Value} User={user}, NewToken={tokens.RequestToken}");
// context.Response.Cookies.Append("XSRF-TOKEN", tokens.RequestToken, new CookieOptions() { HttpOnly = false });
// return next(context);
//});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions