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: Introduce MFA recipe #651

Merged
merged 245 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 231 commits
Commits
Show all changes
245 commits
Select commit Hold shift + click to select a range
ed729ef
adds connection uri and tenant id based resource distributor
rishabhpoddar Jan 13, 2023
10afc48
removes unnecessary file
rishabhpoddar Jan 13, 2023
65012d9
adds a bunch of todos
rishabhpoddar Jan 13, 2023
737563e
adds storage layer function and also laod all configs function
rishabhpoddar Jan 16, 2023
19aade1
implements core config merging across tenants
rishabhpoddar Jan 16, 2023
7ed1b8c
restructures code related to config checking in core
rishabhpoddar Jan 19, 2023
5723ba1
changes storage layer to take json instead of config file path
rishabhpoddar Jan 19, 2023
3ef6397
small refactor
rishabhpoddar Jan 19, 2023
650cffe
adds ability to create new storage instances on the fly
rishabhpoddar Jan 19, 2023
1af722e
in mem db function impl for user pool ID and config conflict checking
rishabhpoddar Jan 19, 2023
b552ff8
small change
rishabhpoddar Jan 19, 2023
67382e5
adds checks for conflicting core configs
rishabhpoddar Jan 20, 2023
76d7492
adds a few tests for multi tenant config
rishabhpoddar Jan 21, 2023
2ac6616
adds more tests
rishabhpoddar Jan 23, 2023
1b0d182
more tests
rishabhpoddar Jan 23, 2023
ba2923b
adds function to get connection pool ID
rishabhpoddar Jan 23, 2023
40ad561
adds skeleton for loading storage layers for tenants
rishabhpoddar Jan 23, 2023
cb6e6d8
fixes compile error
rishabhpoddar Jan 23, 2023
579056b
adds code to load multiple storage layers as well
rishabhpoddar Jan 23, 2023
7c37142
deletes info across all tenants during testing
rishabhpoddar Jan 24, 2023
392a8b0
adds one test for storage layer
rishabhpoddar Jan 24, 2023
1f35011
fixes a test
rishabhpoddar Jan 24, 2023
079ed01
fixes bug in setting resource in resource distributor
rishabhpoddar Jan 24, 2023
c69ca66
fixes bugs
rishabhpoddar Jan 24, 2023
5c2000d
loads signing keys for all tenants
rishabhpoddar Jan 27, 2023
0fcaf35
fixes bug
rishabhpoddar Jan 28, 2023
980f6c3
adds new test and modifies the testing kill process to clear database…
rishabhpoddar Jan 28, 2023
2280002
implements more test
rishabhpoddar Jan 29, 2023
3cc9229
small change to formatting
rishabhpoddar Jan 29, 2023
a0ffc14
small change to formatting
rishabhpoddar Jan 29, 2023
f486e87
modifies cron jobs to run per unique user pool ID
rishabhpoddar Jan 30, 2023
04da733
fixes a few bugs
rishabhpoddar Jan 30, 2023
e25e77b
disallows different argon2 pool size across tenants
rishabhpoddar Jan 30, 2023
880efa6
changes server api key check to be based on connection uri as well
rishabhpoddar Jan 30, 2023
c5fd6af
adds function for getTenantId
rishabhpoddar Jan 30, 2023
3473ca1
modfies delete user API as well
rishabhpoddar Jan 30, 2023
a21a797
makes tests compile
rishabhpoddar Jan 30, 2023
60183b1
marked getStorageLayer older version as testonly
rishabhpoddar Jan 31, 2023
7cc2b2a
fixes a few tests
rishabhpoddar Jan 31, 2023
cca497b
removes unused storage layer when loading them for all tenants
rishabhpoddar Jan 31, 2023
22e0558
makes storagelayer.getAuthRecipeStorage testonly
rishabhpoddar Jan 31, 2023
4b22901
makes storagelayer.getSession testonly
rishabhpoddar Jan 31, 2023
8c2b129
makes storagelayer.getEmailPasswordStorage testonly
rishabhpoddar Jan 31, 2023
0d09a2f
makes storagelayer.getEmailVerificationStorage testonly
rishabhpoddar Jan 31, 2023
a9e64cd
makes storagelayer.getThirdPartyStorage testonly
rishabhpoddar Feb 1, 2023
cad8f0e
makes storagelayer.getPasswordlessStorage testonly
rishabhpoddar Feb 1, 2023
b3b985f
more updates to storage layer functions and reciope
rishabhpoddar Feb 1, 2023
d0254c3
completes all storage layer function changes
rishabhpoddar Feb 1, 2023
a13bc0f
makes Config.getConfig testonly
rishabhpoddar Feb 1, 2023
be3c07d
implements custom routing class for api requests
rishabhpoddar Feb 2, 2023
5f9386c
fixes a few bugs
rishabhpoddar Feb 2, 2023
00b6623
adds test cases
rishabhpoddar Feb 2, 2023
5a3af02
adds tenant not found logic
rishabhpoddar Feb 2, 2023
d59f2ce
adds new exception
rishabhpoddar Feb 2, 2023
f5ef883
fixes all tests
rishabhpoddar Feb 3, 2023
3ed429e
removes unnecessary exception catching
rishabhpoddar Feb 3, 2023
72d0c6a
fixes bug
rishabhpoddar Feb 3, 2023
d6ce9c9
adds test for path router
rishabhpoddar Feb 3, 2023
37d3545
adds more tests
rishabhpoddar Feb 3, 2023
07a6872
adds more tests
rishabhpoddar Feb 4, 2023
b6a9a5f
adds more tests
rishabhpoddar Feb 4, 2023
2f84fa7
changes defaulttenantid to public
rishabhpoddar Feb 5, 2023
10e8bf3
adds appId as a identifier for a unique tenant
rishabhpoddar Feb 5, 2023
fcb6f46
adds extracting appId from request path
rishabhpoddar Feb 6, 2023
5dd7758
small change
rishabhpoddar Feb 6, 2023
bece81e
fixes bug with extarcting tenantid with appid
rishabhpoddar Feb 6, 2023
0478a11
fixes bug
rishabhpoddar Feb 6, 2023
3998dc5
adds more tests
rishabhpoddar Feb 6, 2023
008bb05
starts working on multitenancy class and utils functions
rishabhpoddar Feb 6, 2023
9aa00ea
more changes to multitenancy file
rishabhpoddar Feb 6, 2023
5e7fb35
fixes a bug
rishabhpoddar Feb 6, 2023
6c694d8
small change
rishabhpoddar Feb 6, 2023
d0de2ab
ads crud functions for multi tenancy
rishabhpoddar Feb 7, 2023
65d281f
changes to use of quiteprogramexception from in mem db
rishabhpoddar Feb 7, 2023
7a0a463
adds skeleton for multitenancy functions in in mem db
rishabhpoddar Feb 7, 2023
5b42380
adds a few todos
rishabhpoddar Feb 7, 2023
d649a35
small change
rishabhpoddar Feb 7, 2023
16cde70
small change
rishabhpoddar Feb 8, 2023
393eb73
adds more functions to multi tenancy impl
rishabhpoddar Feb 8, 2023
39c6f9a
adds multi tenancy functions to delete and get info
rishabhpoddar Feb 9, 2023
24409dc
fixes tests
rishabhpoddar Feb 9, 2023
2e4e778
adds a few exception cases
rishabhpoddar Feb 9, 2023
420bc89
updates exception import
rishabhpoddar Feb 9, 2023
fc8e0bd
small change to make debugging easier
rishabhpoddar Feb 9, 2023
de0857f
fixes logging related issue in test
rishabhpoddar Feb 9, 2023
2cbf3d3
checks for permission when creating a new app
rishabhpoddar Feb 10, 2023
e6971e8
simplifies delete of app and connectionuridomain
rishabhpoddar Feb 10, 2023
8b7c1d9
adds sync to respirce distributor
rishabhpoddar Feb 10, 2023
6d44933
small change
rishabhpoddar Feb 10, 2023
5e71bcc
small changes
rishabhpoddar Feb 11, 2023
4e68a65
checks if multi tenancy is enabled in license key during tenant creation
rishabhpoddar Feb 11, 2023
17b673d
adds FeatureNotEnabledException exception
rishabhpoddar Feb 11, 2023
075c3ea
small refactor
rishabhpoddar Feb 12, 2023
ca9e05d
fixes deadlock condition
rishabhpoddar Feb 12, 2023
2d9c45c
fixes in memory db issue
rishabhpoddar Feb 12, 2023
51d8935
does deep equals in tenant refresh function
rishabhpoddar Feb 12, 2023
db79ae4
small change
rishabhpoddar Feb 12, 2023
a3506d6
adds more checks when adding or updating a tenant
rishabhpoddar Feb 13, 2023
70f813b
adds tenantIdentifier for emailpassword and useridmapping recipes
rishabhpoddar Feb 13, 2023
dc8ce7b
enforces unique user pool id per connectionuridomain
rishabhpoddar Feb 13, 2023
2fa639a
small bug fix for refreshing cronjobs
rishabhpoddar Feb 13, 2023
0f0a056
makes cronjob run per user pool, but pass list of tenants within that…
rishabhpoddar Feb 13, 2023
6b7c101
changes to incorporate tenantIndetifier for key value storage
rishabhpoddar Feb 14, 2023
40aa1cd
changes to session receipe to add tenantIdentifier
rishabhpoddar Feb 14, 2023
9c8df63
adds a todo
rishabhpoddar Feb 15, 2023
4e67acd
introduces the concept of appIdentifier vs tenantIdentifier
rishabhpoddar Feb 15, 2023
9884599
fixes test compilation issues
rishabhpoddar Feb 15, 2023
75b8368
fixes bugs from existing tests
rishabhpoddar Feb 15, 2023
9647521
adds appidentifier to user metadata functions
rishabhpoddar Feb 15, 2023
b2ceb7b
modifes user roles functions to add tenantidentifier and appidentifiers
rishabhpoddar Feb 15, 2023
2fa1545
small refactor
rishabhpoddar Feb 15, 2023
dd28dd2
modifies session recipe to add tenantId as part of the access token a…
rishabhpoddar Feb 16, 2023
809bbec
small change
rishabhpoddar Feb 16, 2023
5da2469
fixes a bug
rishabhpoddar Feb 16, 2023
99cfe56
modifies emailpassword functions
rishabhpoddar Feb 16, 2023
408a23b
changes to a few functions
rishabhpoddar Feb 17, 2023
fb49caf
adds appidentifier to email verfication
rishabhpoddar Feb 17, 2023
50a7588
adds tenant identifier to third party
rishabhpoddar Feb 17, 2023
d30c7a7
adds tenantidentifier to passwordless
rishabhpoddar Feb 17, 2023
0a25a6f
changes how tenant configs are checked
rishabhpoddar Feb 18, 2023
15878a2
fixes tests
rishabhpoddar Feb 18, 2023
2f9bf4c
Merge branch '4.3' into multi-tenant-config
rishabhpoddar Feb 19, 2023
06af9d1
small bug fixes
rishabhpoddar Feb 20, 2023
cd15057
fix: config tests (#568)
sattvikc Feb 24, 2023
998845b
fix: new exceptions and tests (#573)
sattvikc Mar 3, 2023
0fce90f
merges with latest
rishabhpoddar Mar 5, 2023
191eec3
merges with latest
rishabhpoddar Mar 9, 2023
4b83b04
Merge branch '4.4' into multi-tenant-config
rishabhpoddar Mar 18, 2023
8ab4dbe
makes telemetry and feature flag multi tenant as well - per app
rishabhpoddar Mar 18, 2023
e0e89cc
refactors crontask to be better suited for multi tenancy
rishabhpoddar Mar 19, 2023
ac90e8d
fix: Email password and user id mapping multi tenancy changes (#580)
sattvikc Mar 27, 2023
209075b
fixes test
rishabhpoddar Mar 27, 2023
9995ce0
fix: Multitenant userroles (#600)
sattvikc Mar 28, 2023
4f1018d
fix: Multitenant usermetadata (#605)
sattvikc Mar 29, 2023
28d139b
fix: emailpassword storage (#607)
sattvikc Mar 29, 2023
477617c
fix: uid mapping storage (#608)
sattvikc Mar 29, 2023
92ae0eb
fix: multitenant ep tests (#609)
sattvikc Mar 29, 2023
75e35bd
fix: Multitenant user id mapping tests (#611)
sattvikc Mar 30, 2023
2e936a7
fix: Multitenant API, storage and tests (#614)
sattvikc Mar 31, 2023
0b200e8
fix: Multitenant thirdparty API, storage and tests (#616)
sattvikc Apr 3, 2023
b435ae7
fix: Multitenant emailverification (#618)
sattvikc Apr 3, 2023
05e052e
fix: Multitenant session (#619)
sattvikc Apr 5, 2023
faa751e
merges with latest (#622)
rishabhpoddar Apr 5, 2023
6ae2c09
several fixes
rishabhpoddar Apr 6, 2023
7e9b5db
fix: Multitenant jwt (#629)
sattvikc Apr 6, 2023
2351148
fix: Multitenant Auth Recipe (#633)
sattvikc Apr 10, 2023
3c2f6aa
fix: Multitenant dashboard (#636)
sattvikc Apr 10, 2023
16938d4
fix: Multitenant totp (#637)
sattvikc Apr 11, 2023
e618b57
merges (#638)
rishabhpoddar Apr 13, 2023
2893edc
adds new config (#639)
rishabhpoddar Apr 18, 2023
fb9d2e0
makes test more reliable
rishabhpoddar Apr 18, 2023
6637bac
removes unnecessary deprecated annotation (#640)
rishabhpoddar Apr 18, 2023
680f8bb
fix: multitenancy changes (#641)
sattvikc Apr 24, 2023
56654d0
fix: Misc changes (#645)
sattvikc Apr 24, 2023
4b1b040
fix: Tenantid logging (#646)
sattvikc Apr 25, 2023
04eaf12
fix: Rate limiting hello (#647)
sattvikc Apr 25, 2023
a9ef7cd
fix: multitenancy stats (#649)
sattvikc Apr 26, 2023
8343f62
fix: Tenantid in userobjects (#650)
sattvikc Apr 27, 2023
968f3d0
feat: Introduce MFA recipe
KShivendu Apr 27, 2023
88fa059
fix: Ip filter per tenant (#652)
sattvikc Apr 28, 2023
d61b9d6
fix: updated console log (#653)
sattvikc Apr 28, 2023
3e51187
fix: API key per app (#654)
sattvikc Apr 28, 2023
87561c9
feat: Add EE feature for MFA functions
KShivendu Apr 28, 2023
af71e6e
fix: Fix didExist of factor disable API
KShivendu Apr 28, 2023
5dde394
fix: Startup log (#655)
sattvikc Apr 28, 2023
f4aa012
fix: License tests (#656)
sattvikc May 1, 2023
5892703
test: Config normalisation test (#658)
sattvikc May 1, 2023
805f78f
feat: Suggested changes along with tests
KShivendu May 3, 2023
ff08fbb
fix: delete non auth user in deleteUserIdFromTenantId (#659)
sattvikc May 4, 2023
857d8bb
fix: thirdparty related tests (#661)
sattvikc May 4, 2023
ce1b6ad
feat: Add MFA EE features and user id mapping related tests
KShivendu May 4, 2023
b27d3d7
fix: Remove irrelevant multitenancy change
KShivendu May 4, 2023
44f8cd2
fix: Config validation (#662)
sattvikc May 4, 2023
8681f4b
fix: config per tenant, per app annotations and validation (#666)
sattvikc May 5, 2023
e603db2
fix: pagination test (#667)
sattvikc May 5, 2023
533a4e1
fix: added version check for multitenant apis (#669)
sattvikc May 8, 2023
bd49eb0
fix: clean up init keys (#670)
sattvikc May 8, 2023
8ef3d69
fix: removed isTesting check in prod code (#671)
sattvikc May 9, 2023
09ba912
Merge branch 'multi-tenant-config' into feat/mfa
KShivendu May 9, 2023
fe17f1c
fix: Suggested changes
KShivendu May 9, 2023
8dc54da
test: Improve MFA delete user test
KShivendu May 10, 2023
73f5391
test: Fix all tests and inherit from MFaTestBase
KShivendu May 10, 2023
4daef01
feat: Add function to delete user from a tenant and test it
KShivendu May 10, 2023
21dafb1
fix: resource reloading (#673)
sattvikc May 12, 2023
43e0847
fix: fixed missing log (#678)
sattvikc May 15, 2023
db50dd1
Overload deleteMfaInfoForUser and set factor column size to 64
KShivendu May 15, 2023
5dbf1d2
Merge branch '5.0' into multi-tenant-config
sattvikc May 16, 2023
e22efee
fix: merge issues (#680)
sattvikc May 16, 2023
a01f0f0
fix: session v4 (#683)
sattvikc May 22, 2023
83ea154
fix: Postgres migration (#685)
sattvikc May 23, 2023
dcf11c2
fix: fixed tests for active user storage (#686)
sattvikc May 25, 2023
0bfc5af
Merge branch 'multi-tenant-config' into feat/mfa
KShivendu May 26, 2023
3092003
Merge branch 'master' into feat/mfa
KShivendu Jun 26, 2023
a55de25
refactor: Remove irrelevant changes from merge conflict
KShivendu Jun 26, 2023
2a7afe7
chores: Mention new MFA recipe in CHANGELOG
KShivendu Jun 26, 2023
9431aea
chores: Bring back ActiveUsers function implementation
KShivendu Jun 26, 2023
7f0b78d
Merge branch 'master' into feat/mfa
KShivendu Sep 27, 2023
9cd4ef2
Merge branch '7.0' into merge-7.0
sattvikc Sep 28, 2023
d54d88c
Merge pull request #824 from supertokens/merge-7.0
sattvikc Sep 28, 2023
49b6a51
fix: tests
sattvikc Sep 28, 2023
0387df7
refactor: Replace TOTP_NOT_ENABLED_ERROR status and make deviceName o…
KShivendu Sep 28, 2023
bbd412b
fix: tests
sattvikc Sep 29, 2023
dd56d93
fix: mfa and totp queries
sattvikc Sep 29, 2023
6edab81
fix: flaky tests
sattvikc Oct 3, 2023
8b17c95
Merge pull request #826 from supertokens/misc-fixes
sattvikc Oct 3, 2023
971e21d
fix: mfa cleanup (#837)
sattvikc Oct 17, 2023
e057f48
Merge branch '7.0' into merge-latest
sattvikc Oct 19, 2023
e7725f5
Merge pull request #862 from supertokens/merge-latest
sattvikc Oct 19, 2023
da5dfa2
Mfa multitenancy (#841)
sattvikc Oct 27, 2023
440980b
Mfa accountlinking (#867)
sattvikc Oct 27, 2023
7ca13a6
Mfa firstfactor in sign in or up (#868)
sattvikc Oct 27, 2023
6726998
fix: import totp device API (#869)
sattvikc Oct 27, 2023
148c72a
fix: add createdat to totp device (#870)
sattvikc Oct 31, 2023
edb4c2e
fix: mfa stats
sattvikc Oct 31, 2023
504c8e3
fix: active users data saved into public tenant storage
sattvikc Nov 1, 2023
6dcca66
fix: pr comments
sattvikc Nov 1, 2023
7850720
fix: pr comments
sattvikc Nov 1, 2023
3e8ae02
fix: pr comment
sattvikc Nov 1, 2023
c10aff7
Merge pull request #871 from supertokens/mfa-stats
sattvikc Nov 1, 2023
6cd3c59
Mfa inmemory (#874)
sattvikc Nov 6, 2023
51f1da7
Merge branch '7.0' into feat/mfa
sattvikc Nov 6, 2023
a0c0581
fix: test
sattvikc Nov 6, 2023
71f09f1
fix: totp APIs and flaky tests fix (#879)
sattvikc Nov 15, 2023
fbf0243
fix: response
sattvikc Nov 15, 2023
6190d9d
Merge branch '7.0' into feat/mfa
sattvikc Nov 28, 2023
cbd7de3
fix: version update
sattvikc Nov 29, 2023
9a62680
fix: changelog
sattvikc Nov 29, 2023
530f869
fix: remove MFA apis
sattvikc Dec 11, 2023
755ac1d
fix: remove isValidFirstFactor
sattvikc Dec 12, 2023
1c56021
fix: revert account linking api
sattvikc Dec 13, 2023
350c973
Mfa changes (#901)
sattvikc Dec 20, 2023
b09ea39
fix: createNewRecipeUser input in consume code API (#910)
sattvikc Jan 27, 2024
9ef8d5f
feat: make refresh sync signing key setting (#909)
porcellus Jan 29, 2024
f884b13
fix: totp import api (#915)
sattvikc Jan 29, 2024
7164a2b
fix: Fake email verified for emailpassword sign up (#913)
sattvikc Jan 30, 2024
e1fcd0c
Merge 7.0 (#940)
sattvikc Feb 27, 2024
4a3a63d
merge latest (#947)
sattvikc Mar 7, 2024
3f46b5d
fix: add check code API and update delete code API (#948)
sattvikc Mar 11, 2024
697eafc
Merge branch '8.0' into merge-8
sattvikc Mar 13, 2024
b44fbe7
fix: revert formatting
sattvikc Mar 13, 2024
a6992c8
fix: revert formatting
sattvikc Mar 13, 2024
d44fdba
Merge pull request #955 from supertokens/merge-8
sattvikc Mar 13, 2024
c4ba0b1
feat: merge last active times when linking users (#954)
porcellus Mar 13, 2024
941bc67
Remaining changes (#956)
sattvikc Mar 13, 2024
60e5b69
fix: fixme
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
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,33 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [8.0.0] - 2023-11-29

### Added

- Supports CDI version `5.0`
- MFA stats in `EEFeatureFlag`
- Adds `ImportTotpDeviceAPI`

### Changes

- `deviceName` in request body of `CreateOrUpdateTotpDeviceAPI` `POST` is now optional
- Adds `firstFactors` and `requiredSecondaryFactors` in request body of create or update CUD, App and
Tenant APIs
- Adds `deviceName` in the response of `CreateOrUpdateTotpDeviceAPI` `POST`
- `VerifyTOTPAPI` changes
- Removes `allowUnverifiedDevices` from request body and unverified devices are not allowed
- Adds `currentNumberOfFailedAttempts` and `maxNumberOfFailedAttempts` in response when status is
`INVALID_TOTP_ERROR` or `LIMIT_REACHED_ERROR`
- Adds status `UNKNOWN_USER_ID_ERROR`
- `VerifyTotpDeviceAPI` changes
- Adds `currentNumberOfFailedAttempts` and `maxNumberOfFailedAttempts` in response when status is
`INVALID_TOTP_ERROR` or `LIMIT_REACHED_ERROR`

### Migration

- TODO - copy once postgres / mysql changelog is done
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO


## [7.0.14] - 2023-11-21

- Updates test user query speed
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ compileTestJava { options.encoding = "UTF-8" }
// }
//}

version = "7.0.14"
version = "8.0.0"


repositories {
Expand Down
5 changes: 3 additions & 2 deletions coreDriverInterfaceSupported.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"2.20",
"2.21",
"3.0",
"4.0"
"4.0",
"5.0"
]
}
}
59 changes: 27 additions & 32 deletions ee/src/main/java/io/supertokens/ee/EEFeatureFlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,44 +185,38 @@ private JsonObject getDashboardLoginStats() throws TenantOrAppNotFoundException,
return stats;
}

private JsonObject getTOTPStats() throws StorageQueryException, TenantOrAppNotFoundException {
JsonObject totpStats = new JsonObject();
JsonArray totpMauArr = new JsonArray();
private boolean isEnterpriseThirdPartyId(String thirdPartyId) {
for (String enterpriseThirdPartyId : ENTERPRISE_THIRD_PARTY_IDS) {
if (thirdPartyId.startsWith(enterpriseThirdPartyId)) {
return true;
}
}
return false;
}

private JsonObject getMFAStats() throws StorageQueryException, TenantOrAppNotFoundException{
// TODO: Active users are present only on public tenant and MFA users may be present on different storages
JsonObject result = new JsonObject();
Storage[] storages = StorageLayer.getStoragesForApp(main, this.appIdentifier);

// TODO Active users are present only on public tenant and TOTP users may be present on different storages
Storage publicTenantStorage = StorageLayer.getStorage(this.appIdentifier.getAsPublicTenantIdentifier(), main);
final long now = System.currentTimeMillis();
for (int i = 0; i < 30; i++) {
long today = now - (now % (24 * 60 * 60 * 1000L));
long timestamp = today - (i * 24 * 60 * 60 * 1000L);

int totpMau = 0;
// TODO Need to figure out a way to combine the data from different storages to get the final stats
// for (Storage storage : storages) {
totpMau += ((ActiveUsersStorage) publicTenantStorage).countUsersEnabledTotpAndActiveSince(this.appIdentifier, timestamp);
// }
totpMauArr.add(new JsonPrimitive(totpMau));
}
int totalUserCountWithMoreThanOneLoginMethod = 0;
int[] maus = new int[30];

totpStats.add("maus", totpMauArr);
long now = System.currentTimeMillis();
long today = now - (now % (24 * 60 * 60 * 1000L));

int totpTotalUsers = 0;
for (Storage storage : storages) {
totpTotalUsers += ((ActiveUsersStorage) storage).countUsersEnabledTotp(this.appIdentifier);
}
totpStats.addProperty("total_users", totpTotalUsers);
return totpStats;
}
totalUserCountWithMoreThanOneLoginMethod += ((AuthRecipeStorage)storage).getUsersCountWithMoreThanOneLoginMethodOrTOTPEnabled(this.appIdentifier);

private boolean isEnterpriseThirdPartyId(String thirdPartyId) {
for (String enterpriseThirdPartyId : ENTERPRISE_THIRD_PARTY_IDS) {
if (thirdPartyId.startsWith(enterpriseThirdPartyId)) {
return true;
for (int i = 0; i < 30; i++) {
long timestamp = today - (i * 24 * 60 * 60 * 1000L);
maus[i] += ((ActiveUsersStorage)storage).countUsersThatHaveMoreThanOneLoginMethodOrTOTPEnabledAndActiveSince(appIdentifier, timestamp);
}
}
return false;

result.addProperty("totalUserCountWithMoreThanOneLoginMethodOrTOTPEnabled", totalUserCountWithMoreThanOneLoginMethod);
result.add("mauWithMoreThanOneLoginMethodOrTOTPEnabled", new Gson().toJsonTree(maus));
return result;
}

private JsonObject getMultiTenancyStats()
Expand Down Expand Up @@ -273,6 +267,7 @@ private JsonObject getMultiTenancyStats()
}

private JsonObject getAccountLinkingStats() throws StorageQueryException {
// TODO: Active users are present only on public tenant and MFA users may be present on different storages
JsonObject result = new JsonObject();
Storage[] storages = StorageLayer.getStoragesForApp(main, this.appIdentifier);
boolean usesAccountLinking = false;
Expand Down Expand Up @@ -355,8 +350,8 @@ public JsonObject getPaidFeatureStats() throws StorageQueryException, TenantOrAp
usageStats.add(EE_FEATURES.DASHBOARD_LOGIN.toString(), getDashboardLoginStats());
}

if (feature == EE_FEATURES.TOTP) {
usageStats.add(EE_FEATURES.TOTP.toString(), getTOTPStats());
if (feature == EE_FEATURES.MFA) {
usageStats.add(EE_FEATURES.MFA.toString(), getMFAStats());
}

if (feature == EE_FEATURES.MULTI_TENANCY) {
Expand Down Expand Up @@ -570,4 +565,4 @@ public static void resetLisenseCheckRequests() {
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void testPaidStatsIsSentForAllAppsInMultitenancy() throws Exception {
new EmailPasswordConfig(true),
new ThirdPartyConfig(true, null),
new PasswordlessConfig(true),
null, null,
config
), false);

Expand All @@ -86,6 +87,7 @@ public void testPaidStatsIsSentForAllAppsInMultitenancy() throws Exception {
new EmailPasswordConfig(true),
new ThirdPartyConfig(true, null),
new PasswordlessConfig(true),
null, null,
config
), false);

Expand All @@ -94,6 +96,7 @@ public void testPaidStatsIsSentForAllAppsInMultitenancy() throws Exception {
new EmailPasswordConfig(true),
new ThirdPartyConfig(true, null),
new PasswordlessConfig(true),
null, null,
config
), false);
}
Expand Down
Binary file added jar/core-5.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": [
"4.0"
"5.0"
]
}
6 changes: 3 additions & 3 deletions src/main/java/io/supertokens/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ private void init() throws IOException, StorageQueryException {
throw new QuitProgramException(e);
}

// loading version file
Version.loadVersion(this, CLIOptions.get(this).getInstallationPath() + "version.yaml");

Logging.info(this, TenantIdentifier.BASE_TENANT, "Completed config.yaml loading.", true);

// loading storage layer
Expand All @@ -167,9 +170,6 @@ private void init() throws IOException, StorageQueryException {
throw new QuitProgramException(e);
}

// loading version file
Version.loadVersion(this, CLIOptions.get(this).getInstallationPath() + "version.yaml");

// init file logging
Logging.initFileLogging(this);

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/io/supertokens/authRecipe/AuthRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public static LinkAccountsResult linkAccounts(Main main, AppIdentifierWithStorag
UnknownUserIdException, TenantOrAppNotFoundException, FeatureNotEnabledException {

if (Arrays.stream(FeatureFlag.getInstance(main, appIdentifierWithStorage).getEnabledFeatures())
.noneMatch(t -> t == EE_FEATURES.ACCOUNT_LINKING)) {
.noneMatch(t -> (t == EE_FEATURES.ACCOUNT_LINKING || t == EE_FEATURES.MFA))) {
throw new FeatureNotEnabledException(
"Account linking feature is not enabled for this app. Please contact support to enable it.");
}
Expand Down Expand Up @@ -544,7 +544,7 @@ public static CreatePrimaryUserResult createPrimaryUser(Main main,
FeatureNotEnabledException {

if (Arrays.stream(FeatureFlag.getInstance(main, appIdentifierWithStorage).getEnabledFeatures())
.noneMatch(t -> t == EE_FEATURES.ACCOUNT_LINKING)) {
.noneMatch(t -> (t == EE_FEATURES.ACCOUNT_LINKING || t == EE_FEATURES.MFA))) {
throw new FeatureNotEnabledException(
"Account linking feature is not enabled for this app. Please contact support to enable it.");
}
Expand Down Expand Up @@ -934,7 +934,6 @@ private static void deleteNonAuthRecipeUser(TransactionConnection con, AppIdenti
.deleteAllRolesForUser_Transaction(con, appIdentifierWithStorage, userId);
appIdentifierWithStorage.getActiveUsersStorage()
.deleteUserActive_Transaction(con, appIdentifierWithStorage, userId);
appIdentifierWithStorage.getTOTPStorage().removeUser_Transaction(con, appIdentifierWithStorage, userId);
}

private static void deleteAuthRecipeUser(TransactionConnection con,
Expand Down Expand Up @@ -975,6 +974,8 @@ public static boolean deleteNonAuthRecipeUser(TenantIdentifierWithStorage
.removeUser(tenantIdentifierWithStorage, userId);
finalDidExist = finalDidExist || didExist;

finalDidExist = finalDidExist || didExist;

return finalDidExist;
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/io/supertokens/featureflag/EE_FEATURES.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

public enum EE_FEATURES {
ACCOUNT_LINKING("account_linking"), MULTI_TENANCY("multi_tenancy"), TEST("test"),
DASHBOARD_LOGIN("dashboard_login"),
TOTP("totp");
DASHBOARD_LOGIN("dashboard_login"), MFA("mfa");

private final String name;

Expand Down
Loading