Skip to content

Commit 22d5c20

Browse files
committed
Merge branch '0.16' into feat/cache-control-jwks
2 parents 4798bd3 + 364896d commit 22d5c20

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1243
-390
lines changed

.circleci/config_continue.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,22 @@ jobs:
7979
- run: make with-django2x
8080
- run: (cd .circleci/ && ./websiteDjango2x.sh)
8181
- slack/status
82+
test-website-flask-nest-asyncio:
83+
docker:
84+
- image: rishabhpoddar/supertokens_python_driver_testing
85+
resource_class: large
86+
environment:
87+
SUPERTOKENS_NEST_ASYNCIO: "1"
88+
steps:
89+
- checkout
90+
- run: update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk-15.0.1/bin/java" 2
91+
- run: update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-15.0.1/bin/javac" 2
92+
- run: git config --global url."https://github.com/".insteadOf ssh://[email protected]/
93+
- run: echo "127.0.0.1 localhost.org" >> /etc/hosts
94+
- run: make with-flask
95+
- run: python -m pip install nest-asyncio
96+
- run: (cd .circleci/ && ./websiteFlask.sh)
97+
- slack/status
8298
test-authreact-fastapi:
8399
docker:
84100
- image: rishabhpoddar/supertokens_python_driver_testing

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [unreleased]
1010

11+
## [0.16.2] - 2023-09-20
1112

13+
- Allow use of [nest-asyncio](https://pypi.org/project/nest-asyncio/) when env var `SUPERTOKENS_NEST_ASYNCIO=1`.
14+
- Retry Querier request on `AsyncLibraryNotFoundError`
15+
16+
## [0.16.1] - 2023-09-19
17+
- Handle AWS Public URLs (ending with `.amazonaws.com`) separately while extracting TLDs for SameSite attribute.
18+
19+
20+
## [0.16.0] - 2023-09-13
21+
22+
23+
### Added
24+
25+
- The Dashboard recipe now accepts a new `admins` property which can be used to give Dashboard Users write privileges for the user dashboard.
26+
27+
### Changes
28+
29+
- Dashboard APIs now return a status code `403` for all non-GET requests if the currently logged in Dashboard User is not listed in the `admins` array
30+
- Now ignoring protected props in the payload in `create_new_session` and `create_new_session_without_request_response`
1231

1332
## [0.15.3] - 2023-09-25
1433

@@ -529,6 +548,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
529548
}
530549
}
531550
```
551+
### SDK and core compatibility
552+
553+
- Compatible with Core>=6.0.0 (CDI 4.0)
554+
- Compatible with frontend SDKs:
555+
- supertokens-auth-react@0.34.0
556+
- supertokens-web-js@0.7.0
557+
- supertokens-website@17.0.2
558+
532559

533560
## [0.14.8] - 2023-07-07
534561
## Fixes

html/supertokens_python/async_to_sync_wrapper.html

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,34 @@ <h1 class="title">Module <code>supertokens_python.async_to_sync_wrapper</code></
4242

4343
import asyncio
4444
from typing import Any, Coroutine, TypeVar
45+
from os import getenv
4546

4647
_T = TypeVar(&#34;_T&#34;)
4748

4849

49-
def check_event_loop():
50+
def nest_asyncio_enabled():
51+
return getenv(&#34;SUPERTOKENS_NEST_ASYNCIO&#34;, &#34;&#34;) == &#34;1&#34;
52+
53+
54+
def create_or_get_event_loop() -&gt; asyncio.AbstractEventLoop:
5055
try:
51-
asyncio.get_event_loop()
52-
except RuntimeError as ex:
56+
return asyncio.get_event_loop()
57+
except Exception as ex:
5358
if &#34;There is no current event loop in thread&#34; in str(ex):
5459
loop = asyncio.new_event_loop()
60+
61+
if nest_asyncio_enabled():
62+
import nest_asyncio # type: ignore
63+
64+
nest_asyncio.apply(loop) # type: ignore
65+
5566
asyncio.set_event_loop(loop)
67+
return loop
68+
raise ex
5669

5770

5871
def sync(co: Coroutine[Any, Any, _T]) -&gt; _T:
59-
check_event_loop()
60-
loop = asyncio.get_event_loop()
72+
loop = create_or_get_event_loop()
6173
return loop.run_until_complete(co)</code></pre>
6274
</details>
6375
</section>
@@ -68,22 +80,43 @@ <h1 class="title">Module <code>supertokens_python.async_to_sync_wrapper</code></
6880
<section>
6981
<h2 class="section-title" id="header-functions">Functions</h2>
7082
<dl>
71-
<dt id="supertokens_python.async_to_sync_wrapper.check_event_loop"><code class="name flex">
72-
<span>def <span class="ident">check_event_loop</span></span>(<span>)</span>
83+
<dt id="supertokens_python.async_to_sync_wrapper.create_or_get_event_loop"><code class="name flex">
84+
<span>def <span class="ident">create_or_get_event_loop</span></span>(<span>)> asyncio.events.AbstractEventLoop</span>
7385
</code></dt>
7486
<dd>
7587
<div class="desc"></div>
7688
<details class="source">
7789
<summary>
7890
<span>Expand source code</span>
7991
</summary>
80-
<pre><code class="python">def check_event_loop():
92+
<pre><code class="python">def create_or_get_event_loop() -&gt; asyncio.AbstractEventLoop:
8193
try:
82-
asyncio.get_event_loop()
83-
except RuntimeError as ex:
94+
return asyncio.get_event_loop()
95+
except Exception as ex:
8496
if &#34;There is no current event loop in thread&#34; in str(ex):
8597
loop = asyncio.new_event_loop()
86-
asyncio.set_event_loop(loop)</code></pre>
98+
99+
if nest_asyncio_enabled():
100+
import nest_asyncio # type: ignore
101+
102+
nest_asyncio.apply(loop) # type: ignore
103+
104+
asyncio.set_event_loop(loop)
105+
return loop
106+
raise ex</code></pre>
107+
</details>
108+
</dd>
109+
<dt id="supertokens_python.async_to_sync_wrapper.nest_asyncio_enabled"><code class="name flex">
110+
<span>def <span class="ident">nest_asyncio_enabled</span></span>(<span>)</span>
111+
</code></dt>
112+
<dd>
113+
<div class="desc"></div>
114+
<details class="source">
115+
<summary>
116+
<span>Expand source code</span>
117+
</summary>
118+
<pre><code class="python">def nest_asyncio_enabled():
119+
return getenv(&#34;SUPERTOKENS_NEST_ASYNCIO&#34;, &#34;&#34;) == &#34;1&#34;</code></pre>
87120
</details>
88121
</dd>
89122
<dt id="supertokens_python.async_to_sync_wrapper.sync"><code class="name flex">
@@ -96,8 +129,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
96129
<span>Expand source code</span>
97130
</summary>
98131
<pre><code class="python">def sync(co: Coroutine[Any, Any, _T]) -&gt; _T:
99-
check_event_loop()
100-
loop = asyncio.get_event_loop()
132+
loop = create_or_get_event_loop()
101133
return loop.run_until_complete(co)</code></pre>
102134
</details>
103135
</dd>
@@ -119,7 +151,8 @@ <h2>Index</h2>
119151
</li>
120152
<li><h3><a href="#header-functions">Functions</a></h3>
121153
<ul class="">
122-
<li><code><a title="supertokens_python.async_to_sync_wrapper.check_event_loop" href="#supertokens_python.async_to_sync_wrapper.check_event_loop">check_event_loop</a></code></li>
154+
<li><code><a title="supertokens_python.async_to_sync_wrapper.create_or_get_event_loop" href="#supertokens_python.async_to_sync_wrapper.create_or_get_event_loop">create_or_get_event_loop</a></code></li>
155+
<li><code><a title="supertokens_python.async_to_sync_wrapper.nest_asyncio_enabled" href="#supertokens_python.async_to_sync_wrapper.nest_asyncio_enabled">nest_asyncio_enabled</a></code></li>
123156
<li><code><a title="supertokens_python.async_to_sync_wrapper.sync" href="#supertokens_python.async_to_sync_wrapper.sync">sync</a></code></li>
124157
</ul>
125158
</li>

html/supertokens_python/constants.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ <h1 class="title">Module <code>supertokens_python.constants</code></h1>
4242
from __future__ import annotations
4343

4444
SUPPORTED_CDI_VERSIONS = [&#34;3.0&#34;]
45-
VERSION = &#34;0.15.2&#34;
45+
VERSION = &#34;0.16.2&#34;
4646
TELEMETRY = &#34;/telemetry&#34;
4747
USER_COUNT = &#34;/users/count&#34;
4848
USER_DELETE = &#34;/user/remove&#34;
@@ -56,7 +56,8 @@ <h1 class="title">Module <code>supertokens_python.constants</code></h1>
5656
API_VERSION = &#34;/apiversion&#34;
5757
API_VERSION_HEADER = &#34;cdi-version&#34;
5858
DASHBOARD_VERSION = &#34;0.7&#34;
59-
HUNDRED_YEARS_IN_MS = 3153600000000</code></pre>
59+
HUNDRED_YEARS_IN_MS = 3153600000000
60+
RATE_LIMIT_STATUS_CODE = 429</code></pre>
6061
</details>
6162
</section>
6263
<section>

html/supertokens_python/framework/django/django_request.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ <h1 class="title">Module <code>supertokens_python.framework.django.django_reques
5757
super().__init__()
5858
self.request = request
5959

60+
def get_original_url(self) -&gt; str:
61+
return self.request.get_raw_uri()
62+
6063
def get_query_param(
6164
self, key: str, default: Union[str, None] = None
6265
) -&gt; Union[str, None]:
@@ -126,6 +129,9 @@ <h2 class="section-title" id="header-classes">Classes</h2>
126129
super().__init__()
127130
self.request = request
128131

132+
def get_original_url(self) -&gt; str:
133+
return self.request.get_raw_uri()
134+
129135
def get_query_param(
130136
self, key: str, default: Union[str, None] = None
131137
) -&gt; Union[str, None]:
@@ -217,6 +223,19 @@ <h3>Methods</h3>
217223
return self.request.META.get(key.upper())</code></pre>
218224
</details>
219225
</dd>
226+
<dt id="supertokens_python.framework.django.django_request.DjangoRequest.get_original_url"><code class="name flex">
227+
<span>def <span class="ident">get_original_url</span></span>(<span>self) ‑> str</span>
228+
</code></dt>
229+
<dd>
230+
<div class="desc"></div>
231+
<details class="source">
232+
<summary>
233+
<span>Expand source code</span>
234+
</summary>
235+
<pre><code class="python">def get_original_url(self) -&gt; str:
236+
return self.request.get_raw_uri()</code></pre>
237+
</details>
238+
</dd>
220239
<dt id="supertokens_python.framework.django.django_request.DjangoRequest.get_path"><code class="name flex">
221240
<span>def <span class="ident">get_path</span></span>(<span>self) ‑> str</span>
222241
</code></dt>
@@ -348,6 +367,7 @@ <h4><code><a title="supertokens_python.framework.django.django_request.DjangoReq
348367
<li><code><a title="supertokens_python.framework.django.django_request.DjangoRequest.form_data" href="#supertokens_python.framework.django.django_request.DjangoRequest.form_data">form_data</a></code></li>
349368
<li><code><a title="supertokens_python.framework.django.django_request.DjangoRequest.get_cookie" href="#supertokens_python.framework.django.django_request.DjangoRequest.get_cookie">get_cookie</a></code></li>
350369
<li><code><a title="supertokens_python.framework.django.django_request.DjangoRequest.get_header" href="#supertokens_python.framework.django.django_request.DjangoRequest.get_header">get_header</a></code></li>
370+
<li><code><a title="supertokens_python.framework.django.django_request.DjangoRequest.get_original_url" href="#supertokens_python.framework.django.django_request.DjangoRequest.get_original_url">get_original_url</a></code></li>
351371
<li><code><a title="supertokens_python.framework.django.django_request.DjangoRequest.get_path" href="#supertokens_python.framework.django.django_request.DjangoRequest.get_path">get_path</a></code></li>
352372
<li><code><a title="supertokens_python.framework.django.django_request.DjangoRequest.get_query_param" href="#supertokens_python.framework.django.django_request.DjangoRequest.get_query_param">get_query_param</a></code></li>
353373
<li><code><a title="supertokens_python.framework.django.django_request.DjangoRequest.get_query_params" href="#supertokens_python.framework.django.django_request.DjangoRequest.get_query_params">get_query_params</a></code></li>

html/supertokens_python/framework/fastapi/fastapi_request.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ <h1 class="title">Module <code>supertokens_python.framework.fastapi.fastapi_requ
5656
super().__init__()
5757
self.request = request
5858

59+
def get_original_url(self) -&gt; str:
60+
return self.request.url.components.geturl()
61+
5962
def get_query_param(
6063
self, key: str, default: Union[str, None] = None
6164
) -&gt; Union[str, None]:
@@ -126,6 +129,9 @@ <h2 class="section-title" id="header-classes">Classes</h2>
126129
super().__init__()
127130
self.request = request
128131

132+
def get_original_url(self) -&gt; str:
133+
return self.request.url.components.geturl()
134+
129135
def get_query_param(
130136
self, key: str, default: Union[str, None] = None
131137
) -&gt; Union[str, None]:
@@ -218,6 +224,19 @@ <h3>Methods</h3>
218224
return self.request.headers.get(key, None)</code></pre>
219225
</details>
220226
</dd>
227+
<dt id="supertokens_python.framework.fastapi.fastapi_request.FastApiRequest.get_original_url"><code class="name flex">
228+
<span>def <span class="ident">get_original_url</span></span>(<span>self) ‑> str</span>
229+
</code></dt>
230+
<dd>
231+
<div class="desc"></div>
232+
<details class="source">
233+
<summary>
234+
<span>Expand source code</span>
235+
</summary>
236+
<pre><code class="python">def get_original_url(self) -&gt; str:
237+
return self.request.url.components.geturl()</code></pre>
238+
</details>
239+
</dd>
221240
<dt id="supertokens_python.framework.fastapi.fastapi_request.FastApiRequest.get_path"><code class="name flex">
222241
<span>def <span class="ident">get_path</span></span>(<span>self) ‑> str</span>
223242
</code></dt>
@@ -350,6 +369,7 @@ <h4><code><a title="supertokens_python.framework.fastapi.fastapi_request.FastApi
350369
<li><code><a title="supertokens_python.framework.fastapi.fastapi_request.FastApiRequest.form_data" href="#supertokens_python.framework.fastapi.fastapi_request.FastApiRequest.form_data">form_data</a></code></li>
351370
<li><code><a title="supertokens_python.framework.fastapi.fastapi_request.FastApiRequest.get_cookie" href="#supertokens_python.framework.fastapi.fastapi_request.FastApiRequest.get_cookie">get_cookie</a></code></li>
352371
<li><code><a title="supertokens_python.framework.fastapi.fastapi_request.FastApiRequest.get_header" href="#supertokens_python.framework.fastapi.fastapi_request.FastApiRequest.get_header">get_header</a></code></li>
372+
<li><code><a title="supertokens_python.framework.fastapi.fastapi_request.FastApiRequest.get_original_url" href="#supertokens_python.framework.fastapi.fastapi_request.FastApiRequest.get_original_url">get_original_url</a></code></li>
353373
<li><code><a title="supertokens_python.framework.fastapi.fastapi_request.FastApiRequest.get_path" href="#supertokens_python.framework.fastapi.fastapi_request.FastApiRequest.get_path">get_path</a></code></li>
354374
<li><code><a title="supertokens_python.framework.fastapi.fastapi_request.FastApiRequest.get_query_param" href="#supertokens_python.framework.fastapi.fastapi_request.FastApiRequest.get_query_param">get_query_param</a></code></li>
355375
<li><code><a title="supertokens_python.framework.fastapi.fastapi_request.FastApiRequest.get_query_params" href="#supertokens_python.framework.fastapi.fastapi_request.FastApiRequest.get_query_params">get_query_params</a></code></li>

html/supertokens_python/framework/flask/flask_request.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ <h1 class="title">Module <code>supertokens_python.framework.flask.flask_request<
5555
super().__init__()
5656
self.request = req
5757

58+
def get_original_url(self) -&gt; str:
59+
return self.request.url
60+
5861
def get_query_param(self, key: str, default: Union[str, None] = None):
5962
return self.request.args.get(key, default)
6063

@@ -133,6 +136,9 @@ <h2 class="section-title" id="header-classes">Classes</h2>
133136
super().__init__()
134137
self.request = req
135138

139+
def get_original_url(self) -&gt; str:
140+
return self.request.url
141+
136142
def get_query_param(self, key: str, default: Union[str, None] = None):
137143
return self.request.args.get(key, default)
138144

@@ -233,6 +239,19 @@ <h3>Methods</h3>
233239
return self.request.headers.get(key) # type: ignore</code></pre>
234240
</details>
235241
</dd>
242+
<dt id="supertokens_python.framework.flask.flask_request.FlaskRequest.get_original_url"><code class="name flex">
243+
<span>def <span class="ident">get_original_url</span></span>(<span>self) ‑> str</span>
244+
</code></dt>
245+
<dd>
246+
<div class="desc"></div>
247+
<details class="source">
248+
<summary>
249+
<span>Expand source code</span>
250+
</summary>
251+
<pre><code class="python">def get_original_url(self) -&gt; str:
252+
return self.request.url</code></pre>
253+
</details>
254+
</dd>
236255
<dt id="supertokens_python.framework.flask.flask_request.FlaskRequest.get_path"><code class="name flex">
237256
<span>def <span class="ident">get_path</span></span>(<span>self) ‑> str</span>
238257
</code></dt>
@@ -371,6 +390,7 @@ <h4><code><a title="supertokens_python.framework.flask.flask_request.FlaskReques
371390
<li><code><a title="supertokens_python.framework.flask.flask_request.FlaskRequest.form_data" href="#supertokens_python.framework.flask.flask_request.FlaskRequest.form_data">form_data</a></code></li>
372391
<li><code><a title="supertokens_python.framework.flask.flask_request.FlaskRequest.get_cookie" href="#supertokens_python.framework.flask.flask_request.FlaskRequest.get_cookie">get_cookie</a></code></li>
373392
<li><code><a title="supertokens_python.framework.flask.flask_request.FlaskRequest.get_header" href="#supertokens_python.framework.flask.flask_request.FlaskRequest.get_header">get_header</a></code></li>
393+
<li><code><a title="supertokens_python.framework.flask.flask_request.FlaskRequest.get_original_url" href="#supertokens_python.framework.flask.flask_request.FlaskRequest.get_original_url">get_original_url</a></code></li>
374394
<li><code><a title="supertokens_python.framework.flask.flask_request.FlaskRequest.get_path" href="#supertokens_python.framework.flask.flask_request.FlaskRequest.get_path">get_path</a></code></li>
375395
<li><code><a title="supertokens_python.framework.flask.flask_request.FlaskRequest.get_query_param" href="#supertokens_python.framework.flask.flask_request.FlaskRequest.get_query_param">get_query_param</a></code></li>
376396
<li><code><a title="supertokens_python.framework.flask.flask_request.FlaskRequest.get_query_params" href="#supertokens_python.framework.flask.flask_request.FlaskRequest.get_query_params">get_query_params</a></code></li>

html/supertokens_python/framework/request.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ <h1 class="title">Module <code>supertokens_python.framework.request</code></h1>
5353
self.wrapper_used = True
5454
self.request = None
5555

56+
@abstractmethod
57+
def get_original_url(self) -&gt; str:
58+
pass
59+
5660
@abstractmethod
5761
def get_query_param(
5862
self, key: str, default: Union[str, None] = None
@@ -127,6 +131,10 @@ <h2 class="section-title" id="header-classes">Classes</h2>
127131
self.wrapper_used = True
128132
self.request = None
129133

134+
@abstractmethod
135+
def get_original_url(self) -&gt; str:
136+
pass
137+
130138
@abstractmethod
131139
def get_query_param(
132140
self, key: str, default: Union[str, None] = None
@@ -230,6 +238,20 @@ <h3>Methods</h3>
230238
pass</code></pre>
231239
</details>
232240
</dd>
241+
<dt id="supertokens_python.framework.request.BaseRequest.get_original_url"><code class="name flex">
242+
<span>def <span class="ident">get_original_url</span></span>(<span>self) ‑> str</span>
243+
</code></dt>
244+
<dd>
245+
<div class="desc"></div>
246+
<details class="source">
247+
<summary>
248+
<span>Expand source code</span>
249+
</summary>
250+
<pre><code class="python">@abstractmethod
251+
def get_original_url(self) -&gt; str:
252+
pass</code></pre>
253+
</details>
254+
</dd>
233255
<dt id="supertokens_python.framework.request.BaseRequest.get_path"><code class="name flex">
234256
<span>def <span class="ident">get_path</span></span>(<span>self) ‑> str</span>
235257
</code></dt>
@@ -372,6 +394,7 @@ <h4><code><a title="supertokens_python.framework.request.BaseRequest" href="#sup
372394
<li><code><a title="supertokens_python.framework.request.BaseRequest.form_data" href="#supertokens_python.framework.request.BaseRequest.form_data">form_data</a></code></li>
373395
<li><code><a title="supertokens_python.framework.request.BaseRequest.get_cookie" href="#supertokens_python.framework.request.BaseRequest.get_cookie">get_cookie</a></code></li>
374396
<li><code><a title="supertokens_python.framework.request.BaseRequest.get_header" href="#supertokens_python.framework.request.BaseRequest.get_header">get_header</a></code></li>
397+
<li><code><a title="supertokens_python.framework.request.BaseRequest.get_original_url" href="#supertokens_python.framework.request.BaseRequest.get_original_url">get_original_url</a></code></li>
375398
<li><code><a title="supertokens_python.framework.request.BaseRequest.get_path" href="#supertokens_python.framework.request.BaseRequest.get_path">get_path</a></code></li>
376399
<li><code><a title="supertokens_python.framework.request.BaseRequest.get_query_param" href="#supertokens_python.framework.request.BaseRequest.get_query_param">get_query_param</a></code></li>
377400
<li><code><a title="supertokens_python.framework.request.BaseRequest.get_query_params" href="#supertokens_python.framework.request.BaseRequest.get_query_params">get_query_params</a></code></li>

0 commit comments

Comments
 (0)