Commit Graph

881 Commits

Author SHA1 Message Date
Andrei Mikhailov
c39b165ff3 increase the size of CSRF token 2020-05-01 00:40:11 -03:00
Ryan Scott
29a08425e9 Use DeriveLift to generate yesod-core's Lift instances
GHC 8.0 and later come with the `DeriveLift` extension for deriving
instances of `Language.Haskell.TH.Syntax.Lift`. `yesod-core` supports
GHC 8.2 and up, so it is able to make use of this. Not only does
`DeriveLift` make for much shorter code, but it also fixes warnings
that you get when compiling `yesod-core` with GHC 8.10 or later:

```
[20 of 31] Compiling Yesod.Routes.TH.Types ( src/Yesod/Routes/TH/Types.hs, interpreted )

src/Yesod/Routes/TH/Types.hs:34:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift (ResourceTree t)’
   |
34 | instance Lift t => Lift (ResourceTree t) where
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Yesod/Routes/TH/Types.hs:49:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift (Resource t)’
   |
49 | instance Lift t => Lift (Resource t) where
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Yesod/Routes/TH/Types.hs:59:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift (Piece t)’
   |
59 | instance Lift t => Lift (Piece t) where
   |          ^^^^^^^^^^^^^^^^^^^^^^^^

src/Yesod/Routes/TH/Types.hs:78:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift (Dispatch t)’
   |
78 | instance Lift t => Lift (Dispatch t) where
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

This is because `DeriveLift` fills in implementations of `liftTyped`,
a method that was introduced to `Lift` in `template-haskell-2.16.0.0`
(bundled with GHC 8.10).
2020-03-31 08:41:00 -04:00
Jezen Thomas
59f601a34c
Add functions for setting description and OG meta (#1663)
* Add functions for setting description and OG meta

It's common that a website author will want to add a specific
description and Open Graph image to a given page in their website. These
functions are simple conveniences to add these meta tags to the document
head.

I decided against simply adding all possible meta tags, because not all
of them are useful, and even in the case of Open Graph tags, many of
them should be set only once and they should use the same value for the
entire website. In those cases, it's probably better for the website
author to add those tags in their layout template.

Closes https://github.com/yesodweb/yesod/issues/1659
2020-03-30 19:00:24 +07:00
Michael Snoyman
9d0c9180b9
unliftio-core 0.2 2020-03-01 11:00:36 +02:00
Michael Snoyman
5943ee527d
Version bump 2020-01-27 17:52:24 +02:00
Simon Michael
dd649bf238 support template-haskell 2.16, build with GHC 8.10 2020-01-27 06:11:48 -08:00
Juan Paucar
6e38a3b99d Bump version properly 2020-01-20 11:06:35 -05:00
Juan Paucar
eb159b6fd5 Bump versions 2020-01-17 14:03:59 -05:00
Juan Paucar
c279547962 Remove unnecesary Typeable deriving 2020-01-17 11:48:58 -05:00
Michael Snoyman
804b114d91
Drop LTS 9 2020-01-07 13:36:58 +02:00
Maximilian Tagher
42d41f77de .. 2019-11-29 10:43:11 -05:00
Maximilian Tagher
0025226af6 Print preview of JSON body in case of parse failure 2019-11-28 22:33:00 -05:00
Michael Snoyman
463fd54c5a
Drop rio dep (fixes #1645) 2019-11-22 09:16:52 +02:00
Alexey Zabelin
19f4b26e1f
Add a warning about DB actions getting rolled back 2019-11-13 20:55:47 -08:00
Michael Snoyman
f054bac0e0
Version bump 2019-09-08 09:45:29 +03:00
Dan Burton
ed69d69347 Add new CPP branch for template-haskell >= 2.15 2019-09-06 13:04:21 -04:00
Jezen Thomas
46af7bfb76
Cleanup 2019-08-26 13:49:57 +02:00
Jezen Thomas
d1e4fd485b
Make jsAttributesHandler use jsAttributes
This addresses this comment:

https://github.com/yesodweb/yesod/pull/1622#discussion_r317467498
2019-08-26 12:05:30 +02:00
Jezen Thomas
59988f46a1
Add jsAttributesHandler
This adds `jsAttributesHandler` to run arbitrary Handler code before
building the attributes map for the script tag generated by `widgetFile`.
This is useful if you need to add a randomised nonce value to that tag.

Closes https://github.com/yesodweb/yesod/issues/1621
2019-08-23 21:57:48 +02:00
Jezen Thomas
d385ada853
Move JavaScript form submission to script block
If someone wants their website to score a good grade on a security
vulnerability scanner like Mozilla Observatory, they will need to enable
the Content Security Policy header. When using CSP, it is possible to
explicitly allow inline JavaScript in `<script>` tags by specifying the
sha256 of the snippet. However the same is _not_ true of any JavaScript
included in a HTML attribute like `onload`.

This changes moves the JavaScript form submission out of the `onload`
HTML attribute and into a `<script>` tag so the user can add the hash of
this script to their explicitly-allowed `script-src` list, and they can
avoid using undesirable CSP rules like `unsafe-inline`.

Without explicitly allowing this script when using CSP, the script would
fail and the user would have to click the button to continue.
2019-08-19 20:56:00 +02:00
Michael Snoyman
b5839420aa
Version bump 2019-04-13 22:01:17 +03:00
Steven Leiva
ab096c649c Introduce JSONResponse.
This data type allows us to return a domain type in our handlers, even
if we eventually want to send JSON to the client.

See: https://tech.freckle.com/2015/12/21/servant-style-handlers-for-yesod/
2019-04-12 16:13:53 -05:00
Grégoire Charvet 黑瓜
f1374c9140 add doc for maximumContentLength override 2019-03-17 09:10:07 +00:00
Grégoire Charvet 黑瓜
a691f49258 update changelog 2019-03-15 20:37:46 +00:00
Grégoire Charvet 黑瓜
48bfe0d573 maximumContentLengthIO 2019-03-15 20:35:39 +00:00
Michael Snoyman
c67c89007c
src subdir for yesod-core 2019-02-19 04:02:21 +02:00
Michael Snoyman
e5cc9987ae
Move from byteable to memory 2019-02-19 03:58:31 +02:00
nytopop
70b730cc4e
Use at most one valid session cookie per request
Makes `loadClientSession` ignore all sessions in a request if more than
a single session cookie decodes successfully. The prior behavior was to
merge all valid session cookies' values.

Bumps version to 1.6.12
2019-02-10 08:42:37 -08:00
Evan Rutledge Borden
da9e72b82f Add minor version bump to 1.6.11
JSON parsing function deprecations warrant a minor version bump.
2019-01-29 15:31:35 -06: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
2a9bef34c0 Add sendResponseNoContent. 2018-11-30 14:27:21 -06:00
Michael Snoyman
6eb91bdb77
Add missing test file (fixes #1563) 2018-10-15 16:21:17 +03:00
Jason Whittle
ee260e24cb Update changelog with a link to PR #1558. 2018-10-08 18:04:16 -04:00
Jason Whittle
ca602d11bf Bump minor version. 2018-10-08 16:56:20 -04:00
Jason Whittle
4e4efd1627 In the route syntax, allow trailing backslashes to indicate line continuation. 2018-10-08 16:47:06 -04:00
Michael Snoyman
6a9bcc292d
Remove unneeded version bumps 2018-10-08 10:20:49 +03:00
Michael Snoyman
55e0ca4bc3
Add PrimMonad instances
Pointed out at: https://stackoverflow.com/q/52692508/369198
2018-10-08 08:19:32 +03:00
Steven Leiva
4015ef2919 Set X-XSS-Protection to 1; mode=block. 2018-08-03 14:17:11 -05:00
Maximilian Tagher
1f05d2c72f
Explain how requireCheckJsonBody can prevent CSRF 2018-07-31 21:22:39 -07: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
182abd89bf
Drop some deps 2018-07-03 19:01:58 +03:00
Michael Snoyman
867e7c32dc
Clean up some CPP 2018-07-03 18:57:23 +03:00
Michael Snoyman
d38d00f114 Skip RawResponse tests on Windows #1523
These tests stall on Windows starting with network-2.6.3.4. I haven't
yet figured out why exactly that's the case, or a minimum repro.
2018-06-19 10:37:20 +03:00
Michael Snoyman
12a2bb58e9 Add timeouts so stalling is more obvious 2018-06-19 09:52:20 +03:00
Steven Leiva
a63bf16a68 defaultErrorHandler handles text/plain request. 2018-06-12 21:08:55 -05:00
ncaq
708648798e deleted: unneed cabal build-depends by weeder
[weeder: Detect dead code](https://hackage.haskell.org/package/weeder)

deleted depends is

* mime-mail
* wai-eventsource

I sort build-depends, because duplicate depend some exist, to sort is detect to easy.
2018-06-09 13:15:21 +09:00
ncaq
a8df3c48c2 modified: use sinkLazy and toStrict
Because performance problem.
2018-05-01 17:15:13 +09:00
ncaq
e664ae2e0e changed: use foldC 2018-04-24 12:55:55 +09:00