diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-11-10 21:15:11 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-11-10 21:15:11 -0800 |
commit | 5ac3804dcd815e6b2aeba79c7faecdcd3649d73d (patch) | |
tree | 06d0376b8fa18d689760687d877ea6d4871ea494 /projecttemplates/WebFormsRelyingParty/Code/Utilities.cs | |
parent | 8576d3e52d930d4a784ba26ecfba9b79ecef2076 (diff) | |
download | DotNetOpenAuth-5ac3804dcd815e6b2aeba79c7faecdcd3649d73d.zip DotNetOpenAuth-5ac3804dcd815e6b2aeba79c7faecdcd3649d73d.tar.gz DotNetOpenAuth-5ac3804dcd815e6b2aeba79c7faecdcd3649d73d.tar.bz2 |
Removed magic string.
Diffstat (limited to 'projecttemplates/WebFormsRelyingParty/Code/Utilities.cs')
-rw-r--r-- | projecttemplates/WebFormsRelyingParty/Code/Utilities.cs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/projecttemplates/WebFormsRelyingParty/Code/Utilities.cs b/projecttemplates/WebFormsRelyingParty/Code/Utilities.cs index b9c9f43..5bf803d 100644 --- a/projecttemplates/WebFormsRelyingParty/Code/Utilities.cs +++ b/projecttemplates/WebFormsRelyingParty/Code/Utilities.cs @@ -12,6 +12,7 @@ namespace WebFormsRelyingParty.Code { using System.Web; public static class Utilities { + private const string csrfCookieName = "CsrfCookie"; private static readonly RandomNumberGenerator CryptoRandomDataGenerator = new RNGCryptoServiceProvider(); public static string ApplicationRoot { @@ -34,7 +35,7 @@ namespace WebFormsRelyingParty.Code { string secret = Convert.ToBase64String(randomData); // Send the secret down as a cookie... - var cookie = new HttpCookie("CsrfCookie", secret) { + var cookie = new HttpCookie(csrfCookieName, secret) { Path = HttpContext.Current.Request.Path, HttpOnly = true, Expires = DateTime.Now.AddMinutes(30), @@ -46,7 +47,7 @@ namespace WebFormsRelyingParty.Code { } public static void VerifyCsrfCookie(string secret) { - var cookie = HttpContext.Current.Request.Cookies["CsrfCookie"]; + var cookie = HttpContext.Current.Request.Cookies[csrfCookieName]; if (cookie != null) { if (cookie.Value == secret) { // Valid CSRF check. Clear the cookie and return. |