Skip to content

Commit 9ee87ec

Browse files
authored
Merge branch '0.10' into fix-multiple-h1-issue
2 parents 84257d1 + 4af9d85 commit 9ee87ec

File tree

549 files changed

+47268
-25038
lines changed

Some content is hidden

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

549 files changed

+47268
-25038
lines changed

.circleci/config_continue.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ jobs:
5959
- run: make with-django
6060
- run: (cd .circleci/ && ./websiteDjango.sh)
6161
- slack/status
62+
test-website-django2x:
63+
docker:
64+
- image: rishabhpoddar/supertokens_python_driver_testing
65+
resource_class: large
66+
steps:
67+
- checkout
68+
- run: update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk-15.0.1/bin/java" 2
69+
- run: update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-15.0.1/bin/javac" 2
70+
- run: echo "127.0.0.1 localhost.org" >> /etc/hosts
71+
- run: make with-django2x
72+
- run: (cd .circleci/ && ./websiteDjango2x.sh)
73+
- slack/status
6274
test-authreact-fastapi:
6375
docker:
6476
- image: rishabhpoddar/supertokens_python_driver_testing
@@ -206,6 +218,16 @@ workflows:
206218
only: /dev-v[0-9]+(\.[0-9]+)*/
207219
branches:
208220
ignore: /.*/
221+
- test-website-django2x:
222+
requires:
223+
- test-dev-tag-as-not-passed
224+
context:
225+
- slack-notification
226+
filters:
227+
tags:
228+
only: /dev-v[0-9]+(\.[0-9]+)*/
229+
branches:
230+
ignore: /.*/
209231
- test-authreact-fastapi:
210232
requires:
211233
- test-dev-tag-as-not-passed
@@ -251,6 +273,7 @@ workflows:
251273
- test-website-fastapi
252274
- test-website-flask
253275
- test-website-django
276+
- test-website-django2x
254277
- test-authreact-fastapi
255278
- test-authreact-flask
256279
- test-authreact-django
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
coreInfo=`curl -s -X GET \
2+
"https://api.supertokens.io/0/core/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$1" \
3+
-H 'api-version: 0'`
4+
if [[ `echo $coreInfo | jq .tag` == "null" ]]
5+
then
6+
echo "fetching latest X.Y.Z version for core, X.Y version: $1, planType: FREE gave response: $coreInfo"
7+
exit 1
8+
fi
9+
coreTag=$(echo $coreInfo | jq .tag | tr -d '"')
10+
coreVersion=$(echo $coreInfo | jq .version | tr -d '"')
11+
12+
pluginInterfaceVersionXY=`curl -s -X GET \
13+
"https://api.supertokens.io/0/core/dependency/plugin-interface/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$1" \
14+
-H 'api-version: 0'`
15+
if [[ `echo $pluginInterfaceVersionXY | jq .pluginInterface` == "null" ]]
16+
then
17+
echo "fetching latest X.Y version for plugin-interface, given core X.Y version: $1, planType: FREE gave response: $pluginInterfaceVersionXY"
18+
exit 1
19+
fi
20+
pluginInterfaceVersionXY=$(echo $pluginInterfaceVersionXY | jq .pluginInterface | tr -d '"')
21+
22+
pluginInterfaceInfo=`curl -s -X GET \
23+
"https://api.supertokens.io/0/plugin-interface/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$pluginInterfaceVersionXY" \
24+
-H 'api-version: 0'`
25+
if [[ `echo $pluginInterfaceInfo | jq .tag` == "null" ]]
26+
then
27+
echo "fetching latest X.Y.Z version for plugin-interface, X.Y version: $pluginInterfaceVersionXY, planType: FREE gave response: $pluginInterfaceInfo"
28+
exit 1
29+
fi
30+
pluginInterfaceTag=$(echo $pluginInterfaceInfo | jq .tag | tr -d '"')
31+
pluginInterfaceVersion=$(echo $pluginInterfaceInfo | jq .version | tr -d '"')
32+
33+
echo "Testing with frontend website: $2, FREE core: $coreVersion, plugin-interface: $pluginInterfaceVersion"
34+
35+
cd ../../
36+
git clone git@github.com:supertokens/supertokens-root.git
37+
cd supertokens-root
38+
echo -e "core,$1\nplugin-interface,$pluginInterfaceVersionXY" > modules.txt
39+
./loadModules --ssh
40+
cd supertokens-core
41+
git checkout $coreTag
42+
cd ../supertokens-plugin-interface
43+
git checkout $pluginInterfaceTag
44+
cd ../
45+
echo $SUPERTOKENS_API_KEY > apiPassword
46+
./utils/setupTestEnvLocal
47+
cd ../
48+
git clone git@github.com:supertokens/supertokens-website.git
49+
cd supertokens-website
50+
git checkout $2
51+
cd ../project/tests/frontendIntegration/django2x
52+
export PYTHONPATH="${PYTHONPATH}:/root/project"
53+
python3 manage.py runserver 8080 &
54+
pid=$!
55+
python3 manage.py runserver 8082 &
56+
pid2=$!
57+
cd ../../../../supertokens-website/test/server
58+
npm i -d
59+
npm i git+https://github.com:supertokens/supertokens-node.git#$3
60+
cd ../../
61+
npm i -d
62+
SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npm test
63+
if [[ $? -ne 0 ]]
64+
then
65+
echo "test failed... killing $pid, $pid2 and exiting!"
66+
kill -9 $pid
67+
kill -9 $pid2
68+
rm -rf ./test/server/node_modules/supertokens-node
69+
git checkout HEAD -- ./test/server/package.json
70+
exit 1
71+
fi
72+
echo "all tests passed, killing processes: $pid and $pid2"
73+
kill -9 $pid
74+
kill -9 $pid2
75+
rm -rf ./test/server/node_modules/supertokens-node
76+
git checkout HEAD -- ./test/server/package.json

.circleci/websiteDjango2x.sh

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
coreDriverJson=`cat ../coreDriverInterfaceSupported.json`
2+
coreDriverLength=`echo $coreDriverJson | jq ".versions | length"`
3+
coreDriverArray=`echo $coreDriverJson | jq ".versions"`
4+
echo "got core driver relations"
5+
6+
frontendDriverJson=`cat ../frontendDriverInterfaceSupported.json`
7+
frontendDriverLength=`echo $frontendDriverJson | jq ".versions | length"`
8+
frontendDriverArray=`echo $frontendDriverJson | jq ".versions"`
9+
echo "got frontend driver relations"
10+
11+
# get driver version
12+
version=`cat ../setup.py | grep -e 'version='`
13+
while IFS='"' read -ra ADDR; do
14+
counter=0
15+
for i in "${ADDR[@]}"; do
16+
if [ $counter == 1 ]
17+
then
18+
version=$i
19+
fi
20+
counter=$(($counter+1))
21+
done
22+
done <<< "$version"
23+
24+
someFrontendTestsRan=false
25+
i=0
26+
coreDriverVersion=`echo $coreDriverArray | jq ". | last"`
27+
coreDriverVersion=`echo $coreDriverVersion | tr -d '"'`
28+
coreFree=`curl -s -X GET \
29+
"https://api.supertokens.io/0/core-driver-interface/dependency/core/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$coreDriverVersion" \
30+
-H 'api-version: 0'`
31+
if [[ `echo $coreFree | jq .core` == "null" ]]
32+
then
33+
echo "fetching latest X.Y version for core given core-driver-interface X.Y version: $coreDriverVersion, planType: FREE gave response: $coreFree. Please make sure all relevant cores have been pushed."
34+
exit 1
35+
fi
36+
coreFree=$(echo $coreFree | jq .core | tr -d '"')
37+
while [ $i -lt $frontendDriverLength ]; do
38+
frontendDriverVersion=`echo $frontendDriverArray | jq ".[$i]"`
39+
frontendDriverVersion=`echo $frontendDriverVersion | tr -d '"'`
40+
i=$((i+1))
41+
42+
if [[ $frontendDriverVersion == '1.0' ]]; then
43+
continue
44+
fi
45+
46+
frontendVersionXY=`curl -s -X GET \
47+
"https://api.supertokens.io/0/frontend-driver-interface/dependency/frontend/latest?password=$SUPERTOKENS_API_KEY&frontendName=website&mode=DEV&version=$frontendDriverVersion" \
48+
-H 'api-version: 0'`
49+
if [[ `echo $frontendVersionXY | jq .frontend` == "null" ]]
50+
then
51+
echo "fetching latest X.Y version for frontend given frontend-driver-interface X.Y version: $frontendDriverVersion, name: webiste gave response: $frontend. Please make sure all relevant versions have been pushed."
52+
exit 1
53+
fi
54+
frontendVersionXY=$(echo $frontendVersionXY | jq .frontend | tr -d '"')
55+
56+
frontendInfo=`curl -s -X GET \
57+
"https://api.supertokens.io/0/driver/latest?password=$SUPERTOKENS_API_KEY&mode=DEV&version=$frontendVersionXY&name=website" \
58+
-H 'api-version: 0'`
59+
if [[ `echo $frontendInfo | jq .tag` == "null" ]]
60+
then
61+
echo "fetching latest X.Y.Z version for frontend, X.Y version: $frontendVersionXY gave response: $frontendInfo"
62+
exit 1
63+
fi
64+
frontendTag=$(echo $frontendInfo | jq .tag | tr -d '"')
65+
frontendVersion=$(echo $frontendInfo | jq .version | tr -d '"')
66+
67+
nodeVersionXY=`curl -s -X GET \
68+
"https://api.supertokens.io/0/frontend-driver-interface/dependency/driver/latest?password=$SUPERTOKENS_API_KEY&mode=DEV&version=$frontendDriverVersion&driverName=node" \
69+
-H 'api-version: 0'`
70+
if [[ `echo $nodeVersionXY | jq .driver` == "null" ]]
71+
then
72+
echo "fetching latest X.Y version for driver given frontend-driver-interface X.Y version: $frontendDriverVersion gave response: $nodeVersionXY. Please make sure all relevant drivers have been pushed."
73+
exit 1
74+
fi
75+
nodeVersionXY=$(echo $nodeVersionXY | jq .driver | tr -d '"')
76+
77+
nodeInfo=`curl -s -X GET \
78+
"https://api.supertokens.io/0/driver/latest?password=$SUPERTOKENS_API_KEY&mode=DEV&version=$nodeVersionXY&name=node" \
79+
-H 'api-version: 0'`
80+
if [[ `echo $nodeInfo | jq .tag` == "null" ]]
81+
then
82+
echo "fetching latest X.Y.Z version for driver, X.Y version: $nodeVersionXY gave response: $nodeInfo"
83+
exit 1
84+
fi
85+
nodeTag=$(echo $nodeInfo | jq .tag | tr -d '"')
86+
87+
someFrontendTestsRan=true
88+
89+
tries=1
90+
while [ $tries -le 3 ]
91+
do
92+
tries=$(( $tries + 1 ))
93+
./setupAndTestWithFrontendWithDjango2x.sh $coreFree $frontendTag $nodeTag
94+
if [[ $? -ne 0 ]]
95+
then
96+
if [[ $tries -le 3 ]]
97+
then
98+
rm -rf ../../supertokens-root
99+
rm -rf ../../supertokens-website
100+
echo "failed test.. retrying!"
101+
else
102+
echo "test failed for website tests... exiting!"
103+
exit 1
104+
fi
105+
else
106+
rm -rf ../../supertokens-root
107+
rm -rf ../../supertokens-website
108+
break
109+
fi
110+
done
111+
done
112+
113+
if [[ $someFrontendTestsRan = "false" ]]
114+
then
115+
echo "no tests ran... failing!"
116+
exit 1
117+
fi

CHANGELOG.md

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,78 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [unreleased]
88

9-
### Documentation
9+
## [0.10.0] - 2022-07-04
10+
11+
- Update tests to cover `resend_code` feature in `passwordless` and `thirdpartypasswordless` recipe.
12+
- Update usermetadata tests to ensure that utf8 chars are supported.
13+
- Mark tests as skipped if core version requirements are not met.
14+
- Use [black](https://github.com/psf/black) instead of `autopep8` to format code.
15+
- Add frontend integration tests for `django2x`
16+
17+
### Bug fix:
18+
19+
- Clears cookies when `revoke_session` is called using the session container, even if the session did not exist from before: https://github.com/supertokens/supertokens-node/issues/343
20+
21+
### Breaking changes:
22+
- Change request arg type in session recipe functions from Any to BaseRequest.
23+
- Changes session function recipe interfaces to not throw an `UNAUTHORISED` error when the input is a session_handle: https://github.com/supertokens/backend/issues/83
24+
- `get_session_information` now returns `None` if the session does not exist.
25+
- `update_session_data` now returns `False` if the input `session_handle` does not exist.
26+
- `update_access_token_payload` now returns `False` if the input `session_handle` does not exist.
27+
- `regenerate_access_token` now returns `None` if the input access token's `session_handle` does not exist.
28+
- The `session_class` functions have not changed in behaviour and still throw `UNAUTHORISED` error. This works cause the `session_class` works on the current session and not some other session.
29+
30+
31+
### Features:
32+
- Adds default `user_context` for API calls that contains the request object. It can be used in APIs / functions override like this:
33+
34+
```python
35+
def apis_override_email_password(param: APIInterface):
36+
og_sign_in_post = param.sign_in_post
37+
38+
async def sign_in_post(
39+
form_fields: List[FormField],
40+
api_options: APIOptions,
41+
user_context: Dict[str, Any],
42+
):
43+
req = user_context.get("_default", {}).get("request")
44+
if req:
45+
# do something with the request
46+
47+
return await og_sign_in_post(form_fields, api_options, user_context)
1048

49+
param.sign_in_post = sign_in_post
50+
return param
51+
52+
def functions_override_email_password(param: RecipeInterface):
53+
og_sign_in = param.sign_in
54+
55+
async def sign_in(email: str, password: str, user_context: Dict[str, Any]):
56+
req = user_context.get("_default", {}).get("request")
57+
if req:
58+
# do something with the request
59+
60+
return await og_sign_in(email, password, user_context)
61+
62+
param.sign_in = sign_in
63+
return param
64+
65+
init(
66+
...,
67+
recipe_list=[
68+
emailpassword.init(
69+
override=emailpassword.InputOverrideConfig(
70+
apis=apis_override_email_password,
71+
functions=functions_override_email_password,
72+
)
73+
),
74+
session.init(),
75+
],
76+
)
77+
```
78+
79+
80+
### Documentation
1181
- Add more details in the `CONTRIBUTING.md` to make it beginner friendly.
1282

1383

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
help:
22
@echo " \x1b[33;1mcheck-lint: \x1b[0mtest styling of code for the library using flak8"
33
@echo " \x1b[33;1mtest: \x1b[0mruns pytest"
4-
@echo " \x1b[33;1mlint: \x1b[0mformat code using autopep8"
4+
@echo " \x1b[33;1mlint: \x1b[0mformat code using black"
55
@echo "\x1b[33;1mset-up-hooks: \x1b[0mset up various git hooks"
66
@echo " \x1b[33;1mdev-install: \x1b[0minstall all packages required for development"
77
@echo " \x1b[33;1mhelp: \x1b[0mprints this"
88

99
format:
10-
autopep8 -r -i -a supertokens_python tests examples
10+
black .
1111

1212
check-lint:
1313
pyright supertokens_python tests examples && pylint supertokens_python tests examples
@@ -34,6 +34,9 @@ with-fastapi:
3434
with-django:
3535
pip3 install -e .[django]
3636

37+
with-django2x:
38+
pip3 install -e .[django2x]
39+
3740
with-flask:
3841
pip3 install -e .[flask]
3942

dev-requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ anyio==3.5.0
22
asgiref==3.4.1
33
astroid==2.9.3
44
attrs==21.4.0
5-
autopep8==1.5.6
5+
black==22.3.0
66
certifi==2021.10.8
77
cffi==1.15.0
88
chardet==4.0.0
99
charset-normalizer==2.0.12
10-
click==7.1.2
10+
click==8.1.3
1111
cryptography==35.0.0
1212
Deprecated==1.2.13
1313
Django==3.2.12
@@ -76,7 +76,7 @@ types-PyYAML==6.0.5
7676
typing_extensions==4.1.1
7777
tzdata==2021.5
7878
urllib3==1.26.9
79-
uvicorn==0.13.4
79+
uvicorn==0.18.2
8080
Werkzeug==2.0.3
8181
wrapt==1.13.3
8282
zipp==3.7.0

examples/with-django/with-thirdpartyemailpassword/manage.py

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

77
def main():
88
"""Run administrative tasks."""
9-
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
9+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
1010
try:
1111
from django.core.management import execute_from_command_line
1212
except ImportError as exc:
@@ -18,5 +18,5 @@ def main():
1818
execute_from_command_line(sys.argv)
1919

2020

21-
if __name__ == '__main__':
21+
if __name__ == "__main__":
2222
main()

examples/with-django/with-thirdpartyemailpassword/project/asgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
from django.core.asgi import get_asgi_application
1313

14-
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
1515

1616
application = get_asgi_application()

0 commit comments

Comments
 (0)