You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/docs/tutorial/security/oauth2-jwt.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,20 +64,20 @@ If your database is stolen, the thief won't have your users' plaintext passwords
64
64
65
65
So, the thief won't be able to try to use that password in another system (as many users use the same password everywhere, this would be dangerous).
66
66
67
-
## Install `passlib`
67
+
## Install `pwdlib`
68
68
69
-
PassLib is a great Python package to handle password hashes.
69
+
pwdlib is a great Python package to handle password hashes.
70
70
71
71
It supports many secure hashing algorithms and utilities to work with them.
72
72
73
-
The recommended algorithm is "Bcrypt".
73
+
The recommended algorithm is "Argon2".
74
74
75
-
Make sure you create a [virtual environment](../../virtual-environments.md){.internal-link target=_blank}, activate it, and then install PassLib with Bcrypt:
75
+
Make sure you create a [virtual environment](../../virtual-environments.md){.internal-link target=_blank}, activate it, and then install pwdlib with Argon2:
76
76
77
77
<divclass="termy">
78
78
79
79
```console
80
-
$ pip install "passlib[bcrypt]"
80
+
$ pip install "pwdlib[argon2]"
81
81
82
82
---> 100%
83
83
```
@@ -86,7 +86,7 @@ $ pip install "passlib[bcrypt]"
86
86
87
87
/// tip
88
88
89
-
With `passlib`, you could even configure it to be able to read passwords created by **Django**, a **Flask** security plug-in or many others.
89
+
With `pwdlib`, you could even configure it to be able to read passwords created by **Django**, a **Flask** security plug-in or many others.
90
90
91
91
So, you would be able to, for example, share the same data from a Django application in a database with a FastAPI application. Or gradually migrate a Django application using the same database.
92
92
@@ -96,15 +96,15 @@ And your users would be able to login from your Django app or from your **FastAP
96
96
97
97
## Hash and verify the passwords
98
98
99
-
Import the tools we need from `passlib`.
99
+
Import the tools we need from `pwdlib`.
100
100
101
-
Create a PassLib "context". This is what will be used to hash and verify passwords.
101
+
Create a PasswordHash instance with recommended settings — it will be used for hashing and verifying passwords.
102
102
103
103
/// tip
104
104
105
-
The PassLib context also has functionality to use different hashing algorithms, including deprecated old ones only to allow verifying them, etc.
105
+
pwdlib also supports the bcrypt hashing algorithm but does not include legacy algorithms — for working with outdated hashes, it is recommended to use the passlib library.
106
106
107
-
For example, you could use it to read and verify passwords generated by another system (like Django) but hash any new passwords with a different algorithm like Bcrypt.
107
+
For example, you could use it to read and verify passwords generated by another system (like Django) but hash any new passwords with a different algorithm like Argon2 or Bcrypt.
108
108
109
109
And be compatible with all of them at the same time.
Copy file name to clipboardExpand all lines: docs/ru/docs/tutorial/security/oauth2-jwt.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,28 +62,28 @@ $ pip install pyjwt
62
62
63
63
Таким образом, вор не сможет использовать этот пароль в другой системе (поскольку многие пользователи везде используют один и тот же пароль, это было бы опасно).
64
64
65
-
## Установка `passlib`
65
+
## Установка `pwdlib`
66
66
67
-
PassLib - это отличный пакет Python для работы с хэшами паролей.
67
+
pwdlib - это отличный пакет Python для работы с хэшами паролей, пришедший на замену passlib.
68
68
69
69
Он поддерживает множество безопасных алгоритмов хеширования и утилит для работы с ними.
70
70
71
-
Рекомендуемый алгоритм - "Bcrypt".
71
+
Рекомендуемый алгоритм - "Argon2".
72
72
73
-
Убедитесь, что вы создали и активировали виртуальное окружение, и затем установите PassLib вместе с Bcrypt:
73
+
Убедитесь, что вы создали и активировали виртуальное окружение, и затем установите pwdlib вместе с Argon2:
74
74
75
75
<divclass="termy">
76
76
77
77
```console
78
-
$ pip install "passlib[bcrypt]"
78
+
$ pip install "pwdlib[argon2]"
79
79
80
80
---> 100%
81
81
```
82
82
83
83
</div>
84
84
85
85
/// tip | Подсказка
86
-
С помощью `passlib` можно даже настроить его на чтение паролей, созданных **Django**, плагином безопасности **Flask** или многими другими библиотеками.
86
+
С помощью `pwdlib` можно даже настроить его на чтение паролей, созданных **Django**, плагином безопасности **Flask** или многими другими библиотеками.
87
87
88
88
Таким образом, вы сможете, например, совместно использовать одни и те же данные из приложения Django в базе данных с приложением FastAPI. Или постепенно мигрировать Django-приложение, используя ту же базу данных.
Импортируйте необходимые инструменты из `passlib`.
95
+
Импортируйте необходимые инструменты из `pwdlib`.
96
96
97
-
Создайте "контекст" PassLib. Именно он будет использоваться для хэширования и проверки паролей.
97
+
Создайте экземпляр `PasswordHash` с рекомендованными настройками — он будет использоваться для хэширования и проверки паролей.
98
98
99
99
/// tip | Подсказка
100
-
Контекст PassLib также имеет функциональность для использования различных алгоритмов хеширования, в том числе и устаревших, только для возможности их проверки и т.д.
100
+
pwdlib также имеет функциональность для использования алгоритма хэширования bcrypt, но не поддерживает старые алгоритмы — для работы с устаревшими хэшами рекомендуется использовать библиотеку passlib.
101
101
102
-
Например, вы можете использовать его для чтения и проверки паролей, сгенерированных другой системой (например, Django), но хэшировать все новые пароли другим алгоритмом, например Bcrypt.
102
+
Например, вы можете использовать его для чтения и проверки паролей, сгенерированных другой системой (например, Django), но хэшировать все новые пароли другим алгоритмом, например Argon2 или Bcrypt.
103
103
104
104
И при этом быть совместимым со всеми этими системами.
0 commit comments