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 in plugin interface #87

Merged
merged 108 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 85 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
5530d00
adds interface for multi tenancy
rishabhpoddar Jan 16, 2023
094f02d
changes storage layer to take json instead of config file path
rishabhpoddar Jan 19, 2023
ef6a9cc
adds new interface to indentify a user pool
rishabhpoddar Jan 19, 2023
fa8af13
exception throwing change
rishabhpoddar Jan 19, 2023
faebf7a
adds function to get connection pool ID
rishabhpoddar Jan 23, 2023
102596d
changes to interface
rishabhpoddar Jan 23, 2023
daa1089
changes to initstorage interface function
rishabhpoddar Jan 24, 2023
c4efd7d
adds function so that the core can create multiple user pools during …
rishabhpoddar Jan 28, 2023
b285355
adds tenantidentifier class
rishabhpoddar Feb 5, 2023
1227497
adds more functions to interface
rishabhpoddar Feb 7, 2023
9eacc1e
removes unused exception
rishabhpoddar Feb 7, 2023
ee8993f
small change
rishabhpoddar Feb 8, 2023
6e100b8
adds new functions
rishabhpoddar Feb 8, 2023
b7b1b50
adds deletion functions for multitenancy
rishabhpoddar Feb 9, 2023
acb2b3f
few changes
rishabhpoddar Feb 9, 2023
8bde555
updates exception class
rishabhpoddar Feb 9, 2023
75f54a5
simplifies delete of app and connectionuridomain
rishabhpoddar Feb 10, 2023
d1755a4
adds getters for certain tenant config props
rishabhpoddar Feb 11, 2023
ac4af09
adds equals functions for tenantconfig types
rishabhpoddar Feb 12, 2023
2425d18
adds constructors for thirdparty config objects
rishabhpoddar Feb 12, 2023
efac642
changes equals for tenantconfig
rishabhpoddar Feb 12, 2023
18dcc9a
removes nullable annotation from primitive type
rishabhpoddar Feb 12, 2023
d402f2d
adds tenantIdentifier for emailpassword and useridmapping recipes
rishabhpoddar Feb 13, 2023
0b15606
adds extra comment
rishabhpoddar Feb 13, 2023
2a4c598
adds comment
rishabhpoddar Feb 13, 2023
54e2a29
changes to incorporate tenantIndetifier for key value storage
rishabhpoddar Feb 14, 2023
dfb9363
changes to session receipe to add tenantIdentifier
rishabhpoddar Feb 14, 2023
0874036
introduces the concept of appIdentifier vs tenantIdentifier
rishabhpoddar Feb 15, 2023
01bf511
adds a few more functions
rishabhpoddar Feb 15, 2023
556e3cd
adds appidentifier to user metadata functions
rishabhpoddar Feb 15, 2023
49eba24
modifes user roles functions to add tenantidentifier and appidentifiers
rishabhpoddar Feb 15, 2023
3b4a43f
changes to emailpassword functions
rishabhpoddar Feb 16, 2023
6c201e9
changes to a few functions
rishabhpoddar Feb 17, 2023
d0071ed
adds appidentifier to email verfication
rishabhpoddar Feb 17, 2023
d08a59b
adds tenant identifier to third party
rishabhpoddar Feb 17, 2023
ac6c099
adds tenantidentifier to passwordless
rishabhpoddar Feb 17, 2023
976362f
function name changes
rishabhpoddar Feb 20, 2023
a36b7f6
fix: changes for multi-tenancy impl (#55)
sattvikc Feb 24, 2023
2018b3d
fix: new exceptions (#56)
sattvikc Feb 28, 2023
dcd6e96
fix: changes for random test (#57)
sattvikc Mar 2, 2023
d7c62eb
Merge branch '2.20' into multi-tenant-config
rishabhpoddar Mar 5, 2023
9b9e228
makes dashboard interface per app
rishabhpoddar Mar 5, 2023
0a1ee4b
fix: storage in AppIdentifier and TenantIdentifier (#61)
sattvikc Mar 24, 2023
35d7cde
fix: fixed pless interface (#64)
sattvikc Mar 24, 2023
0ad9103
fix: to support PR comments on core (#65)
sattvikc Mar 25, 2023
546af6a
fix: added storages to appIdentifierWithStorage (#66)
sattvikc Mar 27, 2023
d6dc7e0
fix: Multitenant userroles (#67)
sattvikc Mar 28, 2023
a9d7e0f
fix: Multitenant usermetadata (#68)
sattvikc Mar 29, 2023
77cf4f3
fix: ep storage (#69)
sattvikc Mar 29, 2023
32ff39d
fix: Multitenant uidmapping storage (#70)
sattvikc Mar 29, 2023
c91dd33
fix: Multitenant passwordless storage (#71)
sattvikc Mar 31, 2023
05cba25
fix: thirdparty storage (#72)
sattvikc Mar 31, 2023
2e97a56
fix: Multitenant thirdparty changes for update email (#73)
sattvikc Apr 1, 2023
16a9f58
fix: Multitenant emailverification storage (#74)
sattvikc Apr 3, 2023
6b01058
fix: making tokens tenant specific (#75)
sattvikc Apr 3, 2023
7acf7f5
comment modification
rishabhpoddar Apr 5, 2023
03bd13a
fix: Multitenant session (#76)
sattvikc Apr 5, 2023
a93b6b9
fix: adding tenant or app not found exceptions
sattvikc Apr 5, 2023
7d9a133
merges with latest (#77)
rishabhpoddar Apr 5, 2023
0c16056
small change
rishabhpoddar Apr 6, 2023
89bc5f7
fix: jwt changes (#78)
sattvikc Apr 6, 2023
c072fa6
fix: Multitenant Authrecipe changes (#79)
sattvikc Apr 7, 2023
525e80c
fix: Multitenant dashboard (#80)
sattvikc Apr 10, 2023
566f5a8
fix: Multitenant totp (#81)
sattvikc Apr 11, 2023
7019947
merges (#82)
rishabhpoddar Apr 13, 2023
155aa16
adds new config (#83)
rishabhpoddar Apr 18, 2023
3cd30ed
fix: multitenancy changes (#84)
sattvikc Apr 20, 2023
a67d94d
fix: base tenant (#85)
sattvikc Apr 25, 2023
eb0bf7a
feat: Introduce MFA recipe
KShivendu Apr 27, 2023
5738264
chores: Mention MFA recipe in the CHANGELOG
KShivendu Apr 27, 2023
a8537c8
fix: Tenantid in userobjects (#86)
sattvikc Apr 27, 2023
b41dd3b
fix: tenant id in loadConfig (#88)
sattvikc Apr 28, 2023
9b6a415
fix: delete non auth user (#89)
sattvikc May 2, 2023
77a78b0
feat: Improvements for EE features and removing MFA info when deletin…
KShivendu May 3, 2023
dcd65c5
fix: nonAuthRecipeuserData to take tenantIdentifier (#90)
sattvikc May 4, 2023
9a9265b
fix: pr comment
sattvikc May 4, 2023
5b95fad
fix: config validation (#91)
sattvikc May 4, 2023
45b8732
Merge branch 'multi-tenant-config' into feat/mfa
KShivendu May 9, 2023
7320125
feat: Add function to delete user from a tenant
KShivendu May 10, 2023
1f0b25f
fix: reload resources (#93)
sattvikc May 11, 2023
eec65fa
fix: added setLogLevels (#95)
sattvikc May 15, 2023
7ca0f44
Use deleteMfaInfoForuser and overload it to handle app as well as ten…
KShivendu May 15, 2023
3e37980
fix: Active user storage to extend NonAuthRecipeStorage (#97)
sattvikc May 25, 2023
9f3b681
Merge branch 'multi-tenant-config' into feat/mfa
KShivendu May 26, 2023
6e5f1ec
Merge branch 'master' into feat/mfa
KShivendu Jun 23, 2023
2986794
Merge branch 'master' into feat/mfa
KShivendu Sep 27, 2023
7dbc14f
refactor: Replace TotpNotEnabledError with UnknownUserIdTotpError (#106)
KShivendu Sep 28, 2023
e18b86a
fix: refactor transaction functions (#120)
sattvikc Oct 3, 2023
e9ab279
fix: mfa cleanup (#121)
sattvikc Oct 16, 2023
43c93f2
fix: mfa cleanup (#123)
sattvikc Oct 17, 2023
b0e49b7
Merge branch '4.0' into merge-latest
sattvikc Oct 19, 2023
31c3f89
Merge pull request #127 from supertokens/merge-latest
sattvikc Oct 19, 2023
df92365
Merge branch '4.0' into merge-latest
sattvikc Oct 20, 2023
5a5d16d
Merge pull request #129 from supertokens/merge-latest
sattvikc Oct 20, 2023
0017637
Mfa multitenancy (#122)
sattvikc Oct 26, 2023
712303d
fix: ordering in comparision
sattvikc Oct 26, 2023
3c9c754
fix: add createdat to totp device (#130)
sattvikc Oct 31, 2023
17bd7c2
fix: mfa stats (#131)
sattvikc Oct 31, 2023
e351629
Merge branch '4.0' into feat/mfa
sattvikc Nov 28, 2023
14a3276
fix: version and changelog
sattvikc Nov 29, 2023
c1fd974
fix: version
sattvikc Nov 29, 2023
208e167
fix: Mfa changes (#135)
sattvikc Dec 20, 2023
a24f17b
Merge branch '4.0' into feat/mfa
sattvikc Dec 21, 2023
93336d8
feat: Add support to update the signing key type of a session (#136)
porcellus Jan 29, 2024
8016591
merge latest (#141)
sattvikc Mar 7, 2024
51c2832
Remaining changes (#144)
sattvikc Mar 13, 2024
18411b2
merge 5.0 (#145)
sattvikc Mar 13, 2024
bd4c643
Merge branch '5.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
Binary file added jar/plugin-interface-2.23.0.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,12 @@ public interface ActiveUsersStorage extends NonAuthRecipeStorage {
/* Count the number of users who have enabled TOTP and are active */
int countUsersEnabledTotpAndActiveSince(AppIdentifier appIdentifier, long time) throws StorageQueryException;

/* Count the number of users who have enabled MFA */
KShivendu marked this conversation as resolved.
Show resolved Hide resolved
int countUsersEnabledMfa(AppIdentifier appIdentifier) throws StorageQueryException;

/* Count the number of users who have enabled MFA and are active */
int countUsersEnabledMfaAndActiveSince(AppIdentifier appIdentifier, long time) throws StorageQueryException;

/* Delete a user from active users table */
void deleteUserActive(AppIdentifier appIdentifier, String userId) throws StorageQueryException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public enum RECIPE_ID {
EMAIL_PASSWORD("emailpassword"), THIRD_PARTY("thirdparty"), SESSION("session"),
EMAIL_VERIFICATION("emailverification"), JWT("jwt"), PASSWORDLESS("passwordless"), USER_METADATA("usermetadata"),
USER_ROLES("userroles"), USER_ID_MAPPING("useridmapping"), DASHBOARD("dashboard"), TOTP("totp"),
MULTITENANCY("multitenancy");
MULTITENANCY("multitenancy"), MFA("mfa");

private final String name;

Expand Down
23 changes: 23 additions & 0 deletions src/main/java/io/supertokens/pluginInterface/mfa/MfaStorage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.supertokens.pluginInterface.mfa;

import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.TenantIdentifier;
import io.supertokens.pluginInterface.nonAuthRecipe.NonAuthRecipeStorage;

public interface MfaStorage extends NonAuthRecipeStorage {
// Enable (insert) a factor for a user and return true if it actually inserted something.
boolean enableFactor(TenantIdentifier tenantIdentifier, String userId, String factorId) throws StorageQueryException;

// List all the factors for a user:
String[] listFactors(TenantIdentifier tenantIdentifier, String userId) throws StorageQueryException;

// Disable (delete) a factor for a user and return true if it actually deleted something.
boolean disableFactor(TenantIdentifier tenantIdentifier, String userId, String factorId) throws StorageQueryException;

// Delete a user across all tenants (with all the relevant factors)
boolean deleteMfaInfoForUser(AppIdentifier appIdentifier, String userId) throws StorageQueryException;

// Delete a user from a tenant (with all the relevant factors)
boolean deleteMfaInfoForUser(TenantIdentifier tenantIdentifier, String userId) throws StorageQueryException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.supertokens.pluginInterface.session.SessionStorage;
import io.supertokens.pluginInterface.thirdparty.sqlStorage.ThirdPartySQLStorage;
import io.supertokens.pluginInterface.totp.sqlStorage.TOTPSQLStorage;
import io.supertokens.pluginInterface.mfa.MfaStorage;
import io.supertokens.pluginInterface.useridmapping.UserIdMappingStorage;
import io.supertokens.pluginInterface.usermetadata.sqlStorage.UserMetadataSQLStorage;
import io.supertokens.pluginInterface.userroles.sqlStorage.UserRolesSQLStorage;
Expand Down Expand Up @@ -152,6 +153,14 @@ public TOTPSQLStorage getTOTPStorage() {
return (TOTPSQLStorage) this.storage;
}

public MfaStorage getMfaStorage() {
if (this.storage.getType() != STORAGE_TYPE.SQL) {
// we only support SQL for now
throw new UnsupportedOperationException("");
}
return (MfaStorage) this.storage;
}

public ActiveUsersStorage getActiveUsersStorage() {
if (this.storage.getType() != STORAGE_TYPE.SQL) {
// we only support SQL for now
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
import io.supertokens.pluginInterface.authRecipe.AuthRecipeStorage;
import io.supertokens.pluginInterface.emailpassword.sqlStorage.EmailPasswordSQLStorage;
import io.supertokens.pluginInterface.emailverification.sqlStorage.EmailVerificationSQLStorage;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;
import io.supertokens.pluginInterface.passwordless.sqlStorage.PasswordlessSQLStorage;
import io.supertokens.pluginInterface.session.SessionStorage;
import io.supertokens.pluginInterface.thirdparty.sqlStorage.ThirdPartySQLStorage;
import io.supertokens.pluginInterface.totp.sqlStorage.TOTPSQLStorage;
import io.supertokens.pluginInterface.mfa.MfaStorage;
import io.supertokens.pluginInterface.useridmapping.UserIdMappingStorage;
import io.supertokens.pluginInterface.userroles.sqlStorage.UserRolesSQLStorage;

Expand Down Expand Up @@ -123,6 +123,14 @@ public TOTPSQLStorage getTOTPStorage() {
}
return (TOTPSQLStorage) this.storage;
}

public MfaStorage getMfaStorage() {
if (this.storage.getType() != STORAGE_TYPE.SQL) {
// we only support SQL for now
throw new UnsupportedOperationException("");
}
return (MfaStorage) this.storage;
}

public MultitenancyStorage getMultitenancyStorageWithTargetStorage() {
if (this.storage.getType() != STORAGE_TYPE.SQL) {
Expand Down