djangosnippets.org: Latest snippets tagged with 'https'https://djangosnippets.org/tags/https/2012-10-19T11:12:48.629453-05:00HTTPS redirections middleware with updated URL template tag
2012-10-19T11:12:48.629453-05:00xlqhttps://djangosnippets.org/snippets/2833/<p>This middleware redirects HTTP requests to HTTPS for some specified URLs, in the same way as <a href="http://djangosnippets.org/snippets/85/">85</a>. It also changes the <code>url</code> template tag to use the <code>https</code> scheme for the same URLs. For example, if you have the following URL pattern:</p>
<pre><code>url(r'^accounts/login/$', 'django.contrib.auth.views.login', {'https': True})
</code></pre>
<p>then the template: …</p>
Freely redistributableTLS(SSL) middleware, per URL pattern or whole site
2010-12-01T08:46:29.250707-06:00robmadolehttps://djangosnippets.org/snippets/2282/<p>Allows url patterns to include a boolean indicating whether a view requires
TLS(SSL). The accompanying middleware handles the redirects needed to make
sure that it upholds this requirement.
</p>
<p><strong>WARNING</strong>: this monkey-patches some Django internals and is difficult to test
since Django's TestClient does not support TLS. If you use …</p>
Freely redistributableFake SSL Middleware for Tests and Local Development
2010-05-05T17:19:15.980802-05:00DrMeershttps://djangosnippets.org/snippets/2009/<p>Add <code>FakeSSLMiddleware</code> to the top of your <code>MIDDLEWARE_CLASSES</code> stack when running tests or developing locally to allow https:// links to operate correctly. Can be used in conjunction with other SSL middleware to allow critical tests to be performed.</p>
Freely redistributableSSL / HTTPS Middleware for Redirection and href Rewriting
2010-04-27T18:39:18.203132-05:00DrMeershttps://djangosnippets.org/snippets/1999/<p>See docstrings for details. To use, add to <code>MIDDLEWARE_CLASSES</code> in <code>settings.py</code>, and in your <code>views.py</code>:
</p>
<ol>
<li>
<code>from path.to.this.middleware import secure</code>
</li>
<li>
Decorate SSL views with <code>@secure</code>
</li>
</ol>
Freely redistributableWebFaction fixes middleware
2009-08-28T15:50:56.812936-05:00spookylukeyhttps://djangosnippets.org/snippets/1706/<p>On WebFaction, each host has it's own Apache instance, with WebFaction's main Apache instance forwarding requests. This is very useful but means that some of the original information is lost. This middleware should be installed at the top of your list to restore this lost info.</p>
<p>It includes the functionality …</p>
Freely redistributableifsecure
2007-12-24T15:17:50.370872-06:00kyprizelhttps://djangosnippets.org/snippets/522/<p>In some cases we need to know if we were opened via https from template.</p>
<p>Usage:
{% ifsecure %}using https{% else %}not using https{% endifsecure %}</p>
<p>If you use fastcgi fastcgi_param HTTPS must exists.</p>
Freely redistributable