sanic-security 1.16.7__py3-none-any.whl → 1.16.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sanic_security/authorization.py +1 -1
- sanic_security/oauth.py +3 -1
- {sanic_security-1.16.7.dist-info → sanic_security-1.16.8.dist-info}/METADATA +15 -26
- {sanic_security-1.16.7.dist-info → sanic_security-1.16.8.dist-info}/RECORD +7 -7
- {sanic_security-1.16.7.dist-info → sanic_security-1.16.8.dist-info}/WHEEL +1 -1
- {sanic_security-1.16.7.dist-info → sanic_security-1.16.8.dist-info}/LICENSE +0 -0
- {sanic_security-1.16.7.dist-info → sanic_security-1.16.8.dist-info}/top_level.txt +0 -0
sanic_security/authorization.py
CHANGED
sanic_security/oauth.py
CHANGED
@@ -149,7 +149,9 @@ async def oauth_revoke(request: Request, client: BaseOAuth2) -> dict:
|
|
149
149
|
token_info = await oauth_decode(request, client, False)
|
150
150
|
request.ctx.oauth["revoked"] = True
|
151
151
|
with suppress(RevokeTokenNotSupportedError):
|
152
|
-
await client.revoke_token(
|
152
|
+
await client.revoke_token(
|
153
|
+
token_info.get("access_token"), "access_token"
|
154
|
+
)
|
153
155
|
return token_info
|
154
156
|
except RevokeTokenError as e:
|
155
157
|
raise OAuthError(f"Failed to revoke access token {e.response.text}")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: sanic-security
|
3
|
-
Version: 1.16.
|
3
|
+
Version: 1.16.8
|
4
4
|
Summary: An async security library for the Sanic framework.
|
5
5
|
Author-email: Aidan Stewart <me@na-stewart.com>
|
6
6
|
Project-URL: Documentation, https://security.na-stewart.com/
|
@@ -30,15 +30,6 @@ Requires-Dist: cryptography; extra == "dev"
|
|
30
30
|
Provides-Extra: crypto
|
31
31
|
Requires-Dist: cryptography>=3.3.1; extra == "crypto"
|
32
32
|
|
33
|
-
<!-- PROJECT SHIELDS -->
|
34
|
-
<!--
|
35
|
-
*** I'm using markdown "reference style" links for readability.
|
36
|
-
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
|
37
|
-
*** See the bottom of this document for the declaration of the reference variables
|
38
|
-
*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.
|
39
|
-
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
|
40
|
-
-->
|
41
|
-
|
42
33
|
[](https://github.com/psf/black)
|
43
34
|
[](https://pepy.tech/project/sanic-security)
|
44
35
|
[](https://anaconda.org/conda-forge/sanic-security)
|
@@ -79,7 +70,7 @@ Requires-Dist: cryptography>=3.3.1; extra == "crypto"
|
|
79
70
|
## About The Project
|
80
71
|
|
81
72
|
Sanic Security is an authentication, authorization, and verification library designed for use with the
|
82
|
-
[Sanic](https://github.com/huge-success/sanic) framework.
|
73
|
+
[Sanic](https://github.com/huge-success/sanic) web app framework.
|
83
74
|
|
84
75
|
* OAuth2 integration
|
85
76
|
* Login, registration, and authentication with refresh mechanisms
|
@@ -94,16 +85,16 @@ Visit [security.na-stewart.com](https://security.na-stewart.com) for documentati
|
|
94
85
|
<!-- GETTING STARTED -->
|
95
86
|
## Getting Started
|
96
87
|
|
97
|
-
In order to get started, please install [PyPI](https://pypi.org/).
|
88
|
+
In order to get started, please install [PyPI](https://pypi.org/) (likely included with your Python build).
|
98
89
|
|
99
90
|
### Installation
|
100
91
|
|
101
|
-
* Install the Sanic Security
|
92
|
+
* Install the Sanic Security package.
|
102
93
|
```shell
|
103
94
|
pip3 install sanic-security
|
104
95
|
````
|
105
96
|
|
106
|
-
* Install the Sanic Security
|
97
|
+
* Install the Sanic Security package with the [cryptography](https://github.com/pyca/cryptography) dependency included.
|
107
98
|
|
108
99
|
If you're planning on encoding or decoding JWTs using certain digital signature algorithms (like RSA or ECDSA which use
|
109
100
|
the public secret and private secret), you will need to install the `cryptography` library. This can be installed explicitly, or
|
@@ -113,7 +104,7 @@ as an extra requirement.
|
|
113
104
|
pip3 install sanic-security[crypto]
|
114
105
|
````
|
115
106
|
|
116
|
-
* Install the Sanic Security
|
107
|
+
* Install the Sanic Security package with the [httpx-oauth](https://github.com/frankie567/httpx-oauth) dependency included.
|
117
108
|
|
118
109
|
If you're planning on utilizing OAuth, you will need to install the `httpx-oauth` library. This can be installed explicitly, or
|
119
110
|
as an extra requirement.
|
@@ -130,8 +121,7 @@ pip3 install sanic-security --upgrade
|
|
130
121
|
|
131
122
|
### Configuration
|
132
123
|
|
133
|
-
Sanic Security configuration is merely an object that can be modified either using dot-notation or like a
|
134
|
-
dictionary.
|
124
|
+
Sanic Security configuration is merely an object that can be modified either using dot-notation or like a dictionary.
|
135
125
|
|
136
126
|
For example:
|
137
127
|
|
@@ -139,7 +129,7 @@ For example:
|
|
139
129
|
from sanic_security.configuration import config as security_config
|
140
130
|
|
141
131
|
security_config.SECRET = "This is a big secret. Shhhhh"
|
142
|
-
security_config["CAPTCHA_FONT"] = "
|
132
|
+
security_config["CAPTCHA_FONT"] = "resources/captcha-font.ttf"
|
143
133
|
```
|
144
134
|
|
145
135
|
You can also use the update() method like on regular dictionaries.
|
@@ -176,8 +166,7 @@ You can load environment variables with a different prefix via `security_config.
|
|
176
166
|
|
177
167
|
## Usage
|
178
168
|
|
179
|
-
Sanic Security's authentication and verification functionality is session based. A new session will be created for the user after the user logs in or requests some form of verification (two-step, captcha). The session data is then encoded into a JWT and stored on a cookie on the user’s browser. The session cookie is then sent
|
180
|
-
along with every subsequent request. The server can then compare the session stored on the cookie against the session information stored in the database to verify user’s identity and send a response with the corresponding state.
|
169
|
+
Sanic Security's authentication and verification functionality is session based. A new session will be created for the user after the user logs in or requests some form of verification (two-step, captcha). The session data is then encoded into a JWT and stored on a cookie on the user’s browser. The session cookie is then sent along with every subsequent request. The server can then compare the session stored on the cookie against the session information stored in the database to verify user’s identity and send a response with the corresponding state.
|
181
170
|
|
182
171
|
* Initialize Sanic Security as follows:
|
183
172
|
```python
|
@@ -267,7 +256,7 @@ async def on_oauth_token(request):
|
|
267
256
|
|
268
257
|
## Authentication
|
269
258
|
|
270
|
-
* Registration (
|
259
|
+
* Registration (with two-step account verification)
|
271
260
|
|
272
261
|
Phone can be null or empty.
|
273
262
|
|
@@ -310,7 +299,7 @@ async def on_verify(request):
|
|
310
299
|
)
|
311
300
|
```
|
312
301
|
|
313
|
-
* Login (
|
302
|
+
* Login (with two-factor authentication)
|
314
303
|
|
315
304
|
Credentials are retrieved via header are constructed by first combining the username and the password with a colon
|
316
305
|
(aladdin:opensesame), and then by encoding the resulting string in base64 (YWxhZGRpbjpvcGVuc2VzYW1l).
|
@@ -399,7 +388,7 @@ async def on_authenticate(request):
|
|
399
388
|
return response
|
400
389
|
```
|
401
390
|
|
402
|
-
* Requires Authentication (
|
391
|
+
* Requires Authentication (this method is not called directly and instead used as a decorator)
|
403
392
|
|
404
393
|
```python
|
405
394
|
@app.post("api/security/auth")
|
@@ -450,7 +439,7 @@ async def on_captcha(request):
|
|
450
439
|
return json("Captcha attempt successful!", captcha_session.json)
|
451
440
|
```
|
452
441
|
|
453
|
-
* Requires CAPTCHA (
|
442
|
+
* Requires CAPTCHA (this method is not called directly and instead used as a decorator)
|
454
443
|
|
455
444
|
| Key | Value |
|
456
445
|
|-------------|--------|
|
@@ -511,7 +500,7 @@ async def on_two_step_verification(request):
|
|
511
500
|
return response
|
512
501
|
```
|
513
502
|
|
514
|
-
* Requires Two-step Verification (
|
503
|
+
* Requires Two-step Verification (this method is not called directly and instead used as a decorator)
|
515
504
|
|
516
505
|
| Key | Value |
|
517
506
|
|----------|--------|
|
@@ -564,7 +553,7 @@ async def on_check_perms(request):
|
|
564
553
|
return json("Account is authorized.", authentication_session.json)
|
565
554
|
```
|
566
555
|
|
567
|
-
* Require Permissions (
|
556
|
+
* Require Permissions (this method is not called directly and instead used as a decorator.)
|
568
557
|
|
569
558
|
```python
|
570
559
|
@app.post("api/security/perms")
|
@@ -1,17 +1,17 @@
|
|
1
1
|
sanic_security/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
sanic_security/authentication.py,sha256=APs_YkwQCAEKyQo76ukKazQLGcm9fYrve6CUNxK2yKU,13201
|
3
|
-
sanic_security/authorization.py,sha256=
|
3
|
+
sanic_security/authorization.py,sha256=Hj1TXWppq7KDH-BQXFNihpZTbaimxnVCbif_Zb5W1bA,8232
|
4
4
|
sanic_security/configuration.py,sha256=2kWC4CZXvWR1wtBaqkMl58IA0VzxhI2ZbBTqd7LS_fE,6305
|
5
5
|
sanic_security/exceptions.py,sha256=b_E6wbbtk9ziFfH3jZstp2E01hTm6V1yjTltANYAuMY,5582
|
6
6
|
sanic_security/models.py,sha256=B6ZLvLqdn7ZWn1VjOylQN4ecGRfdGbtBrScVJmzIg_o,22097
|
7
|
-
sanic_security/oauth.py,sha256=
|
7
|
+
sanic_security/oauth.py,sha256=X1fx5KwvtWOa9ABGj7-MZ82ztlVeEuDz55yOh1Vtkes,8405
|
8
8
|
sanic_security/utils.py,sha256=WlPOEEQGcfZk-GbPNu6OiysNXAo9mw80TitDV7XxWMc,3762
|
9
9
|
sanic_security/verification.py,sha256=vr_64HLC7TfOwhki7B4Xn3XQJ0V6OoVgh8fR4DISZ44,8085
|
10
10
|
sanic_security/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
sanic_security/test/server.py,sha256=bVltV-AB_CEz9xrnVIft88FU6IYPgOOWuoSHDijeTDs,13717
|
12
12
|
sanic_security/test/tests.py,sha256=YXyn9aJmYg7vCjUuAs8FcI_lGIgzhmMe4AYTzu47_18,22618
|
13
|
-
sanic_security-1.16.
|
14
|
-
sanic_security-1.16.
|
15
|
-
sanic_security-1.16.
|
16
|
-
sanic_security-1.16.
|
17
|
-
sanic_security-1.16.
|
13
|
+
sanic_security-1.16.8.dist-info/LICENSE,sha256=sXlJs9_mG-dCkPfWsDnuzydJWagS82E2gYtkVH9enHA,1100
|
14
|
+
sanic_security-1.16.8.dist-info/METADATA,sha256=Ny74Sp3qqXu4piV_7DxNEOzQObdv6rwBOteQ5Epn6GQ,25622
|
15
|
+
sanic_security-1.16.8.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
16
|
+
sanic_security-1.16.8.dist-info/top_level.txt,sha256=ZybkhHXSjfzhmv8XeqLvnNmLmv21Z0oPX6Ep4DJN8b0,15
|
17
|
+
sanic_security-1.16.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|