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 AntiForgery tokens to some actions that were missing them #4490

Merged
merged 4 commits into from
Aug 2, 2017

Conversation

scottbommarito
Copy link
Contributor

@scottbommarito scottbommarito commented Jul 31, 2017

Mostly admin routes.

These include

  • LuceneController
  • SupportRequestController
  • SecurityPolicyController
  • CuratedPackagesController
  • UsersController

https://github.com/NuGet/Engineering/issues/638

@skofman1
Copy link
Contributor

skofman1 commented Aug 1, 2017

How did you test this?

$(document).ready(function() {
$(document).ready(function () {
var addAntiForgeryToken = function (data) {
var $field = $("#AntiForgeryForm input[name=__RequestVerificationToken]");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code should go in a shared location.

Copy link
Member

@joelverhagen joelverhagen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's reduce the copied code here.

@chenriksson
Copy link
Member

Could we have a unit test that verifies that controller actions w/ HttpPost also have ValidateAntiForgeryToken?

@scottbommarito
Copy link
Contributor Author

scottbommarito commented Aug 1, 2017

@skofman1 I tested all of the endpoints manually and checked that they all worked with the attribute.

@chenriksson I like that idea, will add to this PR.

@scottbommarito
Copy link
Contributor Author

@joelverhagen I moved the code to a shared place by adding a ViewHelpers method and a shared Javascript function.

@scottbommarito
Copy link
Contributor Author

@chenriksson Finished the test as requested and found two more endpoints with the issue!

@@ -0,0 +1,104 @@
using System;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copyright

@scottbommarito scottbommarito merged commit 94769fd into dev Aug 2, 2017
@scottbommarito scottbommarito deleted the sb-adminantiforge branch August 2, 2017 18:04
@dtivel dtivel mentioned this pull request Aug 3, 2017
31 tasks
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.

5 participants