Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ASP.NET ValidateAntiForgeryToken feature #2206

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

brunomacharia
Copy link

Jtable ajax calls to controler actions marked with [ValidateAntiForgeryToken] may not work because Antiforgery checks the request header for an antiforgery token which is then compared with the cookies token. If they don't match or the token is missing, the server responds with error 400. All this is to prevent Cross-Site Request Forgery (CSRF) Attacks. This fix attempts to manage this by adding a security option where a antiforgerytoken can be passed, this is then added to the ajax call header for server side validation. usage would be like:

var token = 'gettokenvalue'
$('#CategoriesContainer').jtable(
{
title: 'Categories',
paging: false,
sorting: false,
security: {
antiforgerytoken: token
},
actions: {----------

bmacharia and others added 2 commits January 5, 2019 19:32
Jtable ajax calls to controler actions marked with [ValidateAntiForgeryToken]  may not work because Antiforgery checks the request header for an antiforgery token which is then compared with the  cookies token. If they don't match or the token is missing, the server responds with error 400. All this is to prevent Cross-Site Request Forgery (CSRF) Attacks. This fix attempts to manage this by adding a security option where a antiforgerytoken can be passed, this is then added to the ajax call header for server side validation. usage would be like:

 var token = 'gettokenvalue'
        $('#CategoriesContainer').jtable(
            {
                title: 'Categories',
                paging: false,
                sorting: false,
                security:
                {
                    antiforgerytoken: token
                },
                actions: {----------
@brunomacharia brunomacharia changed the title Add ASP.NET ValidateAntiForgeryToken fix Add ASP.NET ValidateAntiForgeryToken feature Jan 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant