Django项目的CTX防御侧通道攻击的简单集成。
django-ctx的Python项目详细描述
django-django-django-django-django-django-ctx安全防范系统的集成集成集成是django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-django-dpip``:
```sh
pip安装django ctx
```
配置
==
-将ctx添加到您的*已安装的应用程序*设置:
``python
installed的应用程序=(
…
'django-ctx',
)
````
-ctx处理模板请求的*上下文*,这是使用
*上下文处理器*实现的。将CTX处理器添加到*上下文处理器*设置:
``python
context处理器=(
…
'django-ctx.context-处理器.ctx-protect,
)
````
<基本用法
===
>
>
=
=
``ctx标签库加载CTX标签库:
``html
{%loadctx标签标签%}
```
<<
<<
-使用*CTX_protect*标记在机密:
``html
{%ctx_protect secret origin alphabet%}
```
*secret*是包含需要保护的机密的字符串,*origin*
是唯一标识机密的ctx来源的字符串。*alphabet*是一个可选参数,用于定义机密所属的字母表默认值
为“ASCII”,它指的是[ASCII
可打印的](https://docs.python.org/2/library/string.html\string.printable)字符。
-添加*ctx\u置换*标记,以包括每个
源使用的置换:
``html
{%ctx\u置换%}
`````
所有首次使用原点的*ctx_protect*标记。建议在*<;/body>;*html标记之前包含
-在模板中包含ctx*客户端脚本:
``html
<;script src=“ctx.js”>;
````
示例
===
``html
<;!doctype html>;
<;html>;
<;head>;
<;meta charset=“utf-8”>;
<;title>;django ctx示例<;title>;
<;head>;
<;body>;
{%load ctx_tags%}
这是来自origin1的非常敏感的秘密:{%ctx_protect“my secret”“origin1”%}
这是来自origin2的另一个非常敏感的秘密:{%ctx_protect“my other secret”“origin2”“ascii_printable”%}
{%ctx_permutations%}
<;script src=“ctx.js”>;
<;body>;
<;html>;
```
```sh
pip安装django ctx
```
配置
==
-将ctx添加到您的*已安装的应用程序*设置:
``python
installed的应用程序=(
…
'django-ctx',
)
````
-ctx处理模板请求的*上下文*,这是使用
*上下文处理器*实现的。将CTX处理器添加到*上下文处理器*设置:
``python
context处理器=(
…
'django-ctx.context-处理器.ctx-protect,
)
````
<基本用法
===
>
>
=
=
``ctx标签库加载CTX标签库:
``html
{%loadctx标签标签%}
```
<<
<<
-使用*CTX_protect*标记在机密:
``html
{%ctx_protect secret origin alphabet%}
```
*secret*是包含需要保护的机密的字符串,*origin*
是唯一标识机密的ctx来源的字符串。*alphabet*是一个可选参数,用于定义机密所属的字母表默认值
为“ASCII”,它指的是[ASCII
可打印的](https://docs.python.org/2/library/string.html\string.printable)字符。
-添加*ctx\u置换*标记,以包括每个
源使用的置换:
``html
{%ctx\u置换%}
`````
所有首次使用原点的*ctx_protect*标记。建议在*<;/body>;*html标记之前包含
-在模板中包含ctx*客户端脚本:
``html
<;script src=“ctx.js”>;
````
示例
===
``html
<;!doctype html>;
<;html>;
<;head>;
<;meta charset=“utf-8”>;
<;title>;django ctx示例<;title>;
<;head>;
<;body>;
{%load ctx_tags%}
这是来自origin1的非常敏感的秘密:{%ctx_protect“my secret”“origin1”%}
这是来自origin2的另一个非常敏感的秘密:{%ctx_protect“my other secret”“origin2”“ascii_printable”%}
{%ctx_permutations%}
<;script src=“ctx.js”>;
<;body>;
<;html>;
```