Exemple #1
0
        public AntiForgeryToken GetCookieToken(HttpRequestMessage httpContext)
        {
            CookieHeaderValue cookie      = httpContext.Headers.GetCookies(m_config.CookieName).FirstOrDefault();
            string            cookieValue = cookie?[m_config.CookieName].Value;

            if (string.IsNullOrEmpty(cookieValue))
            {
                return(null);
            }

            return(AntiForgeryTokenSerializer.Deserialize(cookieValue));
        }
Exemple #2
0
        public AntiForgeryToken GetFormToken(HttpRequestMessage request)
        {
            PostData postData = request.GetPostData();

            string formValue = postData.FormData[m_config.FormFieldName];

            if (string.IsNullOrEmpty(formValue))
            {
                request.QueryParameters().TryGetValue(m_config.FormFieldName, out formValue);
            }

            if (string.IsNullOrEmpty(formValue))
            {
                return(null);
            }

            return(AntiForgeryTokenSerializer.Deserialize(formValue));
        }
Exemple #3
0
 private AntiForgeryToken DeserializeToken(string serializedToken)
 {
     return(!string.IsNullOrEmpty(serializedToken) ? AntiForgeryTokenSerializer.Deserialize(serializedToken) : null);
 }