Skip to content

Commit ed905b8

Browse files
committed
Merge branch '0.11' into feat/header-based-auth
2 parents 7bbcb53 + a3dd752 commit ed905b8

File tree

7 files changed

+49
-142
lines changed

7 files changed

+49
-142
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## unreleased
9+
# [0.11.13] - 2023-01-06
910

1011
- Add missing `original` attribute to flask response and remove logic for cases where `response` is `None`
12+
- Relax PyJWT version constraints https://github.com/supertokens/supertokens-python/issues/272
1113

1214
## [0.11.12] - 2022-12-27
1315
- Fix django cookie expiry time format to make it consistent with other frameworks: https://github.com/supertokens/supertokens-python/issues/267

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ set-up-hooks:
1717
chmod +x .git/hooks/pre-commit
1818

1919
test:
20-
pytest ./tests/
20+
pytest --reruns 3 --reruns-delay 5 ./tests/
2121

2222
dev-install:
2323
pip install -r dev-requirements.txt

dev-requirements.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ iniconfig==1.1.1
2828
isort==5.10.1
2929
itsdangerous==2.1.2
3030
Jinja2==3.1.1
31+
jsonschema==3.2.0
3132
lazy-object-proxy==1.7.1
3233
Mako==1.2.0
3334
Markdown==3.3.6
@@ -54,7 +55,9 @@ pyparsing==3.0.7
5455
pyright==1.1.236
5556
pyrsistent==0.18.1
5657
pytest==6.2.5
57-
pytest-asyncio==0.14.0
58+
pytest-asyncio==0.18.0
59+
pytest-mock==3.8.2
60+
pytest-rerunfailures==10.3
5861
python-dotenv==0.19.2
5962
pytz==2022.1
6063
PyYAML==5.4.1
@@ -81,4 +84,3 @@ uvicorn==0.18.2
8184
Werkzeug==2.0.3
8285
wrapt==1.13.3
8386
zipp==3.7.0
84-
pytest-mock==3.8.2

html/supertokens_python/constants.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ <h1 class="title">Module <code>supertokens_python.constants</code></h1>
4040
# License for the specific language governing permissions and limitations
4141
# under the License.
4242
SUPPORTED_CDI_VERSIONS = [&#34;2.9&#34;, &#34;2.10&#34;, &#34;2.11&#34;, &#34;2.12&#34;, &#34;2.13&#34;, &#34;2.14&#34;, &#34;2.15&#34;]
43-
VERSION = &#34;0.11.12&#34;
43+
VERSION = &#34;0.11.13&#34;
4444
TELEMETRY = &#34;/telemetry&#34;
4545
USER_COUNT = &#34;/users/count&#34;
4646
USER_DELETE = &#34;/user/remove&#34;

html/supertokens_python/framework/flask/flask_response.html

Lines changed: 38 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ <h1 class="title">Module <code>supertokens_python.framework.flask.flask_response
5151
def __init__(self, response: Response):
5252
super().__init__({})
5353
self.response = response
54+
self.original = response
5455
self.headers: List[Any] = []
5556
self.response_sent = False
5657
self.status_set = False
@@ -72,53 +73,22 @@ <h1 class="title">Module <code>supertokens_python.framework.flask.flask_response
7273
httponly: bool = False,
7374
samesite: str = &#34;lax&#34;,
7475
):
75-
from werkzeug.http import dump_cookie
76-
77-
if self.response is None:
78-
cookie = dump_cookie(
79-
key,
80-
value=value,
81-
expires=int(expires / 1000),
82-
path=path,
83-
domain=domain,
84-
secure=secure,
85-
httponly=httponly,
86-
samesite=samesite,
87-
)
88-
self.headers.append((&#34;Set-Cookie&#34;, cookie))
89-
else:
90-
self.response.set_cookie(
91-
key,
92-
value=value,
93-
expires=expires / 1000,
94-
path=path,
95-
domain=domain,
96-
secure=secure,
97-
httponly=httponly,
98-
samesite=samesite,
99-
)
76+
self.response.set_cookie(
77+
key,
78+
value=value,
79+
expires=expires / 1000,
80+
path=path,
81+
domain=domain,
82+
secure=secure,
83+
httponly=httponly,
84+
samesite=samesite,
85+
)
10086

10187
def set_header(self, key: str, value: str):
102-
if self.response is None:
103-
# TODO in the future the headrs must be validated..
104-
# if not isinstance(value, str):
105-
# raise TypeError(&#34;Value should be unicode.&#34;)
106-
if &#34;\n&#34; in value or &#34;\r&#34; in value:
107-
raise ValueError(
108-
&#34;Detected newline in header value. This is &#34;
109-
&#34;a potential security problem&#34;
110-
)
111-
self.headers.append((key, value))
112-
else:
113-
self.response.headers.add(key, value)
88+
self.response.headers.add(key, value)
11489

11590
def get_header(self, key: str) -&gt; Union[None, str]:
116-
if self.response is not None:
117-
return self.response.headers.get(key)
118-
for value in self.headers:
119-
if value[0] == key:
120-
return value[1]
121-
return None
91+
return self.response.headers.get(key)
12292

12393
def set_status_code(self, status_code: int):
12494
if not self.status_set:
@@ -127,8 +97,6 @@ <h1 class="title">Module <code>supertokens_python.framework.flask.flask_response
12797
self.status_set = True
12898

12999
def get_headers(self):
130-
if self.response is None:
131-
return self.headers
132100
return self.response.headers
133101

134102
def set_json_content(self, content: Dict[str, Any]):
@@ -170,6 +138,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
170138
def __init__(self, response: Response):
171139
super().__init__({})
172140
self.response = response
141+
self.original = response
173142
self.headers: List[Any] = []
174143
self.response_sent = False
175144
self.status_set = False
@@ -191,53 +160,22 @@ <h2 class="section-title" id="header-classes">Classes</h2>
191160
httponly: bool = False,
192161
samesite: str = &#34;lax&#34;,
193162
):
194-
from werkzeug.http import dump_cookie
195-
196-
if self.response is None:
197-
cookie = dump_cookie(
198-
key,
199-
value=value,
200-
expires=int(expires / 1000),
201-
path=path,
202-
domain=domain,
203-
secure=secure,
204-
httponly=httponly,
205-
samesite=samesite,
206-
)
207-
self.headers.append((&#34;Set-Cookie&#34;, cookie))
208-
else:
209-
self.response.set_cookie(
210-
key,
211-
value=value,
212-
expires=expires / 1000,
213-
path=path,
214-
domain=domain,
215-
secure=secure,
216-
httponly=httponly,
217-
samesite=samesite,
218-
)
163+
self.response.set_cookie(
164+
key,
165+
value=value,
166+
expires=expires / 1000,
167+
path=path,
168+
domain=domain,
169+
secure=secure,
170+
httponly=httponly,
171+
samesite=samesite,
172+
)
219173

220174
def set_header(self, key: str, value: str):
221-
if self.response is None:
222-
# TODO in the future the headrs must be validated..
223-
# if not isinstance(value, str):
224-
# raise TypeError(&#34;Value should be unicode.&#34;)
225-
if &#34;\n&#34; in value or &#34;\r&#34; in value:
226-
raise ValueError(
227-
&#34;Detected newline in header value. This is &#34;
228-
&#34;a potential security problem&#34;
229-
)
230-
self.headers.append((key, value))
231-
else:
232-
self.response.headers.add(key, value)
175+
self.response.headers.add(key, value)
233176

234177
def get_header(self, key: str) -&gt; Union[None, str]:
235-
if self.response is not None:
236-
return self.response.headers.get(key)
237-
for value in self.headers:
238-
if value[0] == key:
239-
return value[1]
240-
return None
178+
return self.response.headers.get(key)
241179

242180
def set_status_code(self, status_code: int):
243181
if not self.status_set:
@@ -246,8 +184,6 @@ <h2 class="section-title" id="header-classes">Classes</h2>
246184
self.status_set = True
247185

248186
def get_headers(self):
249-
if self.response is None:
250-
return self.headers
251187
return self.response.headers
252188

253189
def set_json_content(self, content: Dict[str, Any]):
@@ -302,12 +238,7 @@ <h3>Methods</h3>
302238
<span>Expand source code</span>
303239
</summary>
304240
<pre><code class="python">def get_header(self, key: str) -&gt; Union[None, str]:
305-
if self.response is not None:
306-
return self.response.headers.get(key)
307-
for value in self.headers:
308-
if value[0] == key:
309-
return value[1]
310-
return None</code></pre>
241+
return self.response.headers.get(key)</code></pre>
311242
</details>
312243
</dd>
313244
<dt id="supertokens_python.framework.flask.flask_response.FlaskResponse.get_headers"><code class="name flex">
@@ -320,8 +251,6 @@ <h3>Methods</h3>
320251
<span>Expand source code</span>
321252
</summary>
322253
<pre><code class="python">def get_headers(self):
323-
if self.response is None:
324-
return self.headers
325254
return self.response.headers</code></pre>
326255
</details>
327256
</dd>
@@ -345,31 +274,16 @@ <h3>Methods</h3>
345274
httponly: bool = False,
346275
samesite: str = &#34;lax&#34;,
347276
):
348-
from werkzeug.http import dump_cookie
349-
350-
if self.response is None:
351-
cookie = dump_cookie(
352-
key,
353-
value=value,
354-
expires=int(expires / 1000),
355-
path=path,
356-
domain=domain,
357-
secure=secure,
358-
httponly=httponly,
359-
samesite=samesite,
360-
)
361-
self.headers.append((&#34;Set-Cookie&#34;, cookie))
362-
else:
363-
self.response.set_cookie(
364-
key,
365-
value=value,
366-
expires=expires / 1000,
367-
path=path,
368-
domain=domain,
369-
secure=secure,
370-
httponly=httponly,
371-
samesite=samesite,
372-
)</code></pre>
277+
self.response.set_cookie(
278+
key,
279+
value=value,
280+
expires=expires / 1000,
281+
path=path,
282+
domain=domain,
283+
secure=secure,
284+
httponly=httponly,
285+
samesite=samesite,
286+
)</code></pre>
373287
</details>
374288
</dd>
375289
<dt id="supertokens_python.framework.flask.flask_response.FlaskResponse.set_header"><code class="name flex">
@@ -382,18 +296,7 @@ <h3>Methods</h3>
382296
<span>Expand source code</span>
383297
</summary>
384298
<pre><code class="python">def set_header(self, key: str, value: str):
385-
if self.response is None:
386-
# TODO in the future the headrs must be validated..
387-
# if not isinstance(value, str):
388-
# raise TypeError(&#34;Value should be unicode.&#34;)
389-
if &#34;\n&#34; in value or &#34;\r&#34; in value:
390-
raise ValueError(
391-
&#34;Detected newline in header value. This is &#34;
392-
&#34;a potential security problem&#34;
393-
)
394-
self.headers.append((key, value))
395-
else:
396-
self.response.headers.add(key, value)</code></pre>
299+
self.response.headers.add(key, value)</code></pre>
397300
</details>
398301
</dd>
399302
<dt id="supertokens_python.framework.flask.flask_response.FlaskResponse.set_html_content"><code class="name flex">

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
setup(
7272
name="supertokens_python",
73-
version="0.11.12",
73+
version="0.11.13",
7474
author="SuperTokens",
7575
license="Apache 2.0",
7676
author_email="[email protected]",
@@ -99,7 +99,7 @@
9999
],
100100
keywords="",
101101
install_requires=[
102-
"PyJWT>=2.0.0 ,<2.4.0",
102+
"PyJWT>=2.0.0 ,<3.0.0",
103103
"httpx>=0.15.0 ,<0.24.0",
104104
"pycryptodome==3.10.*",
105105
"tldextract==3.1.0",

supertokens_python/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414
SUPPORTED_CDI_VERSIONS = ["2.9", "2.10", "2.11", "2.12", "2.13", "2.14", "2.15"]
15-
VERSION = "0.11.12"
15+
VERSION = "0.11.13"
1616
TELEMETRY = "/telemetry"
1717
USER_COUNT = "/users/count"
1818
USER_DELETE = "/user/remove"

0 commit comments

Comments
 (0)