diff --git a/CHANGELOG.md b/CHANGELOG.md index 9602ac67..814d9d45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,23 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [2.18.0] - 2022-08-18 + +- Adds `LOG_LEVEL` enum, and changes `initFileLogging` interface function to accept a log level. + +## [2.17.0] - 2022-08-10 + +- Adds `getUserIdMappingForSuperTokensIds` to the UserIdMapping Interface +- Adds `isUserIdBeingUsedInNonAuthRecipe` and `addInfoToNonAuthRecipesBasedOnUserId` to the Storage Interface +- Adds `NonAuthRecipeStorage` Interface +- All non-auth recipes now extend the `NonAuthRecipeStorage` Interface + ## [2.16.0] - 2022-07-25 - UserId Mapping interface +## [2.16.0] - 2022-07-25 + ## [2.15.0] - 2022-06-07 - Changes name of `getAllSessionHandlesForUser` to `getAllNonExpiredSessionHandlesForUser`. diff --git a/build.gradle b/build.gradle index 56130f3e..81dccd1f 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ plugins { id 'java-library' } -version = "2.16.0" +version = "2.18.0" repositories { mavenCentral() diff --git a/jar/plugin-interface-2.15.0.jar b/jar/plugin-interface-2.18.0.jar similarity index 59% rename from jar/plugin-interface-2.15.0.jar rename to jar/plugin-interface-2.18.0.jar index 91715437..f69f74b7 100644 Binary files a/jar/plugin-interface-2.15.0.jar and b/jar/plugin-interface-2.18.0.jar differ diff --git a/src/main/java/io/supertokens/pluginInterface/LOG_LEVEL.java b/src/main/java/io/supertokens/pluginInterface/LOG_LEVEL.java new file mode 100644 index 00000000..c53c1578 --- /dev/null +++ b/src/main/java/io/supertokens/pluginInterface/LOG_LEVEL.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2020, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + */ + +package io.supertokens.pluginInterface; + +public enum LOG_LEVEL { + NONE, DEBUG, INFO, WARN, ERROR +} diff --git a/src/main/java/io/supertokens/pluginInterface/Storage.java b/src/main/java/io/supertokens/pluginInterface/Storage.java index 029da4e5..2eb896a4 100644 --- a/src/main/java/io/supertokens/pluginInterface/Storage.java +++ b/src/main/java/io/supertokens/pluginInterface/Storage.java @@ -19,12 +19,14 @@ import io.supertokens.pluginInterface.exceptions.StorageQueryException; +import java.util.Set; + 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); + void loadConfig(String configFilePath, Set logLevels); void initFileLogging(String infoLogPath, String errorLogPath); @@ -49,4 +51,11 @@ public interface Storage { boolean canBeUsed(String configFilePath); + // 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; + + // 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; + } diff --git a/src/main/java/io/supertokens/pluginInterface/emailverification/EmailVerificationStorage.java b/src/main/java/io/supertokens/pluginInterface/emailverification/EmailVerificationStorage.java index ed13d7e3..c9df0b26 100644 --- a/src/main/java/io/supertokens/pluginInterface/emailverification/EmailVerificationStorage.java +++ b/src/main/java/io/supertokens/pluginInterface/emailverification/EmailVerificationStorage.java @@ -19,8 +19,9 @@ import io.supertokens.pluginInterface.Storage; import io.supertokens.pluginInterface.emailverification.exception.DuplicateEmailVerificationTokenException; import io.supertokens.pluginInterface.exceptions.StorageQueryException; +import io.supertokens.pluginInterface.nonAuthRecipe.NonAuthRecipeStorage; -public interface EmailVerificationStorage extends Storage { +public interface EmailVerificationStorage extends NonAuthRecipeStorage { void addEmailVerificationToken(EmailVerificationTokenInfo emailVerificationInfo) throws StorageQueryException, DuplicateEmailVerificationTokenException; diff --git a/src/main/java/io/supertokens/pluginInterface/jwt/JWTRecipeStorage.java b/src/main/java/io/supertokens/pluginInterface/jwt/JWTRecipeStorage.java index c4a7c73a..5296d722 100644 --- a/src/main/java/io/supertokens/pluginInterface/jwt/JWTRecipeStorage.java +++ b/src/main/java/io/supertokens/pluginInterface/jwt/JWTRecipeStorage.java @@ -16,7 +16,7 @@ package io.supertokens.pluginInterface.jwt; -import io.supertokens.pluginInterface.Storage; +import io.supertokens.pluginInterface.nonAuthRecipe.NonAuthRecipeStorage; -public interface JWTRecipeStorage extends Storage { +public interface JWTRecipeStorage extends NonAuthRecipeStorage { } diff --git a/src/main/java/io/supertokens/pluginInterface/nonAuthRecipe/NonAuthRecipeStorage.java b/src/main/java/io/supertokens/pluginInterface/nonAuthRecipe/NonAuthRecipeStorage.java new file mode 100644 index 00000000..b31fce60 --- /dev/null +++ b/src/main/java/io/supertokens/pluginInterface/nonAuthRecipe/NonAuthRecipeStorage.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package io.supertokens.pluginInterface.nonAuthRecipe; + +import io.supertokens.pluginInterface.Storage; + +// All Non-Auth Recipes will extend this interface. +// We will use this interface in testing to check If the createUserIdMapping and deleteUserIdMapping functions have checks for all nonAuthRecipes +public interface NonAuthRecipeStorage extends Storage { +} diff --git a/src/main/java/io/supertokens/pluginInterface/session/SessionStorage.java b/src/main/java/io/supertokens/pluginInterface/session/SessionStorage.java index 58bdfeae..638f2462 100644 --- a/src/main/java/io/supertokens/pluginInterface/session/SessionStorage.java +++ b/src/main/java/io/supertokens/pluginInterface/session/SessionStorage.java @@ -19,10 +19,11 @@ import com.google.gson.JsonObject; import io.supertokens.pluginInterface.Storage; import io.supertokens.pluginInterface.exceptions.StorageQueryException; +import io.supertokens.pluginInterface.nonAuthRecipe.NonAuthRecipeStorage; import javax.annotation.Nullable; -public interface SessionStorage extends Storage { +public interface SessionStorage extends NonAuthRecipeStorage { void createNewSession(String sessionHandle, String userId, String refreshTokenHash2, JsonObject userDataInDatabase, long expiry, JsonObject userDataInJWT, long createdAtTime) throws StorageQueryException; diff --git a/src/main/java/io/supertokens/pluginInterface/useridmapping/UserIdMappingStorage.java b/src/main/java/io/supertokens/pluginInterface/useridmapping/UserIdMappingStorage.java index 9a0e45b8..2f68c51c 100644 --- a/src/main/java/io/supertokens/pluginInterface/useridmapping/UserIdMappingStorage.java +++ b/src/main/java/io/supertokens/pluginInterface/useridmapping/UserIdMappingStorage.java @@ -22,6 +22,8 @@ import io.supertokens.pluginInterface.useridmapping.exception.UserIdMappingAlreadyExistsException; import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.HashMap; public interface UserIdMappingStorage extends Storage { @@ -37,4 +39,9 @@ void createUserIdMapping(String superTokensUserId, String externalUserId, @Nulla boolean updateOrDeleteExternalUserIdInfo(String userId, boolean isSuperTokensUserId, @Nullable String externalUserIdInfo) throws StorageQueryException; + // This function will be used to retrieve the userId mapping for a list of userIds. The key of the HashMap will be + // superTokensUserId and the value will be the externalUserId. If a mapping does not exist for an input userId, + // it will not be in a part of the returned HashMap + HashMap getUserIdMappingForSuperTokensIds(ArrayList userIds) throws StorageQueryException; + } diff --git a/src/main/java/io/supertokens/pluginInterface/usermetadata/UserMetadataStorage.java b/src/main/java/io/supertokens/pluginInterface/usermetadata/UserMetadataStorage.java index 46715ca6..560f77cf 100644 --- a/src/main/java/io/supertokens/pluginInterface/usermetadata/UserMetadataStorage.java +++ b/src/main/java/io/supertokens/pluginInterface/usermetadata/UserMetadataStorage.java @@ -19,8 +19,9 @@ import com.google.gson.JsonObject; import io.supertokens.pluginInterface.Storage; import io.supertokens.pluginInterface.exceptions.StorageQueryException; +import io.supertokens.pluginInterface.nonAuthRecipe.NonAuthRecipeStorage; -public interface UserMetadataStorage extends Storage { +public interface UserMetadataStorage extends NonAuthRecipeStorage { JsonObject getUserMetadata(String userId) throws StorageQueryException; int deleteUserMetadata(String userId) throws StorageQueryException; diff --git a/src/main/java/io/supertokens/pluginInterface/userroles/UserRolesStorage.java b/src/main/java/io/supertokens/pluginInterface/userroles/UserRolesStorage.java index 216b7a2a..ddf91633 100644 --- a/src/main/java/io/supertokens/pluginInterface/userroles/UserRolesStorage.java +++ b/src/main/java/io/supertokens/pluginInterface/userroles/UserRolesStorage.java @@ -19,10 +19,11 @@ import com.google.gson.JsonObject; import io.supertokens.pluginInterface.Storage; import io.supertokens.pluginInterface.exceptions.StorageQueryException; +import io.supertokens.pluginInterface.nonAuthRecipe.NonAuthRecipeStorage; import io.supertokens.pluginInterface.userroles.exception.DuplicateUserRoleMappingException; import io.supertokens.pluginInterface.userroles.exception.UnknownRoleException; -public interface UserRolesStorage extends Storage { +public interface UserRolesStorage extends NonAuthRecipeStorage { // associate a userId with a role that exists void addRoleToUser(String userId, String role)