runtime loading of ValidateAntiForgeryToken Salt value

前端 未结 2 1185
猫巷女王i
猫巷女王i 2020-12-06 15:21

Consider an ASP.NET MVC application using the Salt parameter in the [ValidateAntiForgeryToken] directive.

The scenario is such that the app

2条回答
  •  囚心锁ツ
    2020-12-06 15:53

    The Salt property is meant to be a compile-time constant. It's simply a way to link a particular form to a particular action method. For example, if you have a login form, you may wish to use the salt "Login" for this form so that a token that was valid for the login form can't be used for the change password form, etc.

    In all cases, the app's machine key is automatically used as an additional salt value. So an anti-XSRF token for one application can't be used for another application, even if both salt values read "Login". The machine key is settable in the Web.config section.

提交回复
热议问题