Commit Graph

35 Commits

Author SHA1 Message Date
37a5e66403 Return a HttpResponse instead of an exception on NUL in query string parameters
Raising an exception triggers an email-to-admin-action, and the whole
reason we have this NUL check is to *avoid* triggering those emails...
Hopefully explicitly returning a 400 HttpResponse will maek them go
away.
2021-11-04 17:10:59 +01:00
379796952f Explicitly disallow NUL characters in URL parameters
This would already not work at a lower layer, but would typically
generate an internal server error exception instead of just an error
message.

Instead, put an explicit check in the middleware that's already
validating the query parameters and reject them with a 400 error.
2021-09-12 14:40:13 +02:00
50ef8dd63a Fix debug toolbar integration
This was broken when the querystring limiter was put in place
in 0724c08e40.
2021-03-24 19:27:09 +01:00
0724c08e40 Require explicit tagging on views taking query parameters
Require each view to declare which query parameters it wants, and filter
out any other parameters.

We have very few views that actually take query parameters, and random
additional query patterns will have no effect on the view. However, they
will break frontend caching (in making them look like different pages).

This will be extended into an implementation in the caching frontends as
well, btu it's needed in the backend to ensure that local testing will
have tbe same effect as the caches.
2021-02-22 10:43:59 +01:00
ec745db571 Allow additions to auto-generated xkey tags
If an xkey tag is already set on a response when it reaches the
middleware, add it to the set of automated xkeys generated from the
templates instead of overwriting it.
2020-11-23 11:58:51 +01:00
0387d17e2d Replace non-ascii chars in template names when building xkey
We don't have non-ascii characters in any of our correct URLs, but
people can still specify them on the URL. In this case the xkey isn't
going to match anything anyway, so it is not critical how we handle it,
especially since the generated page is going to be a 404 anyway. So just
use the simple built-in replace function.
2020-11-18 11:28:40 +01:00
95e4ef533d Add CSP for GTM. 2020-07-02 16:26:08 +01:00
e02761dfcf Middleware and urls update for django 2.2 2020-03-31 22:55:13 +02:00
a10eb6420b More generic changes from 2to3 2019-01-26 16:19:26 +01:00
b7f0398c15 Fix unicode for hashlib operations 2019-01-26 16:19:26 +01:00
0883ac6423 Fix whitespace and indentation, per pep8 2019-01-17 20:47:43 +01:00
87237f6536 Tabs, meet your new overlords: spaces
In a quest to reach pep8, use spaces to indent rather than tabs.
2019-01-17 15:35:39 +01:00
41f38d6105 Seems GA also needs data: urls sometimes 2019-01-17 10:29:06 +01:00
b2771a29bb Allow framing google.com on account signup page
This is used for the recaptcha. Also enable this for oauth signups,
previously missed.
2018-12-29 11:49:57 +01:00
97da9cb69c Allow data: url for image and fonts
Turns out data: is not included in "*" for images, so just add it. For
fonts, data: is used by google fonts.
2018-12-29 11:25:43 +01:00
0e8feb6afe Allow google analytics to do "connect" as well
Based on CSP reports collected
2018-12-29 11:18:05 +01:00
c1c40208ca Another try at fixing google analytics vs CSP 2018-12-22 16:24:10 +01:00
3606b102b0 Allow all of google-analytics in CSP
It needs a tleast both www.google-analytics and ssl.google-analytics..
2018-12-22 16:22:35 +01:00
d36ea4a985 Enable setting of security http headers
The following security policy headers are set:

X-XSS-Protection: 1; mode=block -- always set

X-Frame-Options: DENY is set for all pages except for the documentation
  pages, primarily because pgadmin4 loads them in an iframe which would
  break.

Content-Security-Policy: <x>-src
  Is set to allow the default of self only, then allowing scripts for
  google analytics and fonts for google fonts. Images are allowed from everywhere.
  frame-ancestors 'none' is set by the same rules as X-Frame-Options

This also adds a decorator for @script_sources to have a single view
allow extra sources, and this is used for recaptcha. A generic decorator
is also made for other types of exclusions, though we don't have any at
this point.

If the setting SECURITY_POLICY_REPORT_ONLY is set to True then the policy
will be report-only and not enforced (for testing), otherwise enforcing
mode is enabled.

The setting SECURITY_POLICY_REPORT_URI sets where to send security
policy reports, if any.
2018-12-21 21:46:28 +01:00
747cc8f06a Add support for doing ESI on pages in Varnish 2018-06-29 18:03:25 +02:00
dcd98cf6fe Add support for automatic template based xkey
This adds an xkey header to all outgoing requests with the hash of the
name of all templates loaded. In the future we will be able to use this
to purge "all pages that included a specific template", regardless of
where in the hierarchy it was loaded.

Do this by faking a template loader that never finds anything -- but it
will record the path of the template that it tried to load, and then
leave it to another template loader to actually load it. Store this in
thread local storage (it's a bit ugly, but it's the only thing Django
supports for storing things at the request level from a template
loader), and fetch it from the middleware.
2018-06-29 18:01:35 +02:00
0c6099e236 Remove unused imports 2018-06-29 13:40:04 +02:00
2f52c4f7c4 Clean up whitespace in primary Python / HTML files
Clean up the whitespace in the primary Python / HTML files in
order to make it easier to apply changes going forward.
2017-11-29 08:21:35 -05:00
3c089cd09a Remove SSL decorators and middleware
The site is now served regardless of SSL, and assumes that the webserver
or web cache ensures that things rae always SSL.
2016-05-24 21:13:00 +02:00
753d20545a Remove SSL optional tag 2016-05-24 21:13:00 +02:00
b1ae5f8ec0 Remove workaround for django bug #15152.
This bug is fixed before django 1.8, so remove our workaround which
should now be unnecessary.
2016-05-19 14:23:52 -04:00
385dd66a7c Remove workaround for persistent admin filters
Persistent admin filters are fixed in django 1.8
2016-05-19 14:23:47 -04:00
596520ba13 Implement workaround for django bug #15152 for badly encoded URLs
Hopefully this will stop the system spamming us..
2014-06-03 09:26:48 +02:00
048a17ae4b Don't redirect dynamic CSS from https to http
This can break things (d'uh).

Do this by introducing a new decorator, @ssl_optional. When this is
present, no SSL redirection will happen, regardless of whether the
access comes in over http or https.

This decorator overrides @ssl_required, but for redability's sake,
never use both at the same time.
2014-01-02 12:00:32 +01:00
756aa6ffbe Clean up imports
Remove unused imports and some other completely unused code.
2014-01-01 15:42:30 +01:00
5a4e2ea792 Make filters in admin be sticky, according to:
http://code.djangoproject.com/ticket/3777
2013-01-30 11:41:14 +01:00
557c44fab5 Update @ssl_required decorator to play nice with other decorators
The decorator now retains all attributes of the original view and adds a
new 'view.ssl_required = True' attribute.
2012-11-11 16:07:05 +01:00
4936664ddb Enforce redirection of /admin/ to https in the django code instead,
seems impossible to get it working properly in the webserver...
2010-06-09 19:47:27 +02:00
5f619889d7 Make https redirection work again.
Add a way to skip https redirection, so we can still run it locally,
and mark a couple of forms as requiring https.
2009-09-16 15:46:17 +02:00
90b758c247 A first very basic import.
Contains basic functionality, and an import of most of the static content
from the old site.

There is still plenty more to do...
2009-09-14 14:39:25 +02:00