A simple integration of the CTX defense against side-channel attacks for Flask projects.
Project description
flask-ctx
==============
A simple integration of the CTX defense against side-channel attacks for Flask projects.
Requirements
============
- Python 2.5+
- Flask 0.10+
- ctx-defense
Installation
============
- Install the latest stable version using ``pip``:
```sh
pip install flask-ctx
```
Configuration
=============
- Import the *ctx_processor* function from ctx's context processors:
```python
from flask_ctx.context_processors import ctx_processor
```
- Add the *ctx_processor* in the application's context processors:
```python
app.context_processor(ctx_processor)
```
Basic Usage
===========
- Use the *ctx_protect* function 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 the [ASCII_printable](https://docs.python.org/2/library/string.html#string.printable) characters.
- Add the *ctx_permutations* function to include the used permutations for each
origin:
```html
{{ ctx_permutations() }}
```
The *ctx_permutations* function needs to run after all *ctx_protect* calls
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>flask-ctx Example</title>
</head>
<body>
This is a very sensitive secret: {{ ctx_protect("a secret", "origin1") }}
This is another very sensitive secret: {{ ctx_protect("another secret", "origin2") }}
{{ ctx_permutations() }}
<script src="ctx.js"></script>
</body>
</html>
```
==============
A simple integration of the CTX defense against side-channel attacks for Flask projects.
Requirements
============
- Python 2.5+
- Flask 0.10+
- ctx-defense
Installation
============
- Install the latest stable version using ``pip``:
```sh
pip install flask-ctx
```
Configuration
=============
- Import the *ctx_processor* function from ctx's context processors:
```python
from flask_ctx.context_processors import ctx_processor
```
- Add the *ctx_processor* in the application's context processors:
```python
app.context_processor(ctx_processor)
```
Basic Usage
===========
- Use the *ctx_protect* function 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 the [ASCII_printable](https://docs.python.org/2/library/string.html#string.printable) characters.
- Add the *ctx_permutations* function to include the used permutations for each
origin:
```html
{{ ctx_permutations() }}
```
The *ctx_permutations* function needs to run after all *ctx_protect* calls
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>flask-ctx Example</title>
</head>
<body>
This is a very sensitive secret: {{ ctx_protect("a secret", "origin1") }}
This is another very sensitive secret: {{ ctx_protect("another secret", "origin2") }}
{{ ctx_permutations() }}
<script src="ctx.js"></script>
</body>
</html>
```
Project details
Release history Release notifications | RSS feed
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
Close
Hashes for flask_ctx-1.0.0.dev20161104-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 657ebbcd5c92d42a5b5a0c7c875aff97bc77044ab2f76169e3fc37cc1462534a |
|
MD5 | 1ae7b11deefe4dae1896df476f1bdeb9 |
|
BLAKE2b-256 | 7be50103297d478e9c96bc462f6ee6ef16c3e7c591eceeb6bdba0e3a0865d830 |