Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: MFA #162

Merged
merged 120 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
f99cd8f
changes storage layer to take json instead of config file path
rishabhpoddar Jan 19, 2023
e16d29b
adds new functions skeleton
rishabhpoddar Jan 19, 2023
841e84e
adds checks for conflicting configs for user pools
rishabhpoddar Jan 19, 2023
f322888
changes to tests to make them pass
rishabhpoddar Jan 19, 2023
dacfeef
adds skeleton for multi tenancy functions
rishabhpoddar Jan 21, 2023
426e2ed
fixes bug
rishabhpoddar Jan 23, 2023
4178085
adds connection pool ID function
rishabhpoddar Jan 23, 2023
89761fb
changes as per interface change
rishabhpoddar Jan 23, 2023
b7b8b5d
adds one test for multi tenany storage layer
rishabhpoddar Jan 24, 2023
787d49c
adds more tests
rishabhpoddar Jan 24, 2023
32680ee
fixes bugs
rishabhpoddar Jan 24, 2023
a700b72
adds more tests and changes config parsing to prioritise connection u…
rishabhpoddar Jan 25, 2023
91b3e33
fixes a few config parsing bugs
rishabhpoddar Jan 25, 2023
4ce4383
adds more tests
rishabhpoddar Jan 25, 2023
b68aebb
modifies testing to clear multiple user pools after each test
rishabhpoddar Jan 28, 2023
55e8075
makes initlogging idempotent
rishabhpoddar Jan 31, 2023
cbc005b
fixes all tests
rishabhpoddar Feb 3, 2023
ccb6f73
fixes tests
rishabhpoddar Feb 5, 2023
9cbc85f
adds more placeholder functions
rishabhpoddar Feb 7, 2023
ea05ab3
removes use of quiteprogramexception
rishabhpoddar Feb 7, 2023
18fd7ae
small change
rishabhpoddar Feb 8, 2023
b61ddc7
adds new function skeleton
rishabhpoddar Feb 8, 2023
06a0643
adds more skeleton functions
rishabhpoddar Feb 9, 2023
0c0931f
updates exception import
rishabhpoddar Feb 9, 2023
489ec41
adds skeleton for tenantIdentifier for emailpassword and useridmappin…
rishabhpoddar Feb 13, 2023
8a988ea
changes to incorporate tenantIndetifier for key value storage
rishabhpoddar Feb 14, 2023
5a9a47d
changes to session receipe to add tenantIdentifier
rishabhpoddar Feb 14, 2023
1c39f03
introduces the concept of appIdentifier vs tenantIdentifier
rishabhpoddar Feb 15, 2023
6746329
fixes test compilation issues
rishabhpoddar Feb 15, 2023
cb724ee
changes as per plugin change
rishabhpoddar Feb 15, 2023
72f7ec1
modifes user roles functions to add tenantidentifier and appidentifiers
rishabhpoddar Feb 15, 2023
39b5690
modifies emailpassword functions
rishabhpoddar Feb 16, 2023
145a4be
changes to a few functions
rishabhpoddar Feb 17, 2023
ebd1131
adds appidentifier to email verfication
rishabhpoddar Feb 17, 2023
437f39e
makes tests pass
rishabhpoddar Feb 17, 2023
805a9a7
adds tenant identifier to third party
rishabhpoddar Feb 17, 2023
38d10b1
adds tenantidentifier to passwordless
rishabhpoddar Feb 17, 2023
7e0c165
function name changes
rishabhpoddar Feb 20, 2023
9ae2f2d
fix: Multitenancy schema updates (#59)
sattvikc Mar 3, 2023
ef3a0a5
merges with latest
rishabhpoddar Mar 5, 2023
4525dec
fix: Multitenant emailpassword recipe changes (#60)
sattvikc Mar 14, 2023
639cb7c
fix: minor fix (#62)
sattvikc Mar 17, 2023
baf6a86
fix: Multitenant schema changes (#64)
sattvikc Mar 24, 2023
4c36155
fix: to support PR comments on core (#65)
sattvikc Mar 25, 2023
0c467d1
fix: Multitenant userroles (#69)
sattvikc Mar 28, 2023
d282b12
fix: Multitenant usermetadata (#70)
sattvikc Mar 29, 2023
7a9adbc
fix: ep storage (#71)
sattvikc Mar 29, 2023
09729e7
fix: thirdparty storage (#74)
sattvikc Mar 31, 2023
7eb9f2a
fix: Multitenant thirdparty changes for update email (#75)
sattvikc Apr 3, 2023
8dc347c
fix: Multitenant emailverification storage (#76)
sattvikc Apr 3, 2023
105b5f0
fix: tokens tenant specific (#77)
sattvikc Apr 3, 2023
154b9b3
fix: Multitenant session (#78)
sattvikc Apr 4, 2023
7800c54
comment modification
rishabhpoddar Apr 5, 2023
aaa94c2
fix: Multitenant session changes (#80)
sattvikc Apr 5, 2023
8e71b3e
Multi tenant merging with latest (#79)
rishabhpoddar Apr 5, 2023
ac16c99
many fixes
rishabhpoddar Apr 6, 2023
af8c931
fix: jwt changes (#82)
sattvikc Apr 6, 2023
6ac571a
fix: Multitenant General Queries (#84)
sattvikc Apr 10, 2023
16e970d
fix: Multitenant dashboard (#85)
sattvikc Apr 10, 2023
546de37
fix: Multitenant totp (#86)
sattvikc Apr 11, 2023
94855c9
merges (#87)
rishabhpoddar Apr 13, 2023
9d1a3a2
adds new config
rishabhpoddar Apr 18, 2023
528ee86
fix: multitenancy changes (#88)
sattvikc Apr 21, 2023
741a9b2
fix: Misc changes (#89)
sattvikc Apr 24, 2023
6662fb5
feat: Introduce MFA recipe in postgresql plugin
KShivendu Apr 27, 2023
45e6e09
chores: Mention MFA recipe support in CHANGELOG
KShivendu Apr 27, 2023
0e2b0e6
fix: Tenantid in userobjects (#90)
sattvikc Apr 27, 2023
1933454
fix: test fix (#92)
sattvikc Apr 28, 2023
6c3664e
fix: Startup log (#93)
sattvikc Apr 28, 2023
2e44c54
fix: Userpool test (#94)
sattvikc May 1, 2023
890192c
fix: delete non auth user (#95)
sattvikc May 2, 2023
71485b7
fix: Delete nonauth user (#96)
sattvikc May 4, 2023
1797df2
feat: Add active user stat queries for MFA
KShivendu May 4, 2023
77beacc
fix: Update user_id length in mfa_user_factors table
KShivendu May 4, 2023
0744c44
Set factor_id VARCHAR length to 16
KShivendu May 4, 2023
2d00098
fix: config validation (#97)
sattvikc May 4, 2023
8a7c696
fix: config per tenant, per app annotations (#98)
sattvikc May 5, 2023
57740f4
Merge branch 'multi-tenant-config' into feat/mfa
KShivendu May 9, 2023
4e1d22b
feat: Consider multitenancy when getting MFA stats
KShivendu May 10, 2023
2268cf2
test: Fix mistake in MFA table create query
KShivendu May 10, 2023
2b30ca9
feat: Add query to delete user from a tenant
KShivendu May 10, 2023
bfda93f
fix: config annotation (#102)
sattvikc May 12, 2023
a153063
fix: added setLogLevels (#103)
sattvikc May 15, 2023
275d4ad
Merge branch '3.0' into multi-tenant-config
sattvikc May 15, 2023
1b841e9
fix: merge issue
sattvikc May 15, 2023
1da59bc
Overload deleteMfaInfoForUser and set factor column size to 64
KShivendu May 15, 2023
f261688
fix: fkey names (#104)
sattvikc May 17, 2023
42eb27e
fix: Postgres migration (#105)
sattvikc May 23, 2023
e2b9ab3
fix: Fkey indexes (#109)
sattvikc May 25, 2023
8e1865d
Merge branch 'multi-tenant-config' into feat/mfa
KShivendu May 26, 2023
cdc6949
refactor: Replace totp not enabled error with unknown device error
KShivendu Jun 27, 2023
4d6a335
fix: Revert irrelevant changes
KShivendu Jun 27, 2023
453081b
Merge branch '5.0' into merge-5.0
sattvikc Sep 28, 2023
4917483
Merge pull request #161 from supertokens/merge-5.0
sattvikc Sep 28, 2023
4cf61bb
refactor: Replace TotpNotEnabledError with UnknownUserIdTotpError (#133)
KShivendu Sep 28, 2023
e547b94
fix: queries
sattvikc Sep 29, 2023
31578e2
fix: changes as per plugin interface (#163)
sattvikc Oct 3, 2023
d3ab41b
fix: mfa cleanup (#164)
sattvikc Oct 17, 2023
b6ae4e6
Merge branch '5.0' into merge-latest
sattvikc Oct 20, 2023
ed5eee8
Merge pull request #168 from supertokens/merge-latest
sattvikc Oct 20, 2023
b3f7a73
Mfa multitenancy (#167)
sattvikc Oct 27, 2023
6ebaa47
fix: created_at in totp devices (#169)
sattvikc Oct 31, 2023
dba89ba
fix: mfa stats (#170)
sattvikc Nov 1, 2023
72589b2
fix: index name
sattvikc Nov 6, 2023
c03a7f1
Merge branch '5.0' into feat/mfa
sattvikc Nov 6, 2023
d40538a
Merge branch '5.0' into feat/mfa
sattvikc Nov 28, 2023
d6e27cc
Merge branch '5.0' into feat/mfa
sattvikc Dec 21, 2023
08043dc
fix: mfa changes (#177)
sattvikc Dec 25, 2023
87e64f2
feat: make refresh update the signing key type of sessions (#180)
porcellus Jan 29, 2024
15a4351
fix: Merge latest (#199)
sattvikc Feb 27, 2024
85b4e52
merge latest (#204)
sattvikc Mar 7, 2024
f24e2eb
fix: One million users test (#196)
sattvikc Mar 11, 2024
451289b
fix: pass appId to getUserIdMappingForSuperTokensIds
sattvikc Mar 13, 2024
b6f9065
fix: one million users test
sattvikc Mar 13, 2024
8f4b1a9
fix: versions
sattvikc Mar 13, 2024
68cb492
fix: versions
sattvikc Mar 13, 2024
ae791e1
Remaining changes (#206)
sattvikc Mar 13, 2024
c91dea7
fix: one million users
sattvikc Mar 13, 2024
eb32bd3
Merge branch 'remaining-changes' into feat/mfa
sattvikc Mar 13, 2024
7a06b1f
Merge branch '6.0' into feat/mfa
sattvikc Mar 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 102 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,88 @@ jobs:
name: running tests
command: (cd .circleci/ && ./doTests.sh)
- slack/status
test-onemillionusers:
docker:
- image: rishabhpoddar/supertokens_postgresql_plugin_test
resource_class: large
steps:
- add_ssh_keys:
fingerprints:
- "14:68:18:82:73:00:e4:fc:9e:f3:6f:ce:1d:5c:6d:c4"
- checkout
- run:
name: update postgresql max_connections
command: |
sed -i 's/^#*\s*max_connections\s*=.*/max_connections = 10000/' /etc/postgresql/9.5/main/postgresql.conf
- run:
name: starting postgresql
command: |
(cd / && ./runPostgreSQL.sh)
- run:
name: create databases
command: |
psql -c "create database st0;"
psql -c "create database st1;"
psql -c "create database st2;"
psql -c "create database st3;"
psql -c "create database st4;"
psql -c "create database st5;"
psql -c "create database st6;"
psql -c "create database st7;"
psql -c "create database st8;"
psql -c "create database st9;"
psql -c "create database st10;"
psql -c "create database st11;"
psql -c "create database st12;"
psql -c "create database st13;"
psql -c "create database st14;"
psql -c "create database st15;"
psql -c "create database st16;"
psql -c "create database st17;"
psql -c "create database st18;"
psql -c "create database st19;"
psql -c "create database st20;"
psql -c "create database st21;"
psql -c "create database st22;"
psql -c "create database st23;"
psql -c "create database st24;"
psql -c "create database st25;"
psql -c "create database st26;"
psql -c "create database st27;"
psql -c "create database st28;"
psql -c "create database st29;"
psql -c "create database st30;"
psql -c "create database st31;"
psql -c "create database st32;"
psql -c "create database st33;"
psql -c "create database st34;"
psql -c "create database st35;"
psql -c "create database st36;"
psql -c "create database st37;"
psql -c "create database st38;"
psql -c "create database st39;"
psql -c "create database st40;"
psql -c "create database st41;"
psql -c "create database st42;"
psql -c "create database st43;"
psql -c "create database st44;"
psql -c "create database st45;"
psql -c "create database st46;"
psql -c "create database st47;"
psql -c "create database st48;"
psql -c "create database st49;"
psql -c "create database st50;"
- run:
name: running tests
command: (cd .circleci/ && ./doOneMillionUsersTests.sh)
- slack/status
mark-passed:
docker:
- image: rishabhpoddar/supertokens_postgresql_plugin_test
steps:
- checkout
- run: (cd .circleci && ./markPassed.sh)
- slack/status

workflows:
version: 2
Expand All @@ -89,4 +171,23 @@ workflows:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
ignore: /.*/
- test-onemillionusers:
context:
- slack-notification
filters:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
- mark-passed:
context:
- slack-notification
filters:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
requires:
- test
- test-onemillionusers
135 changes: 135 additions & 0 deletions .circleci/doOneMillionUsersTests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
function cleanup {
if test -f "pluginInterfaceExactVersionsOutput"; then
rm pluginInterfaceExactVersionsOutput
fi
}

trap cleanup EXIT
cleanup

pluginInterfaceJson=`cat ../pluginInterfaceSupported.json`
pluginInterfaceLength=`echo $pluginInterfaceJson | jq ".versions | length"`
pluginInterfaceArray=`echo $pluginInterfaceJson | jq ".versions"`
echo "got plugin interface relations"

./getPluginInterfaceExactVersions.sh $pluginInterfaceLength "$pluginInterfaceArray"

if [[ $? -ne 0 ]]
then
echo "all plugin interfaces found... failed. exiting!"
exit 1
else
echo "all plugin interfaces found..."
fi

# get plugin version
pluginVersion=`cat ../build.gradle | grep -e "version =" -e "version="`
while IFS='"' read -ra ADDR; do
counter=0
for i in "${ADDR[@]}"; do
if [ $counter == 1 ]
then
pluginVersion=$i
fi
counter=$(($counter+1))
done
done <<< "$pluginVersion"

responseStatus=`curl -s -o /dev/null -w "%{http_code}" -X PUT \
https://api.supertokens.io/0/plugin \
-H 'Content-Type: application/json' \
-H 'api-version: 0' \
-d "{
\"password\": \"$SUPERTOKENS_API_KEY\",
\"planType\":\"FREE\",
\"version\":\"$pluginVersion\",
\"pluginInterfaces\": $pluginInterfaceArray,
\"name\": \"postgresql\"
}"`
if [ $responseStatus -ne "200" ]
then
echo "failed plugin PUT API status code: $responseStatus. Exiting!"
exit 1
fi

someTestsRan=false
while read -u 10 line
do
if [[ $line = "" ]]; then
continue
fi
i=0
currTag=`echo $line | jq .tag`
currTag=`echo $currTag | tr -d '"'`

currVersion=`echo $line | jq .version`
currVersion=`echo $currVersion | tr -d '"'`
piX=$(cut -d'.' -f1 <<<"$currVersion")
piY=$(cut -d'.' -f2 <<<"$currVersion")
piVersion="$piX.$piY"

someTestsRan=true

response=`curl -s -X GET \
"https://api.supertokens.io/0/plugin-interface/dependency/core/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$piVersion" \
-H 'api-version: 0'`
if [[ `echo $response | jq .core` == "null" ]]
then
echo "fetching latest X.Y version for core given plugin-interface X.Y version: $piVersion gave response: $response"
exit 1
fi
coreVersionX2=$(echo $response | jq .core | tr -d '"')

response=`curl -s -X GET \
"https://api.supertokens.io/0/core/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$coreVersionX2" \
-H 'api-version: 0'`
if [[ `echo $response | jq .tag` == "null" ]]
then
echo "fetching latest X.Y.Z version for core X.Y version: $coreVersionX2 gave response: $response"
exit 1
fi
coreVersionTag=$(echo $response | jq .tag | tr -d '"')

cd ../../
git clone [email protected]:supertokens/supertokens-root.git
cd supertokens-root

update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk-15.0.1/bin/java" 2
update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-15.0.1/bin/javac" 2

pluginX=$(cut -d'.' -f1 <<<"$pluginVersion")
pluginY=$(cut -d'.' -f2 <<<"$pluginVersion")
echo -e "core,$coreVersionX2\nplugin-interface,$piVersion\npostgresql-plugin,$pluginX.$pluginY" > modules.txt
./loadModules
cd supertokens-core
git checkout $coreVersionTag
cd ../supertokens-plugin-interface
git checkout $currTag
cd ../supertokens-postgresql-plugin
git checkout dev-v$pluginVersion
cd ../
echo $SUPERTOKENS_API_KEY > apiPassword
export ONE_MILLION_USERS_TEST=1
./utils/setupTestEnv --cicd
./gradlew :supertokens-postgresql-plugin:test --tests io.supertokens.storage.postgresql.test.OneMillionUsersTest

if [[ $? -ne 0 ]]
then
cat logs/*
cd ../project/
echo "test failed... exiting!"
exit 1
fi
cd ../
rm -rf supertokens-root
cd project/.circleci
done 10<pluginInterfaceExactVersionsOutput

if [[ $someTestsRan = "true" ]]
then
echo "all tests ran"
exit 0
else
echo "no test ran"
exit 1
fi
19 changes: 2 additions & 17 deletions .circleci/doTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,8 @@ done 10<pluginInterfaceExactVersionsOutput

if [[ $someTestsRan = "true" ]]
then
echo "calling /core PATCH to make testing passed"
responseStatus=`curl -s -o /dev/null -w "%{http_code}" -X PATCH \
https://api.supertokens.io/0/plugin \
-H 'Content-Type: application/json' \
-H 'api-version: 0' \
-d "{
\"password\": \"$SUPERTOKENS_API_KEY\",
\"planType\":\"FREE\",
\"name\":\"postgresql\",
\"version\":\"$pluginVersion\",
\"testPassed\": true
}"`
if [ $responseStatus -ne "200" ]
then
echo "patch api failed"
exit 1
fi
echo "all tests ran"
exit 0
else
echo "no test ran"
exit 1
Expand Down
29 changes: 29 additions & 0 deletions .circleci/markPassed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pluginVersion=`cat ../build.gradle | grep -e "version =" -e "version="`
while IFS='"' read -ra ADDR; do
counter=0
for i in "${ADDR[@]}"; do
if [ $counter == 1 ]
then
pluginVersion=$i
fi
counter=$(($counter+1))
done
done <<< "$pluginVersion"

echo "calling /core PATCH to make testing passed"
responseStatus=`curl -s -o /dev/null -w "%{http_code}" -X PATCH \
https://api.supertokens.io/0/plugin \
-H 'Content-Type: application/json' \
-H 'api-version: 0' \
-d "{
\"password\": \"$SUPERTOKENS_API_KEY\",
\"planType\":\"FREE\",
\"name\":\"postgresql\",
\"version\":\"$pluginVersion\",
\"testPassed\": true
}"`
if [ $responseStatus -ne "200" ]
then
echo "patch api failed"
exit 1
fi
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- [ ] Issue this PR against the latest non released version branch.
- To know which one it is, run find the latest released tag (`git tag`) in the format `vX.Y.Z`, and then find the latest branch (`git branch --all`) whose `X.Y` is greater than the latest released tag.
- If no such branch exists, then create one from the latest released branch.

- [ ] When adding new recipes, ensure that its performance is being measured in the `OneMillionUsersTest`
## Remaining TODOs for this PR
- [ ] Item1
- [ ] Item2
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved
## [7.0.0] - 2024-03-13

- Replace `TotpNotEnabledError` with `UnknownUserIdTotpError`.
- Support for MFA recipe
- Adds a new `useStaticKey` param to `updateSessionInfo_Transaction`
- This enables smooth switching between `useDynamicAccessTokenSigningKey` settings by allowing refresh calls to
change the signing key type of a session

## [6.0.0] - 2024-03-05

- Implements `deleteAllUserRoleAssociationsForRole`
Expand Down Expand Up @@ -151,7 +159,6 @@ CREATE INDEX IF NOT EXISTS app_id_to_user_id_primary_user_id_index ON app_id_to_
```
4. Run the new instance(s) of the core (version 7.0.0)


## [4.0.2]

- Fixes null pointer issue when user belongs to no tenant.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'java-library'
}

version = "6.0.0"
version = "7.0.0"

repositories {
mavenCentral()
Expand Down
Binary file added jar/postgresql-plugin-7.0.0.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion pluginInterfaceSupported.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"_comment": "contains a list of plugin interfaces branch names that this core supports",
"versions": [
"5.0"
"6.0"
]
}
Loading
Loading