Commit Graph

154 Commits

Author SHA1 Message Date
Tom Sydney Kerckhove
96a940b60c yesod-core: test for looping breadcrumbs 2021-05-20 14:25:17 +02:00
Michael Snoyman
e4cd44a4c7
Fix test suite for latest wai-extra (fixes #1711) 2020-12-14 11:29:11 +02:00
d86leader
e3528ad85d Add test for regression of mkYesod 2020-09-22 15:41:45 +07:00
d86leader
62b418a801 Add tests for mkYesod with polymorphic datatypes 2020-09-22 15:33:34 +07:00
Juan Paucar
c279547962 Remove unnecesary Typeable deriving 2020-01-17 11:48:58 -05:00
Evan Rutledge Borden
b50ca99566 Deprecate insecure JSON body functions
`parseJsonBody` and `requireJsonBody` do not require a mime type when
parsing `JSON` content. This leaves them open to CSRF. They are now
deprecated and `insecure` versions are added in their place. Consumers
are now given a proper choice between secure and insecure functions.

There is a potential attack vector in that the browser does not trigger
CORS requests for "simple requests", which includes POST requests that
are form or text content-types. An attacker can craft a form whose body
is valid JSON, and when a user visits attacker.com and submits that
form, it can be submitted to bank.com and bypass CORS.

Checking the content-type is application/json prevents this, because if
the content-type was set to application/json, then the browser would
send a CORS request—a preflight OPTIONS request to the server asking if
the current domain (and some other values) are whitelisted to send
requests to that server. If the server doesn't say attacker.com is
whitelisted, the browser will not send the real request to the server.
2019-01-24 09:12:48 -06:00
Michael Snoyman
c7e4dd0a1c
Fix test suite compilation on GHC 8.6.3 commercialhaskell/stackage#4319 2019-01-22 18:40:31 +02:00
Maximilian Tagher
c8974d81f9 Add functions to get and set values in the per-request caches
Closes #1572
2019-01-21 10:47:27 -08:00
Steven Leiva
4015ef2919 Set X-XSS-Protection to 1; mode=block. 2018-08-03 14:17:11 -05:00
Steven Leiva
266c436f18 selectRep chooses first rep if no matches found.
The `selectRep` documentation indicates that it choose the first
representation provided if no representation matches.

This was only partially correct, as `selectRep` required that no
representation matched **and** that the `Content-Type` header of the
response was empty.

This led to a problem because `defaultErrorhandler` relies on
`selectRep`, and when `selectRep` was unable to find a suitable
representation, it would "swallow" the original error that resulted in
`defaultErrorhandler` being called, and set a status 406 for all cases.
2018-07-19 21:32:02 -05:00
Michael Snoyman
12a2bb58e9 Add timeouts so stalling is more obvious 2018-06-19 09:52:20 +03:00
Michael Snoyman
fa8e1ac00f
Switch to SubHandlerFor
This is much more consistent than suddenly using a ReaderT for subsites.
Thanks to @jprider63 for the inspiration for this, I think it cleans
things up a lot!
2018-01-24 13:01:26 +02:00
Michael Snoyman
6830a9840c
Merge branch 'better-monads' into no-transformers 2018-01-17 06:43:52 +02:00
Michael Snoyman
60f65ed267
Cleanup warnings 2018-01-15 15:09:07 +02:00
Michael Snoyman
1a1cb8a45f
Drop mwc-random 2018-01-15 10:18:16 +02:00
Michael Snoyman
3e06942449
Simplify YesodSubDispatch 2018-01-11 23:13:32 +02:00
Michael Snoyman
fbccfe2306
Merge branch 'better-monads' into no-transformers 2018-01-11 22:49:02 +02:00
Michael Snoyman
103c098cf8
Catch up with Data.Conduit.Combinators 2018-01-10 12:16:31 -08:00
Michael Snoyman
a16e75249a
More moving over to unliftio 2017-12-31 09:20:02 +02:00
Michael Snoyman
61c887f501
Start converting yesod-auth over 2017-12-13 13:44:59 +02:00
Michael Snoyman
47ee7384ea
Be gone with ye HandlerT! 2017-12-13 09:53:14 +02:00
Ian Duncan
05b2193e9f
Code review fixes for #1444 2017-09-08 09:00:12 +09:00
Ian Duncan
fd872cff40
Add support to yesod-core for weak etags 2017-09-06 10:08:45 +09:00
Sibi Prabakaran
19ff5c2006
Fix warning in test code 2017-07-28 16:58:11 +05:30
Sibi Prabakaran
f3ed12ed81
Add additional test to make sure that header value is not lost 2017-07-13 12:43:16 +05:30
Sibi Prabakaran
051339f3dc
Add test code for HTTP headers properties 2017-07-13 11:05:57 +05:30
James Parker
6c7a40ea5b Adds curly brackets to route parser. 2017-03-22 18:30:08 -04:00
Michael Snoyman
3dc2d10b30 Compile with -Wall -Werror 2017-02-05 12:09:18 +02:00
Cthulhu
fbaf502858 cached and cachedBy will not overwrite global state changes 2016-08-28 19:02:11 +03:00
Maximilian Tagher
e6287362ad Default CSRF tokens to the root path "/"
* The default path of cookies is the current path making the request
  * e.g. an AJAX request made from http://example.com/foo/bar would be /foo
  * This causes multiple CSRF tokens to build up as you navigate a site
  * This will cause errors if the CSRF tokens have different values, and an invalid token is sent.
* Closes #1247
2016-08-16 07:25:41 -07:00
Michael Snoyman
f6891b0373 Merge branch 'BL/samesite' of https://github.com/bobjflong/yesod into bobjflong-BL/samesite 2016-08-10 15:17:25 +03:00
Mikkel Christiansen
50c4138a5c Take hlint suggestions. 2016-06-28 08:28:23 +02:00
Michael Snoyman
a3d9a13abe Proper handling of impure exceptions within HandlerError values 2016-06-22 18:24:18 +03:00
Bob Long
a797c2e5d4 Add laxSameSiteSessions and strictSameSiteSessions 2016-05-01 16:31:01 +01:00
Erik de Castro Lopo
226c381baa yesod-core: Make it work with ghc-8.0
Use CPP hackery to make it compile with ghc-8.0 and ghc 7.10. If
ghc-7.10 works, I assume earlier supported versions of GHC also
work. All tests pass with both GHC versions.

Unfortunately, the TH changes force changes in the type signature
of Yesod.Routes.TH.RenderRoute.mkRouteCons from:

    mkRouteCons :: [ResourceTree Type] -> ([Con], [Dec])

to

    mkRouteCons :: [ResourceTree Type] -> Q ([Con], [Dec])

and I can't see a way around that.
2016-04-19 14:52:03 +10:00
Anupam Jain
38680c6568 Add test for hierarchical subsite with arguments
Note: Needed to enable ViewPatterns for this
2016-01-19 17:06:40 +05:30
Anupam Jain
0d99f94e5a Add a testcase for nested subsites 2016-01-14 11:30:06 +05:30
Daniel Díaz
5375bacf81 Placed App after mkYesod in the RawResponse test. 2015-08-23 22:53:13 +02:00
Maximilian Tagher
33982b2112 Add CSRF protection functions/middleware that support AJAX requests 2015-08-17 16:52:39 -07:00
Patrick Boe
8b7c58f381 added functions to simplify application of an ssl-only policy to a site 2014-12-20 10:26:32 -05:00
Michael Snoyman
9a4348a0e3 Improve etag supported fpco/stackage-server#29 #868 #869 2014-11-19 11:03:55 +02:00
Greg Weber
898c0a1e18 test case for toWidget* functions 2014-10-27 21:16:03 -07:00
Michael Snoyman
972e117005 More efficient token generation
Old code would create a new System.Random generator each time, which
requires going to the system entropy store. New code caches an
mwc-random gen at startup.
2014-10-20 10:34:38 +03:00
Greg Weber
00b5781ec5 add cachedBy, like cached but adds a key
re-factored to a base implementation with
no Yesod dependencies in TypeCache.hs
2014-09-20 14:34:10 -07:00
Michael Snoyman
ccab062f2d Remove all conditional compilation for Yesod 1.4 release
Left in for GHC-bundled libraries (ghc, base, bytestring, binary)
2014-09-07 18:17:45 +03:00
Michael Snoyman
f779004d19 Merge yesod-routes into yesod-core entirely 2014-09-07 17:34:37 +03:00
Michael Snoyman
6eb1447dd9 Add missing LANGUAGE pragma 2014-08-27 08:15:47 +03:00
Michael Snoyman
c66ef04f17 Merge branch 'master' into yesod-1.4
Conflicts:
	yesod-form/Yesod/Form/Functions.hs
2014-08-25 20:20:16 +03:00
Michael Snoyman
a3ec07c359 Disable broken test 2014-08-23 21:50:38 +03:00
Michael Snoyman
21d1965774 Merge remote-tracking branch 'origin/master' into yesod-1.4 2014-06-15 15:49:51 +03:00