From 29a7c6d3ba989af0dc1427315e491b3ccefff958 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Tue, 2 Jul 2024 11:57:35 +0530 Subject: [PATCH 1/6] fix: providers non null --- .../postgresql/queries/MultitenancyQueries.java | 1 - .../queries/multitenancy/TenantConfigSQLHelper.java | 10 ++++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/supertokens/storage/postgresql/queries/MultitenancyQueries.java b/src/main/java/io/supertokens/storage/postgresql/queries/MultitenancyQueries.java index 447ffb40..9d0ee182 100644 --- a/src/main/java/io/supertokens/storage/postgresql/queries/MultitenancyQueries.java +++ b/src/main/java/io/supertokens/storage/postgresql/queries/MultitenancyQueries.java @@ -52,7 +52,6 @@ static String getQueryToCreateTenantConfigsTable(Start start) { + "passwordless_enabled BOOLEAN," + "third_party_enabled BOOLEAN," + "is_first_factors_null BOOLEAN," - + "is_third_party_providers_null BOOLEAN," + "CONSTRAINT " + Utils.getConstraintName(schema, tenantConfigsTable, null, "pkey") + " PRIMARY KEY (connection_uri_domain, app_id, tenant_id)" + ");"; // @formatter:on diff --git a/src/main/java/io/supertokens/storage/postgresql/queries/multitenancy/TenantConfigSQLHelper.java b/src/main/java/io/supertokens/storage/postgresql/queries/multitenancy/TenantConfigSQLHelper.java index 3c9c100a..222997ed 100644 --- a/src/main/java/io/supertokens/storage/postgresql/queries/multitenancy/TenantConfigSQLHelper.java +++ b/src/main/java/io/supertokens/storage/postgresql/queries/multitenancy/TenantConfigSQLHelper.java @@ -53,13 +53,12 @@ public static TenantConfigSQLHelper.TenantConfigRowMapper getInstance(ThirdParty public TenantConfig map(ResultSet result) throws StorageQueryException { try { boolean isFirstFactorsNull = result.getBoolean("is_first_factors_null"); - boolean isThirdPartyProvidersNull = result.getBoolean("is_third_party_providers_null"); return new TenantConfig( new TenantIdentifier(result.getString("connection_uri_domain"), result.getString("app_id"), result.getString("tenant_id")), new EmailPasswordConfig(result.getBoolean("email_password_enabled")), new ThirdPartyConfig( result.getBoolean("third_party_enabled"), - providers.length == 0 && isThirdPartyProvidersNull ? null : providers), + providers), new PasswordlessConfig(result.getBoolean("passwordless_enabled")), firstFactors.length == 0 && isFirstFactorsNull ? null : firstFactors, requiredSecondaryFactors.length == 0 ? null : requiredSecondaryFactors, @@ -75,7 +74,7 @@ public static TenantConfig[] selectAll(Start start, HashMap {}, result -> { @@ -108,8 +107,8 @@ public static void create(Start start, Connection sqlCon, TenantConfig tenantCon String QUERY = "INSERT INTO " + getConfig(start).getTenantConfigsTable() + "(connection_uri_domain, app_id, tenant_id, core_config," + " email_password_enabled, passwordless_enabled, third_party_enabled," - + " is_first_factors_null, is_third_party_providers_null)" - + " VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)"; + + " is_first_factors_null)" + + " VALUES(?, ?, ?, ?, ?, ?, ?, ?)"; update(sqlCon, QUERY, pst -> { pst.setString(1, tenantConfig.tenantIdentifier.getConnectionUriDomain()); @@ -120,7 +119,6 @@ public static void create(Start start, Connection sqlCon, TenantConfig tenantCon pst.setBoolean(6, tenantConfig.passwordlessConfig.enabled); pst.setBoolean(7, tenantConfig.thirdPartyConfig.enabled); pst.setBoolean(8, tenantConfig.firstFactors == null); - pst.setBoolean(9, tenantConfig.thirdPartyConfig.providers == null); }); } From e424be6b4b2e3fc2fd8d93ebe3875416e5867289 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Tue, 2 Jul 2024 12:29:38 +0530 Subject: [PATCH 2/6] fix: changelog --- CHANGELOG.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 518be7b1..29997ea5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,16 +10,13 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [7.1.0] - Adds implementation for a new method `getConfigFieldsInfo` to fetch the plugin config fields. -- Adds `null` state for `firstFactors` and `providers` by adding `is_first_factors_null` and `is_third_party_providers_null` fields in `tenant_configs` table +- Adds `null` state for `firstFactors` by adding `is_first_factors_null` field in `tenant_configs` table ### Migration ```sql ALTER TABLE tenant_configs ADD COLUMN IF NOT EXISTS is_first_factors_null BOOLEAN DEFAULT TRUE; -ALTER TABLE tenant_configs ADD COLUMN IF NOT EXISTS is_third_party_providers_null BOOLEAN DEFAULT TRUE; - ALTER TABLE tenant_configs ALTER COLUMN is_first_factors_null DROP DEFAULT; -ALTER TABLE tenant_configs ALTER COLUMN is_third_party_providers_null DROP DEFAULT; ``` ## [7.0.1] - 2024-04-17 From 9463f1f72526d042fc9e5fc6e89b3090d9309ee4 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Mon, 8 Jul 2024 18:23:26 +0530 Subject: [PATCH 3/6] fix: build fix --- .../test/multitenancy/StorageLayerTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/java/io/supertokens/storage/postgresql/test/multitenancy/StorageLayerTest.java b/src/test/java/io/supertokens/storage/postgresql/test/multitenancy/StorageLayerTest.java index 77204865..b75bf745 100644 --- a/src/test/java/io/supertokens/storage/postgresql/test/multitenancy/StorageLayerTest.java +++ b/src/test/java/io/supertokens/storage/postgresql/test/multitenancy/StorageLayerTest.java @@ -174,11 +174,11 @@ public void storageInstanceIsReusedAcrossTenants() StorageLayer.getStorage(new TenantIdentifier(null, null, null), process.getProcess())); Assert.assertEquals( - Config.getConfig(new TenantIdentifier(null, null, null), process.getProcess()).getAccessTokenValidity(), + Config.getConfig(new TenantIdentifier(null, null, null), process.getProcess()).getAccessTokenValidityInMillis(), (long) 3600 * 1000); Assert.assertEquals(Config.getConfig(new TenantIdentifier(null, "abc", null), process.getProcess()) - .getAccessTokenValidity(), + .getAccessTokenValidityInMillis(), (long) 3601 * 1000); Assert.assertEquals( @@ -238,11 +238,11 @@ public void storageInstanceIsReusedAcrossTenantsComplex() StorageLayer.getStorage(new TenantIdentifier(null, null, null), process.getProcess())); Assert.assertEquals( - Config.getConfig(new TenantIdentifier(null, null, null), process.getProcess()).getAccessTokenValidity(), + Config.getConfig(new TenantIdentifier(null, null, null), process.getProcess()).getAccessTokenValidityInMillis(), (long) 3600 * 1000); Assert.assertEquals(Config.getConfig(new TenantIdentifier(null, "abc", null), process.getProcess()) - .getAccessTokenValidity(), + .getAccessTokenValidityInMillis(), (long) 3601 * 1000); Assert.assertEquals( @@ -453,11 +453,11 @@ public void newStorageIsNotCreatedWhenSameTenantIsAdded() existingStorage); Assert.assertEquals( - Config.getConfig(new TenantIdentifier(null, null, null), process.getProcess()).getAccessTokenValidity(), + Config.getConfig(new TenantIdentifier(null, null, null), process.getProcess()).getAccessTokenValidityInMillis(), (long) 3600 * 1000); Assert.assertEquals(Config.getConfig(new TenantIdentifier(null, "abc", null), process.getProcess()) - .getAccessTokenValidity(), + .getAccessTokenValidityInMillis(), (long) 3601 * 1000); Assert.assertEquals( From 9606b559e2d96a6ce673270a3cf3060aef7f41fa Mon Sep 17 00:00:00 2001 From: rishabhpoddar Date: Mon, 8 Jul 2024 21:53:56 +0530 Subject: [PATCH 4/6] reformats code --- .../storage/postgresql/queries/MultitenancyQueries.java | 9 ++++++--- .../postgresql/test/multitenancy/StorageLayerTest.java | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/supertokens/storage/postgresql/queries/MultitenancyQueries.java b/src/main/java/io/supertokens/storage/postgresql/queries/MultitenancyQueries.java index cdc5e919..b0c7ffe1 100644 --- a/src/main/java/io/supertokens/storage/postgresql/queries/MultitenancyQueries.java +++ b/src/main/java/io/supertokens/storage/postgresql/queries/MultitenancyQueries.java @@ -18,7 +18,9 @@ import io.supertokens.pluginInterface.exceptions.StorageQueryException; import io.supertokens.pluginInterface.exceptions.StorageTransactionLogicException; -import io.supertokens.pluginInterface.multitenancy.*; +import io.supertokens.pluginInterface.multitenancy.TenantConfig; +import io.supertokens.pluginInterface.multitenancy.TenantIdentifier; +import io.supertokens.pluginInterface.multitenancy.ThirdPartyConfig; import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException; import io.supertokens.storage.postgresql.Start; import io.supertokens.storage.postgresql.config.Config; @@ -32,8 +34,8 @@ import java.sql.SQLException; import java.util.HashMap; -import static io.supertokens.storage.postgresql.QueryExecutorTemplate.update; import static io.supertokens.storage.postgresql.QueryExecutorTemplate.execute; +import static io.supertokens.storage.postgresql.QueryExecutorTemplate.update; import static io.supertokens.storage.postgresql.config.Config.getConfig; public class MultitenancyQueries { @@ -52,7 +54,8 @@ static String getQueryToCreateTenantConfigsTable(Start start) { + "passwordless_enabled BOOLEAN," + "third_party_enabled BOOLEAN," + "is_first_factors_null BOOLEAN," - + "CONSTRAINT " + Utils.getConstraintName(schema, tenantConfigsTable, null, "pkey") + " PRIMARY KEY (connection_uri_domain, app_id, tenant_id)" + + "CONSTRAINT " + Utils.getConstraintName(schema, tenantConfigsTable, null, "pkey") + + " PRIMARY KEY (connection_uri_domain, app_id, tenant_id)" + ");"; // @formatter:on } diff --git a/src/test/java/io/supertokens/storage/postgresql/test/multitenancy/StorageLayerTest.java b/src/test/java/io/supertokens/storage/postgresql/test/multitenancy/StorageLayerTest.java index 6573a3c8..dc592a21 100644 --- a/src/test/java/io/supertokens/storage/postgresql/test/multitenancy/StorageLayerTest.java +++ b/src/test/java/io/supertokens/storage/postgresql/test/multitenancy/StorageLayerTest.java @@ -174,7 +174,8 @@ public void storageInstanceIsReusedAcrossTenants() StorageLayer.getStorage(new TenantIdentifier(null, null, null), process.getProcess())); Assert.assertEquals( - Config.getConfig(new TenantIdentifier(null, null, null), process.getProcess()).getAccessTokenValidityInMillis(), + Config.getConfig(new TenantIdentifier(null, null, null), process.getProcess()) + .getAccessTokenValidityInMillis(), (long) 3600 * 1000); Assert.assertEquals(Config.getConfig(new TenantIdentifier(null, "abc", null), process.getProcess()) @@ -238,7 +239,8 @@ public void storageInstanceIsReusedAcrossTenantsComplex() StorageLayer.getStorage(new TenantIdentifier(null, null, null), process.getProcess())); Assert.assertEquals( - Config.getConfig(new TenantIdentifier(null, null, null), process.getProcess()).getAccessTokenValidityInMillis(), + Config.getConfig(new TenantIdentifier(null, null, null), process.getProcess()) + .getAccessTokenValidityInMillis(), (long) 3600 * 1000); Assert.assertEquals(Config.getConfig(new TenantIdentifier(null, "abc", null), process.getProcess()) @@ -454,7 +456,8 @@ public void newStorageIsNotCreatedWhenSameTenantIsAdded() existingStorage); Assert.assertEquals( - Config.getConfig(new TenantIdentifier(null, null, null), process.getProcess()).getAccessTokenValidityInMillis(), + Config.getConfig(new TenantIdentifier(null, null, null), process.getProcess()) + .getAccessTokenValidityInMillis(), (long) 3600 * 1000); Assert.assertEquals(Config.getConfig(new TenantIdentifier(null, "abc", null), process.getProcess()) From 931c334b2ffe5108fff9016bc10c94ef0d58cb90 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Tue, 9 Jul 2024 12:04:18 +0530 Subject: [PATCH 5/6] fix: changelog --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef6cd014..d7b13708 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,11 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [7.1.0] +- Compatible with plugin interface version 6.2 - Adds implementation for a new method `getConfigFieldsInfo` to fetch the plugin config fields. -- Adds `null` state for `firstFactors` by adding `is_first_factors_null` field in `tenant_configs` table +- Adds `DashboardInfo` annotations to the config properties in `PostgreSQLConfig` +- Adds `null` state for `firstFactors` by adding `is_first_factors_null` field in `tenant_configs` table. The value of + this column is only applicable when there are no entries in the `tenant_first_factors` table for the tenant. ### Migration From 5438d209cc7fbb9984bc5d8378ced026bd55ba37 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Tue, 9 Jul 2024 12:08:02 +0530 Subject: [PATCH 6/6] fix: reformat --- .idea/gradle.xml | 28 ++++++++++++++-------------- .idea/misc.xml | 2 +- .idea/vcs.xml | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 14ff0eb7..889d0053 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -1,18 +1,18 @@ - - - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 6ed36dd3..3338eab6 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 35eb1ddf..9db25eef 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - - - + + + \ No newline at end of file