提交 4d106e87 编写于 作者: T tssujt

Proofread secure-connections section

上级 b1c650bf
......@@ -61,7 +61,7 @@
| [8 初始化数据库后端](zh/8.md) | [@ImPerat0R\_](https://github.com/tssujt) |
| [9 使用操作器](zh/9.md) | [@ImPerat0R\_](https://github.com/tssujt) |
| [10 管理连接](zh/10.md) | [@ImPerat0R\_](https://github.com/tssujt) |
| [11 保护连接](zh/11.md) | |
| [11 保护连接](zh/11.md) | [@ImPerat0R\_](https://github.com/tssujt) |
| [12 写日志](zh/12.md) | |
| [13 用Celery扩大规模](zh/13.md) | |
| [14 用Dask扩展](zh/14.md) | |
......
# 保护连接
默认情况下,Airflow将在元数据数据库中以纯文本格式保存连接的密码。 在安装过程中强烈建议使用`crypto`包。 `crypto`包确实要求您的操作系统安装了libffi-dev。
默认情况下,Airflow在元数据数据库中是以纯文本格式保存连接的密码。在安装过程中强烈建议使用`crypto`包。`crypto`要求您的操作系统安装了libffi-dev。
如果最初未安装`crypto`软件包,您仍可以通过以下步骤为连接启用加密:
1. 安装crypto包`pip install apache-airflow[crypto]`
2. 使用下面的代码片段生成fernet_key。 fernet_key必须是base64编码的32字节密钥。
1. 安装crypto包`pip install apache-airflow[crypto]`
2. 使用下面的代码片段生成fernet_key。 fernet_key必须是base64编码的32字节密钥。
```
from cryptography.fernet import Fernet
fernet_key = Fernet . generate_key ()
print ( fernet_key . decode ()) # your fernet_key, keep it in secured place!
from cryptography.fernet import Fernet
fernet_key= Fernet.generate_key()
print(fernet_key.decode()) # 你的fernet_key,把它放在安全的地方
```
3.`airflow.cfg` fernet_key值替换为步骤2中的值。或者,可以将fernet_key存储在OS环境变量中。 在这种情况下,您不需要更改`airflow.cfg` ,因为Airflow将使用环境变量而不是`airflow.cfg`中的值:
3.`airflow.cfg`中的fernet_key值替换为步骤2中的值。或者,可以将fernet_key存储在OS环境变量中。在这种情况下,您不需要更改`airflow.cfg`,因为Airflow将使用环境变量而不是`airflow.cfg`中的值:
```
# Note the double underscores
EXPORT AIRFLOW__CORE__FERNET_KEY = your_fernet_key
# 注意双下划线
export AIRFLOW__CORE__FERNET_KEY=your_fernet_key
```
1. 重启Airflow网络服务器。
2. 对于现有连接(在安装`airflow[crypto]`和创建Fernet密钥之前已定义的连接),您需要在连接管理UI中打开每个连接,重新键入密码并保存。
\ No newline at end of file
1. 重启Airflow网络服务器。
2. 对于现有连接(在安装`airflow[crypto]`和创建Fernet密钥之前已定义的连接),您需要在连接管理UI中打开每个连接,重新键入密码并保存。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册