-
Notifications
You must be signed in to change notification settings - Fork 549
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* delete and get user apis now work with userIdMapping * updates emailpassword apis to use userIdMapping * adds remaining userIdMapping changes to thirdParty and passwordless APIs * implements more feedback * adds more tests implement more feedback * adds userPagination test with userIdMapping * API fixes * adds passwordResetFlow test * finishes EmailPassword tests * starts ThirdPartAPI tests * adds some thirdParty tests * implements feedback for delete API * implements some changes * adds test for new EmailVerification function * adds checks to deleteUserIdMapping function * updates Create UserIdMapping and DelteUserIdMapping API to have optional force option * implements feedback changes * implements changes to deleteUser * adds additional check in createUserIdMapping function * adds get user tests for ThirdParty recipe * fixes due to plugin interface change * adds deleteUser tests for UserIdMapping * implements more feedback * adds comments explaining changes to deleteUser queries * implements more feedback * updates tests to now ignore jwt recipe checking for create and deleteUserIdMapping tests * comment fixes * cleans up code * Update src/main/java/io/supertokens/authRecipe/AuthRecipe.java * adds more tests * removes unnecessary static function * implements feedback * implements more feedback * fixes * comment fixes * adds more passwordless tests * bug fix, and test update * updates deleteUserIdMapping behavior * fixes * test fixes * test fixes * fixes * adds userIdMapping changes * adds test for deleteingUserIdMapping with force * adds tests for intermediate state in deleteAPI * adds forbidden state tests * adds more tests * removes unused import * fixes bug in auth getUserAPIs * adds additional test * removes unnecessary checks * updates version information * gst * fixes * fixes * fixes Co-authored-by: Rishabh Poddar <[email protected]>
- Loading branch information
1 parent
3843c38
commit 451986a
Showing
35 changed files
with
2,254 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": [ | ||
"2.16" | ||
"2.17" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,9 @@ | |
import io.supertokens.Main; | ||
import io.supertokens.ProcessState; | ||
import io.supertokens.ResourceDistributor; | ||
import io.supertokens.emailpassword.EmailPassword; | ||
import io.supertokens.emailverification.EmailVerification; | ||
import io.supertokens.emailverification.exception.EmailAlreadyVerifiedException; | ||
import io.supertokens.inmemorydb.config.Config; | ||
import io.supertokens.inmemorydb.queries.*; | ||
import io.supertokens.pluginInterface.KeyValueInfo; | ||
|
@@ -34,20 +37,24 @@ | |
import io.supertokens.pluginInterface.emailpassword.exceptions.DuplicateUserIdException; | ||
import io.supertokens.pluginInterface.emailpassword.exceptions.UnknownUserIdException; | ||
import io.supertokens.pluginInterface.emailpassword.sqlStorage.EmailPasswordSQLStorage; | ||
import io.supertokens.pluginInterface.emailverification.EmailVerificationStorage; | ||
import io.supertokens.pluginInterface.emailverification.EmailVerificationTokenInfo; | ||
import io.supertokens.pluginInterface.emailverification.exception.DuplicateEmailVerificationTokenException; | ||
import io.supertokens.pluginInterface.emailverification.sqlStorage.EmailVerificationSQLStorage; | ||
import io.supertokens.pluginInterface.exceptions.QuitProgramFromPluginException; | ||
import io.supertokens.pluginInterface.exceptions.StorageQueryException; | ||
import io.supertokens.pluginInterface.exceptions.StorageTransactionLogicException; | ||
import io.supertokens.pluginInterface.jwt.JWTRecipeStorage; | ||
import io.supertokens.pluginInterface.jwt.JWTSigningKeyInfo; | ||
import io.supertokens.pluginInterface.jwt.exceptions.DuplicateKeyIdException; | ||
import io.supertokens.pluginInterface.jwt.sqlstorage.JWTRecipeSQLStorage; | ||
import io.supertokens.pluginInterface.nonAuthRecipe.NonAuthRecipeStorage; | ||
import io.supertokens.pluginInterface.passwordless.PasswordlessCode; | ||
import io.supertokens.pluginInterface.passwordless.PasswordlessDevice; | ||
import io.supertokens.pluginInterface.passwordless.exception.*; | ||
import io.supertokens.pluginInterface.passwordless.sqlStorage.PasswordlessSQLStorage; | ||
import io.supertokens.pluginInterface.session.SessionInfo; | ||
import io.supertokens.pluginInterface.session.SessionStorage; | ||
import io.supertokens.pluginInterface.session.sqlStorage.SessionSQLStorage; | ||
import io.supertokens.pluginInterface.sqlStorage.TransactionConnection; | ||
import io.supertokens.pluginInterface.thirdparty.exception.DuplicateThirdPartyUserException; | ||
|
@@ -56,17 +63,28 @@ | |
import io.supertokens.pluginInterface.useridmapping.UserIdMappingStorage; | ||
import io.supertokens.pluginInterface.useridmapping.exception.UnknownSuperTokensUserIdException; | ||
import io.supertokens.pluginInterface.useridmapping.exception.UserIdMappingAlreadyExistsException; | ||
import io.supertokens.pluginInterface.usermetadata.UserMetadataStorage; | ||
import io.supertokens.pluginInterface.usermetadata.sqlStorage.UserMetadataSQLStorage; | ||
import io.supertokens.pluginInterface.userroles.UserRolesStorage; | ||
import io.supertokens.pluginInterface.userroles.exception.DuplicateUserRoleMappingException; | ||
import io.supertokens.pluginInterface.userroles.exception.UnknownRoleException; | ||
import io.supertokens.pluginInterface.userroles.sqlStorage.UserRolesSQLStorage; | ||
import io.supertokens.session.Session; | ||
import io.supertokens.usermetadata.UserMetadata; | ||
import io.supertokens.userroles.UserRoles; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.TestOnly; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.spec.InvalidKeySpecException; | ||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
import java.sql.SQLTransactionRollbackException; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
public class Start | ||
|
@@ -1524,4 +1542,83 @@ public boolean updateOrDeleteExternalUserIdInfo(String userId, boolean isSuperTo | |
} | ||
|
||
} | ||
|
||
@Override | ||
public HashMap<String, String> getUserIdMappingForSuperTokensIds(ArrayList<String> userIds) | ||
throws StorageQueryException { | ||
try { | ||
return UserIdMappingQueries.getUserIdMappingWithUserIds(this, userIds); | ||
} catch (SQLException e) { | ||
throw new StorageQueryException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isUserIdBeingUsedInNonAuthRecipe(String className, String userId) throws StorageQueryException { | ||
|
||
// check if the input userId is being used in nonAuthRecipes. | ||
if (className.equals(SessionStorage.class.getName())) { | ||
String[] sessionHandlesForUser = getAllNonExpiredSessionHandlesForUser(userId); | ||
return sessionHandlesForUser.length > 0; | ||
} else if (className.equals(UserRolesStorage.class.getName())) { | ||
String[] roles = getRolesForUser(userId); | ||
return roles.length > 0; | ||
} else if (className.equals(UserMetadataStorage.class.getName())) { | ||
JsonObject userMetadata = getUserMetadata(userId); | ||
return userMetadata != null; | ||
} else if (className.equals(EmailVerificationStorage.class.getName())) { | ||
try { | ||
return EmailVerificationQueries.isUserIdBeingUsedForEmailVerification(this, userId); | ||
} catch (SQLException e) { | ||
throw new StorageQueryException(e); | ||
} | ||
} else if (className.equals(JWTRecipeStorage.class.getName())) { | ||
return false; | ||
} else { | ||
throw new IllegalStateException("ClassName: " + className + " is not part of NonAuthRecipeStorage"); | ||
} | ||
} | ||
|
||
@TestOnly | ||
@Override | ||
public void addInfoToNonAuthRecipesBasedOnUserId(String className, String userId) throws StorageQueryException { | ||
// add entries to nonAuthRecipe tables with input userId | ||
if (className.equals(SessionStorage.class.getName())) { | ||
try { | ||
Session.createNewSession(this.main, userId, new JsonObject(), new JsonObject()); | ||
} catch (Exception e) { | ||
throw new StorageQueryException(e); | ||
} | ||
} else if (className.equals(UserRolesStorage.class.getName())) { | ||
try { | ||
String role = "testRole"; | ||
UserRoles.createNewRoleOrModifyItsPermissions(this.main, role, null); | ||
UserRoles.addRoleToUser(this.main, userId, role); | ||
} catch (StorageTransactionLogicException e) { | ||
throw new StorageQueryException(e.actualException); | ||
} catch (UnknownRoleException e) { | ||
throw new StorageQueryException(e); | ||
} | ||
} else if (className.equals(EmailVerificationStorage.class.getName())) { | ||
try { | ||
EmailVerification.generateEmailVerificationToken(this.main, userId, "[email protected]"); | ||
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) { | ||
throw new StorageQueryException(e); | ||
} catch (EmailAlreadyVerifiedException e) { | ||
/* do nothing cause the userId already exists in the table */ | ||
} | ||
} else if (className.equals(UserMetadataStorage.class.getName())) { | ||
JsonObject data = new JsonObject(); | ||
data.addProperty("test", "testData"); | ||
try { | ||
UserMetadata.updateUserMetadata(this.main, userId, data); | ||
} catch (StorageTransactionLogicException e) { | ||
throw new StorageQueryException(e); | ||
} | ||
} else if (className.equals(JWTRecipeStorage.class.getName())) { | ||
/* Since JWT recipe tables do not store userId we do not add any data to them */ | ||
} else { | ||
throw new IllegalStateException("ClassName: " + className + " is not part of NonAuthRecipeStorage"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.