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 84 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
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

- Introduce MFA Recipe plugin interface

## [2.23.0] - 2023-04-05

- Added `useStaticKey ` into session info classes
- Added `hashCode` override for JWTSigningKeyInfo

## [2.22.0] - 2023-03-30

- Adds Support for Dashboard Search

## [2.21.0] - 2023-03-27

- Introduce TOTP Recipe plugin interface
- Introduce Active users storage plugin interface

## [2.20.0] - 2023-02-21

- Dashboard Recipe Interface
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 = "2.20.0"
version = "2.23.0"

repositories {
mavenCentral()
Expand Down
Binary file not shown.
Binary file added jar/plugin-interface-2.23.0.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.supertokens.pluginInterface;

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

public interface ActiveUsersStorage extends NonAuthRecipeStorage {
/* Update the last active time of a user to now */
void updateLastActive(AppIdentifier appIdentifier, String userId) throws StorageQueryException;

/* Count the number of users who did some activity after given timestamp */
int countUsersActiveSince(AppIdentifier appIdentifier, long time) throws StorageQueryException;

/* Count the number of users who have enabled TOTP */
int countUsersEnabledTotp(AppIdentifier appIdentifier) throws StorageQueryException;

/* 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;
}
3 changes: 2 additions & 1 deletion src/main/java/io/supertokens/pluginInterface/RECIPE_ID.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ 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");
USER_ROLES("userroles"), USER_ID_MAPPING("useridmapping"), DASHBOARD("dashboard"), TOTP("totp"),
MULTITENANCY("multitenancy"), MFA("mfa");

private final String name;

Expand Down
46 changes: 39 additions & 7 deletions src/main/java/io/supertokens/pluginInterface/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@

package io.supertokens.pluginInterface;

import com.google.gson.JsonObject;
import io.supertokens.pluginInterface.exceptions.DbInitException;
import io.supertokens.pluginInterface.exceptions.InvalidConfigException;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.TenantIdentifier;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;

import java.util.Set;

Expand All @@ -26,14 +32,27 @@ public interface Storage {
// if silent is true, do not log anything out on the console
void constructor(String processId, boolean silent);

void loadConfig(String configFilePath, Set<LOG_LEVEL> logLevels);
void loadConfig(JsonObject jsonConfig, Set<LOG_LEVEL> logLevels, TenantIdentifier tenantIdentifier) throws InvalidConfigException;

// this returns a unique ID based on the db's connection URI and table prefix such that
// two different user pool IDs imply that the data for those two user pools are completely isolated.
String getUserPoolId();

// this returns a unique ID based on the db's connection pool config. This can be different
// even if the getUserPoolId returns the same ID - based on the config provided by the user.
// So two different db connection pools may point to the same end user pool.
String getConnectionPoolId();

// if the input otherConfig has different values set for the same properties as this user pool's config,
// then this function should throw an error since this is a misconfig from ther user's side.
void assertThatConfigFromSameUserPoolIsNotConflicting(JsonObject otherConfig) throws InvalidConfigException;

void initFileLogging(String infoLogPath, String errorLogPath);

void stopLogging();

// load tables and create connection pools
void initStorage();
void initStorage(boolean shouldWait) throws DbInitException;

// used by the core to do transactions the right way.
STORAGE_TYPE getType();
Expand All @@ -43,19 +62,32 @@ public interface Storage {

void close();

KeyValueInfo getKeyValue(String key) throws StorageQueryException;
KeyValueInfo getKeyValue(TenantIdentifier tenantIdentifier, String key) throws StorageQueryException;

void setKeyValue(String key, KeyValueInfo info) throws StorageQueryException;
void setKeyValue(TenantIdentifier tenantIdentifier, String key, KeyValueInfo info) throws StorageQueryException,
TenantOrAppNotFoundException;

void setStorageLayerEnabled(boolean enabled);

boolean canBeUsed(String configFilePath);
boolean canBeUsed(JsonObject configJson);

// this function will be used in the createUserIdMapping and deleteUserIdMapping functions to check if the userId is
// being used in NonAuth recipes.
boolean isUserIdBeingUsedInNonAuthRecipe(String className, String userId) throws StorageQueryException;
boolean isUserIdBeingUsedInNonAuthRecipe(AppIdentifier appIdentifier, String className, String userId)
throws StorageQueryException;

// to be used for testing purposes only. This function will add dummy data to non-auth tables.
void addInfoToNonAuthRecipesBasedOnUserId(String className, String userId) throws StorageQueryException;
void addInfoToNonAuthRecipesBasedOnUserId(TenantIdentifier tenantIdentifier, String className, String userId) throws StorageQueryException;

// this function is used during testing in the core so that the core can
// create multiple user pools across any plugin being used.
void modifyConfigToAddANewUserPoolForTesting(JsonObject config, int poolNumber);

// this function returns a list of protected configs which users of supertokens saas can't read or modify
// when they are operating on tenantsm unless the supertokens_saas_secret key is used in the API request.
String[] getProtectedConfigsFromSuperTokensSaaSUsers();

Set<String> getValidFieldsInConfig();

void setLogLevels(Set<LOG_LEVEL> logLevels);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,29 @@

import io.supertokens.pluginInterface.RECIPE_ID;
import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.dashboard.DashboardSearchTags;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.TenantIdentifier;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public interface AuthRecipeStorage extends Storage {

long getUsersCount(@Nullable RECIPE_ID[] includeRecipeIds) throws StorageQueryException;
long getUsersCount(TenantIdentifier tenantIdentifier, @Nullable RECIPE_ID[] includeRecipeIds)
throws StorageQueryException;

long getUsersCount(AppIdentifier appIdentifier, @Nullable RECIPE_ID[] includeRecipeIds)
throws StorageQueryException;

AuthRecipeUserInfo[] getUsers(@Nonnull Integer limit, @Nonnull String timeJoinedOrder,
@Nullable RECIPE_ID[] includeRecipeIds, @Nullable String userId, @Nullable Long timeJoined)
AuthRecipeUserInfo[] getUsers(TenantIdentifier tenantIdentifier, @Nonnull Integer limit,
@Nonnull String timeJoinedOrder,
@Nullable RECIPE_ID[] includeRecipeIds, @Nullable String userId,
@Nullable Long timeJoined, @Nullable DashboardSearchTags dashboardSearchTags)
throws StorageQueryException;

boolean doesUserIdExist(String userId) throws StorageQueryException;
boolean doesUserIdExist(AppIdentifier appIdentifier, String userId) throws StorageQueryException;

boolean doesUserIdExist(TenantIdentifier tenantIdentifierIdentifier, String userId) throws StorageQueryException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ public abstract class AuthRecipeUserInfo {

public long timeJoined;

public AuthRecipeUserInfo(String id, long timeJoined) {
public final String[] tenantIds;

public AuthRecipeUserInfo(String id, long timeJoined, String[] tenantIds) {
this.id = id;
this.timeJoined = timeJoined;
this.tenantIds = tenantIds;
}

public abstract RECIPE_ID getRecipeId();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package io.supertokens.pluginInterface.dashboard;

import java.util.ArrayList;

import javax.annotation.Nullable;

public class DashboardSearchTags {

public ArrayList<String> emails;
public ArrayList<String> phoneNumbers;
public ArrayList<String> providers;

public DashboardSearchTags(@Nullable ArrayList<String> emails, @Nullable ArrayList<String> phones,
@Nullable ArrayList<String> providers) {
this.emails = emails;
this.phoneNumbers = phones;
this.providers = providers;
}

public boolean shouldEmailPasswordTableBeSearched() {

ArrayList<SUPPORTED_SEARCH_TAGS> nonNullSearchTags = getNonNullSearchFields();
return nonNullSearchTags.contains(SUPPORTED_SEARCH_TAGS.EMAIL) && nonNullSearchTags.size() == 1;

}

public boolean shouldThirdPartyTableBeSearched() {

ArrayList<SUPPORTED_SEARCH_TAGS> nonNullSearchTags = getNonNullSearchFields();
if(nonNullSearchTags.contains(SUPPORTED_SEARCH_TAGS.EMAIL) && nonNullSearchTags.contains(SUPPORTED_SEARCH_TAGS.PROVIDER)){
return nonNullSearchTags.size() == 2;
}

if(nonNullSearchTags.contains(SUPPORTED_SEARCH_TAGS.EMAIL) || nonNullSearchTags.contains(SUPPORTED_SEARCH_TAGS.PROVIDER)){
return nonNullSearchTags.size() == 1;
}

return false;
}

public boolean shouldPasswordlessTableBeSearched() {
ArrayList<SUPPORTED_SEARCH_TAGS> nonNullSearchTags = getNonNullSearchFields();
if(nonNullSearchTags.contains(SUPPORTED_SEARCH_TAGS.EMAIL) && nonNullSearchTags.contains(SUPPORTED_SEARCH_TAGS.PHONE)){
return nonNullSearchTags.size() == 2;
}

if(nonNullSearchTags.contains(SUPPORTED_SEARCH_TAGS.EMAIL) || nonNullSearchTags.contains(SUPPORTED_SEARCH_TAGS.PHONE)){
return nonNullSearchTags.size() == 1;
}

return false;
}

private ArrayList<SUPPORTED_SEARCH_TAGS> getNonNullSearchFields() {
ArrayList<SUPPORTED_SEARCH_TAGS> nonNullSearchTags = new ArrayList<>();

if (this.emails != null) {
nonNullSearchTags.add(SUPPORTED_SEARCH_TAGS.EMAIL);
}

if (this.phoneNumbers != null) {
nonNullSearchTags.add(SUPPORTED_SEARCH_TAGS.PHONE);
}

if (this.providers != null) {
nonNullSearchTags.add(SUPPORTED_SEARCH_TAGS.PROVIDER);
}

return nonNullSearchTags;
}

public enum SUPPORTED_SEARCH_TAGS {
EMAIL("email"), PHONE("phone"), PROVIDER("provider");

private String tag;

SUPPORTED_SEARCH_TAGS(String tag) {
this.tag = tag;
}

public static SUPPORTED_SEARCH_TAGS fromString(String text) {
for (SUPPORTED_SEARCH_TAGS t : SUPPORTED_SEARCH_TAGS.values()) {
if (t.tag.equalsIgnoreCase(text)) {
return t;
}
}
return null;
}

@Override
public String toString() {
return tag;
}
}

}
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
package io.supertokens.pluginInterface.dashboard;

import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.dashboard.exceptions.DuplicateEmailException;
import io.supertokens.pluginInterface.dashboard.exceptions.DuplicateUserIdException;
import io.supertokens.pluginInterface.dashboard.exceptions.UserIdNotFoundException;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;

public interface DashboardStorage extends Storage {

void createNewDashboardUser(DashboardUser userInfo) throws StorageQueryException, DuplicateUserIdException, DuplicateEmailException;
void createNewDashboardUser(AppIdentifier appIdentifier, DashboardUser userInfo)
throws StorageQueryException, DuplicateUserIdException, DuplicateEmailException,
TenantOrAppNotFoundException;

DashboardUser getDashboardUserByEmail(AppIdentifier appIdentifier, String email) throws StorageQueryException;

DashboardUser getDashboardUserByEmail(String email) throws StorageQueryException;
DashboardUser getDashboardUserByUserId(AppIdentifier appIdentifier, String userId) throws StorageQueryException;

DashboardUser getDashboardUserByUserId(String userId) throws StorageQueryException;
DashboardUser[] getAllDashboardUsers(AppIdentifier appIdentifier) throws StorageQueryException;

DashboardUser[] getAllDashboardUsers() throws StorageQueryException;
boolean deleteDashboardUserWithUserId(AppIdentifier appIdentifier, String userId) throws StorageQueryException;

boolean deleteDashboardUserWithUserId(String userId) throws StorageQueryException;

void createNewDashboardUserSession(String userId, String sessionId, long timeCreated, long expiry) throws StorageQueryException, UserIdNotFoundException;
void createNewDashboardUserSession(AppIdentifier appIdentifier, String userId, String sessionId, long timeCreated,
long expiry) throws StorageQueryException, UserIdNotFoundException;

DashboardSessionInfo[] getAllSessionsForUserId(String userId) throws StorageQueryException;
DashboardSessionInfo[] getAllSessionsForUserId(AppIdentifier appIdentifier, String userId)
throws StorageQueryException;

DashboardSessionInfo getSessionInfoWithSessionId(String sessionId) throws StorageQueryException;
DashboardSessionInfo getSessionInfoWithSessionId(AppIdentifier appIdentifier, String sessionId)
throws StorageQueryException;

boolean revokeSessionWithSessionId(String sessionId) throws StorageQueryException;
boolean revokeSessionWithSessionId(AppIdentifier appIdentifier, String sessionId) throws StorageQueryException;

// this function removes based on expired time, so we can use this to globally remove from a particular db.
void revokeExpiredSessions() throws StorageQueryException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
import io.supertokens.pluginInterface.dashboard.exceptions.DuplicateEmailException;
import io.supertokens.pluginInterface.dashboard.exceptions.UserIdNotFoundException;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.sqlStorage.SQLStorage;
import io.supertokens.pluginInterface.sqlStorage.TransactionConnection;

public interface DashboardSQLStorage extends DashboardStorage, SQLStorage {

void updateDashboardUsersEmailWithUserId_Transaction(TransactionConnection con, String userId, String newEmail) throws StorageQueryException, DuplicateEmailException, UserIdNotFoundException;
void updateDashboardUsersEmailWithUserId_Transaction(AppIdentifier appIdentifier, TransactionConnection con,
String userId, String newEmail)
throws StorageQueryException, DuplicateEmailException, UserIdNotFoundException;

void updateDashboardUsersPasswordWithUserId_Transaction(AppIdentifier appIdentifier, TransactionConnection con,
String userId, String newPassword)
throws StorageQueryException, UserIdNotFoundException;

void updateDashboardUsersPasswordWithUserId_Transaction(TransactionConnection con, String userId, String newPassword) throws StorageQueryException, UserIdNotFoundException;

}
Loading