sanic-security 1.16.0__py3-none-any.whl → 1.16.2__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/oauth.py +1 -35
- sanic_security/test/server.py +2 -2
- {sanic_security-1.16.0.dist-info → sanic_security-1.16.2.dist-info}/METADATA +7 -6
- {sanic_security-1.16.0.dist-info → sanic_security-1.16.2.dist-info}/RECORD +7 -7
- {sanic_security-1.16.0.dist-info → sanic_security-1.16.2.dist-info}/LICENSE +0 -0
- {sanic_security-1.16.0.dist-info → sanic_security-1.16.2.dist-info}/WHEEL +0 -0
- {sanic_security-1.16.0.dist-info → sanic_security-1.16.2.dist-info}/top_level.txt +0 -0
sanic_security/oauth.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import functools
|
2
2
|
import time
|
3
|
-
from typing import Literal
|
4
3
|
|
5
4
|
import jwt
|
6
5
|
from httpx_oauth.oauth2 import BaseOAuth2, RefreshTokenError
|
@@ -37,40 +36,6 @@ SOFTWARE.
|
|
37
36
|
"""
|
38
37
|
|
39
38
|
|
40
|
-
async def oauth_url(
|
41
|
-
client: BaseOAuth2,
|
42
|
-
redirect_uri: str = config.OAUTH_REDIRECT,
|
43
|
-
state: str = None,
|
44
|
-
scopes: list[str] = None,
|
45
|
-
code_challenge: str = None,
|
46
|
-
code_challenge_method: Literal["plain", "S256"] = None,
|
47
|
-
**extra_params: str,
|
48
|
-
) -> str:
|
49
|
-
"""
|
50
|
-
Constructs an authorization URL to prompt the user to authorize the application.
|
51
|
-
|
52
|
-
Args:
|
53
|
-
client (BaseOAuth2): OAuth provider.
|
54
|
-
redirect_uri (str): The URL where the user will be redirected after authorization.
|
55
|
-
state (str): An opaque value used by the client to maintain state between the request and the callback.
|
56
|
-
scopes (list[str]): The scopes to be requested. If not provided, `base_scopes` will be used.
|
57
|
-
code_challenge (str): [PKCE](https://datatracker.ietf.org/doc/html/rfc7636)) code challenge.
|
58
|
-
code_challenge_method (str): [PKCE](https://datatracker.ietf.org/doc/html/rfc7636)) code challenge method.
|
59
|
-
**extra_params (dict[str, str]): Optional extra parameters specific to the service.
|
60
|
-
|
61
|
-
Returns:
|
62
|
-
oauth_redirect
|
63
|
-
"""
|
64
|
-
return await client.get_authorization_url(
|
65
|
-
redirect_uri,
|
66
|
-
state,
|
67
|
-
scopes or client.base_scopes,
|
68
|
-
code_challenge,
|
69
|
-
code_challenge_method,
|
70
|
-
extra_params,
|
71
|
-
)
|
72
|
-
|
73
|
-
|
74
39
|
async def oauth_callback(
|
75
40
|
request: Request,
|
76
41
|
client: BaseOAuth2,
|
@@ -112,6 +77,7 @@ async def oauth_callback(
|
|
112
77
|
username=email.split("@")[0],
|
113
78
|
password="",
|
114
79
|
oauth_id=oauth_id,
|
80
|
+
verified=True,
|
115
81
|
)
|
116
82
|
authentication_session = await AuthenticationSession.new(
|
117
83
|
request,
|
sanic_security/test/server.py
CHANGED
@@ -277,9 +277,9 @@ async def on_account_creation(request):
|
|
277
277
|
async def on_oauth_request(request):
|
278
278
|
"""OAuth request."""
|
279
279
|
return redirect(
|
280
|
-
await
|
281
|
-
google_oauth,
|
280
|
+
await google_oauth.get_authorization_url(
|
282
281
|
"http://localhost:8000/api/test/oauth/callback",
|
282
|
+
scope=google_oauth.base_scopes,
|
283
283
|
)
|
284
284
|
)
|
285
285
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: sanic-security
|
3
|
-
Version: 1.16.
|
3
|
+
Version: 1.16.2
|
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/
|
@@ -136,10 +136,10 @@ dictionary.
|
|
136
136
|
For example:
|
137
137
|
|
138
138
|
```python
|
139
|
-
from sanic_security.configuration import config
|
139
|
+
from sanic_security.configuration import config as security_config
|
140
140
|
|
141
|
-
|
142
|
-
|
141
|
+
security_config.SECRET = "This is a big secret. Shhhhh"
|
142
|
+
security_config["CAPTCHA_FONT"] = "./resources/captcha-font.ttf"
|
143
143
|
```
|
144
144
|
|
145
145
|
You can also use the update() method like on regular dictionaries.
|
@@ -217,8 +217,9 @@ google_oauth = GoogleOAuth2(
|
|
217
217
|
@app.route("api/security/oauth", methods=["GET", "POST"])
|
218
218
|
async def on_oauth_request(request):
|
219
219
|
return redirect(
|
220
|
-
await
|
221
|
-
|
220
|
+
await google_oauth.get_authorization_url(
|
221
|
+
"http://localhost:8000/api/security/oauth/callback",
|
222
|
+
scope=google_oauth.base_scopes,
|
222
223
|
)
|
223
224
|
)
|
224
225
|
```
|
@@ -4,14 +4,14 @@ sanic_security/authorization.py,sha256=ssq58w4vLv4YsNt40ufxHVyCeNzVDby3UcOYOEeTn
|
|
4
4
|
sanic_security/configuration.py,sha256=2kWC4CZXvWR1wtBaqkMl58IA0VzxhI2ZbBTqd7LS_fE,6305
|
5
5
|
sanic_security/exceptions.py,sha256=RCYrDUgczwH_Uz2A__z1zCc8iKKbt2YSBdNTQUaMykc,5381
|
6
6
|
sanic_security/models.py,sha256=Ote83cdLUTpNWOMaY1uM04yDmst5_DamPEMFcSSmdks,22161
|
7
|
-
sanic_security/oauth.py,sha256=
|
7
|
+
sanic_security/oauth.py,sha256=T2IgjgHa_pA1eTuCieNwPZp0N7triqyI8nIvXuNmZVU,7083
|
8
8
|
sanic_security/utils.py,sha256=WlPOEEQGcfZk-GbPNu6OiysNXAo9mw80TitDV7XxWMc,3762
|
9
9
|
sanic_security/verification.py,sha256=0pBoGBVGsyTFNLHI0lyz640Y1f8fnKjLjA8zHzXutqM,8660
|
10
10
|
sanic_security/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
|
-
sanic_security/test/server.py,sha256=
|
11
|
+
sanic_security/test/server.py,sha256=pAXA-hWjHCobi_VxY9hLBIPrEy1sWTpcx9egtkBYQ5A,13356
|
12
12
|
sanic_security/test/tests.py,sha256=h6v3N1YhvENNA0eC-RqJK1sqGe2gFeKAMPJu7hjceqc,22570
|
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.2.dist-info/LICENSE,sha256=sXlJs9_mG-dCkPfWsDnuzydJWagS82E2gYtkVH9enHA,1100
|
14
|
+
sanic_security-1.16.2.dist-info/METADATA,sha256=1uHGMbxF6ZjF7bCePnDA5Q8nFRjV2JOQznZcBb4o15k,25742
|
15
|
+
sanic_security-1.16.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
16
|
+
sanic_security-1.16.2.dist-info/top_level.txt,sha256=ZybkhHXSjfzhmv8XeqLvnNmLmv21Z0oPX6Ep4DJN8b0,15
|
17
|
+
sanic_security-1.16.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|