Skip to main content

A simple integration of the CTX defense against side-channel attacks for Django projects.

Project description

django-ctx
==============

A simple integration of the CTX defense against side-channel attacks for Django projects.

Requirements
============

- Python 2.5+
- Django 1.9+
- ctx-defense

Installation
============

- Install the latest stable version using ``pip``:

```sh
pip install django-ctx
```

Configuration
=============

- Add ctx to your *INSTALLED_APPS* setting:
```python
INSTALLED_APPS = (
...
'django_ctx',
)
```

- Ctx processes the *context* for template requests, which is implemented using a
*context processor*. Add the ctx processor to your *context_processors* setting:
```python
context_processors = (
...
'django_ctx.context_processors.ctx_protect',
)
```

Basic Usage
===========

- Load the ctx tag library:
```html
{% load ctx_tags %}
```

- Use the *ctx_protect* tag to use ctx on secrets:
```html
{% ctx_protect secret origin alphabet %}
```

*secret* is a string containing the secret that needs to be protected and *origin*
is a string uniquely identifying the CTX origin for the secret. *alphabet* is
an optional argument to define the alphabet that the secret belongs to, default
being 'ASCII' which refers to the [ASCII
printable](https://docs.python.org/2/library/string.html#string.printable) characters.

- Add the *ctx_permutations* tag to include the used permutations for each
origin:
```html
{% ctx_permutations %}
```
The *ctx_permutations* tag needs to be included after all *ctx_protect* tags
that use an origin for the first time. It is proposed that it is included
before the *</body>* HTML tag.

- Include the ctx *client script* in the template:
```html
<script src="ctx.js"></script>
```

Example
=======
```html
<!DOCTYPE html>

<html>

<head>
<meta charset="utf-8">
<title>django-ctx Example</title>
</head>

<body>
{% load ctx_tags %}

This is a very sensitive secret from origin1: {% ctx_protect "my secret" "origin1" %}
This is another very sensitive secret from origin2: {% ctx_protect "my other secret" "origin2" "ASCII_printable" %}

{% ctx_permutations %}
<script src="ctx.js"></script>
</body>

</html>
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_ctx-1.0.0.dev20161104-py2.py3-none-any.whl (6.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django_ctx-1.0.0.dev20161104-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_ctx-1.0.0.dev20161104-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2bc997ae32b235f06c1ed60bd317a265b4650e3bbf1c4040e3378019a5dd1aa8
MD5 6ff6fe96928709727cae2d018a10c7f0
BLAKE2b-256 b9b9b7036e2f4ee26369a06855d9f7963cb93fcf79be0524d01e0888b0cb7fcc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page