public RequestHeaders(IObjectConverter converter, IObjectResolver resolver, IRequestData requestData) { _converter = converter; _resolver = resolver; _values = requestData.ValuesFor(RequestDataSource.Header); }
public bool Validate(string salt) { var applicationPath = _fubuApplicationFiles.RootPath; var fieldName = _tokenProvider.GetTokenName(); var cookieName = _tokenProvider.GetTokenName(applicationPath); var cookie = _cookies.Get(cookieName); if (cookie == null || string.IsNullOrEmpty(cookie.Value)) { return(false); } var cookieToken = _serializer.Deserialize(HttpUtility.UrlDecode(cookie.Value)); var formValue = _requestData.ValuesFor(RequestDataSource.Header).Get(fieldName) as string ?? _requestData.ValuesFor(RequestDataSource.Request).Get(fieldName) as string; if (formValue.IsEmpty()) { return(false); } var formToken = _serializer.Deserialize(formValue); if (!string.Equals(cookieToken.Value, formToken.Value, StringComparison.Ordinal)) { return(false); } var currentUsername = AntiForgeryData.GetUsername(Thread.CurrentPrincipal); if (!string.Equals(formToken.Username, currentUsername, StringComparison.OrdinalIgnoreCase)) { return(false); } if (!string.Equals(salt ?? string.Empty, formToken.Salt, StringComparison.Ordinal)) { return(false); } return(true); }
public static string FindPath(IRequestData dictionary) { var routeData = dictionary.ValuesFor(RequestDataSource.Route); var list = new List<string>(); for (var i = 0; i < 10; i++) { routeData.Value("Part" + i, o => list.Add(o.RawValue.ToString())); } return list.Join("/"); }
public static string FindPath(IRequestData dictionary) { var routeData = dictionary.ValuesFor(RequestDataSource.Route); var list = new List <string>(); for (var i = 0; i < 10; i++) { routeData.Value("Part" + i, o => { if (o.RawValue != null) { list.Add(o.RawValue.ToString()); } }); } return(list.Join("/")); }
public IValueSource ValuesFor(string nameOrProvenance) { return(_inner.ValuesFor(nameOrProvenance)); }
public static IValueSource ValuesFor(this IRequestData request, RequestDataSource source) { return(request.ValuesFor(source.ToString())); }