Commit Graph

37 Commits

Author SHA1 Message Date
Ryan Brandenburg bb52bcf11b Set 2.0 baselines 2018-03-21 14:54:59 -07:00
Artak Mkrtchyan 18bd033d8e Removed unnecessary comment 2018-01-22 18:10:01 -08:00
Artak Mkrtchyan 763393efc4 Added a test verifying that the cache headers are not set after the response has started. 2018-01-22 17:51:13 -08:00
Kiran Challa d2c27104dd Throwing AntiforgeryValidationException for failure to deserializing tokens 2018-01-10 15:03:54 -08:00
Kiran Challa 12e9430d89 Sets the default cookie secure policy to None 2017-08-30 10:25:14 -07:00
Nate McMaster df41fd8ccc Replace the ConfigureCookieOptions action property with the CookieBuilder 2017-06-30 15:18:40 -07:00
John Luo 5870fce035 Add configure delegate for CookieOptions
- allows configuration of CookieOptions such as SameSite without explicit duplication of the option on AntiforgeryOptions
2017-06-02 14:35:22 -07:00
Pranav K 6986ab3a0f Change TFM to netcoreapp2.0 2017-05-05 10:33:07 -07:00
Pranav K c3d312b0b0 Remove net451 as a cross-compile target 2017-03-23 10:32:42 -07:00
Kiran Challa f31c302e5c Converted test project to run on netcoreapp2.0 2017-03-22 15:42:53 -07:00
Doug Bunting 221c582a6f Bump test projects up to .NET 4.5.2
- aspnet/Testing#248
- xUnit no longer supports .NET 4.5.1
- build tests for desktop .NET only on Windows
2017-02-14 12:11:52 -08:00
Kiran Challa cd4afdc083 [Fixes #116] Set 'no-store' also in Cache-Conrol header 2017-01-26 12:56:15 -08:00
Kiran Challa a5c0e505c1 Fix cookie from being set to empty pathbase
Found with issue: https://github.com/aspnet/Mvc/issues/5512
2016-11-08 12:25:18 -08:00
Kiran Challa 3fc090e2fe [Fixes #105] Disable caching when response uses antiforgery 2016-11-02 16:16:06 -07:00
Kiran Challa 08cb67b7e4 [Fixes #104] Expose cookie options via Antiforgery options 2016-11-02 11:03:23 -07:00
Kiran Challa ad90db343c [Fixes #101] Cookie path is always / in IIS 2016-09-13 13:58:02 -07:00
Pranav K d529378a46 Updating to RTM builds of dotnet-test-xunit and Moq 2016-06-29 12:32:06 -07:00
Kiran Challa 3595452af7 Change priority for request token source lookup. Header token now takes priority over form field token. 2016-05-18 17:03:20 -07:00
Ryan Brandenburg eabe83a72d Prevent null-ref and log exceptions form Serializer 2016-04-18 15:55:27 -07:00
Ryan Brandenburg fd81151d31 Preserve X-Frame-Options if it was already set 2016-04-18 14:27:06 -07:00
Kiran Challa 330200874d Changed DNX451 references to NET451 2016-04-08 15:04:49 -07:00
Ryan Nowak 37c8f5de70 Revert "Add antiforgery middleware"
This reverts commit 4629148519.
2016-04-01 09:10:33 -07:00
Doug Bunting 65a2b8d25b React to HttpAbstractions namespace changes
- aspnet/HttpAbstractions#549 and aspnet/HttpAbstractions#592
- clean up `using`s
2016-03-30 16:13:12 -07:00
ryanbrandenburg 94cefde3ec Make IAntiforgeryContextAccessor a Feature 2016-03-23 14:35:26 -07:00
jacalvar c237f8989a React to changes in DataProtection 2016-03-15 16:26:57 -07:00
John Luo 91b955e080 Update cookie name 2016-03-03 22:48:13 -08:00
Ryan Nowak 4629148519 [Design] Add antiforgery middleware
This new middleware participates in authentication and acts as a filter
when the request doesn't include a valid CSRF token for a POST.

Any authentication middleware that you want to validate an antiforgery
token should go ahead of this middleware in the pipeline (Cookies,
IISIntegration). This also takes care of automatic auth (Windows) done by
weblistener.

Any authentication middleware that you want to ignore antiforgery should
go after this middleware in the pipeline.

To facilitate this, there are a few changes in the antiforgery API
surface. Namely we can now pass in a principal to validate tokens. You
can't pass in a principal to generate tokens - we expect you to be logged
in at that poing. Also, ValidateRequestAsync(...) now checks the HTTP verb
and won't validate GETs and such.
2016-02-24 15:04:09 -08:00
Ajay Bhargav Baaskaran 220479c1a1 [Fixes #30] Updated UID generation in DefaultClaimUidExtractor 2016-02-16 10:14:52 -08:00
Ryan Nowak ac107b5371 Make IsRequestValid check HTTP method
This code was popping up everywhere this method is called. Seems bad to
duplicate it. Really what the caller wants to know is 'is the request
valid or a potential CSRF exploit?'. This gets the API closer to that.
2016-02-12 16:52:25 -08:00
Doug Bunting c85badcf71 Fix bad merge
- not exactly logging at the right spot in `GetAndStoreTokens()`
- test helpers were creating two separate `ServiceCollections`
 - also didn't compile!
2016-02-09 16:43:01 -08:00
Doug Bunting 73695fc443 Serialize cookie token at most once
- #23 part 3
- `Get[AndStore]Tokens()` would deserialize cookie token from request even if `IsRequestValidAsync()` already had
- `GetAndStoreTokens()` serialized an old (never saved) cookie token once and a new one twice

- refactor serialization from `DefaultAntiforgeryTokenStore` to `DefaultAntiforgery`
 - divide responsibilities and ease overall fix
- above refactoring took `IAntiforgeryContextAccessor` responsibilities along to `DefaultAntiforgery` as well
 - store all tokens in `IAntiforgeryContextAccessor` to avoid repeated (de)serializations
 - remove `AntiforgeryTokenSetInternal`

nits:
- bit more parameter renaming to `httpContext`
- remove argument checks in helper methods
 - did _not_ do a sweep through the repo; just files in this PR
2016-02-09 15:29:04 -08:00
ryanbrandenburg c8a9ecc0c1 * Add logging to Antiforgery 2016-02-09 09:27:51 -08:00
Doug Bunting 08cf13b870 Remove `ValidateTokens()` from `IAntiforgery`
- `IAntiforgery` does not expose a way to get an invalid `AntiforgeryTokenSet`
2016-02-05 12:16:10 -08:00
Ryan Nowak 33e3001d53 Remove GetHtml
It's being moved to MVC
2016-02-04 11:22:26 -08:00
Ryan Nowak 3a2d09b066 Move exceptions from the store to the facade
My earlier change to add TryValidateRequestAsync didn't go far enough,
because the store will still throw when the tokens aren't present. This
change is to make the store just return null tokens in these cases, and
move the exceptions to DefaultAntiforgery.
2016-02-04 11:11:45 -08:00
Doug Bunting c91f0ee667 Clean up some tests
- avoid mocking `HttpContext`
- change `DefaultAntiforgeryTest` to mock token generators consistently
2016-02-04 10:11:05 -08:00
Doug Bunting 705c080d3b Move Antiforgery implementation details to `.Internal`
- leave `IAntiforgery`, `IAntiforgeryAdditionalDataProvider` and related bits behind
2016-02-03 15:39:33 -08:00