From 80165917db08cf9105e07c2b7418c10bde879a87 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Thu, 7 Mar 2024 17:53:04 +0530 Subject: [PATCH] merge latest (#141) * fix: fixes storage handling for non-auth recipes (#140) * fix: non auth stuff * fix: AppIdentifier * fix: interface changes * fix: multitenancy storage * fix: update add user role * fix: cleanup * fix: user role storage updates * fix: user roles * fix: version and changelog * adding dev-v5.0.0 tag to this commit to ensure building --------- Co-authored-by: rishabhpoddar --- CHANGELOG.md | 7 +- ...e-4.0.5.jar => plugin-interface-5.0.0.jar} | Bin 96628 -> 94584 bytes .../pluginInterface/StorageUtils.java | 136 +++++++++++++++ .../sqlStorage/AuthRecipeSQLStorage.java | 1 - .../multitenancy/AppIdentifier.java | 4 - .../AppIdentifierWithStorage.java | 162 ------------------ .../multitenancy/MultitenancyStorage.java | 5 - .../multitenancy/TenantIdentifier.java | 5 - .../TenantIdentifierWithStorage.java | 133 -------------- .../sqlStorage/UserIdMappingSQLStorage.java | 1 - .../userroles/UserRolesStorage.java | 7 +- 11 files changed, 147 insertions(+), 314 deletions(-) rename jar/{plugin-interface-4.0.5.jar => plugin-interface-5.0.0.jar} (72%) create mode 100644 src/main/java/io/supertokens/pluginInterface/StorageUtils.java delete mode 100644 src/main/java/io/supertokens/pluginInterface/multitenancy/AppIdentifierWithStorage.java delete mode 100644 src/main/java/io/supertokens/pluginInterface/multitenancy/TenantIdentifierWithStorage.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d7a8bcc..e18558b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] -## [5.0.0] - 2023-11-29 +## [6.0.0] - 2024-03-04 - Replace `TotpNotEnabledException` with `UnknownUserTotpIdException` - ActiveUsersSQLStorage interface changes @@ -26,6 +26,11 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - This enables smooth switching between `useDynamicAccessTokenSigningKey` settings by allowing refresh calls to change the signing key type of a session +## [5.0.0] - 2024-03-05 + +- Removes types `AppIdentifierWithStorage` and `TenantIdentifierWithStorage` +- Adds `deleteAllUserRoleAssociationsForRole` function to `UserRolesStorage` + ## [4.0.5] - 2023-12-05 - Adds `InvalidConfigException` to throws list of `canBeUsed` function diff --git a/jar/plugin-interface-4.0.5.jar b/jar/plugin-interface-5.0.0.jar similarity index 72% rename from jar/plugin-interface-4.0.5.jar rename to jar/plugin-interface-5.0.0.jar index 5d03cb99a849b9e5fa3de86c29c680818b2302de..629363a2cc429ea0ef90b95cc95591405cb9e9aa 100644 GIT binary patch delta 11893 zcmZu%2|QHa7oTSdW9<9BFJ;e`C6Vmemz14k-$^AVDU}x0E3Xy((juf9B@#-JND?JW zh>}7SQmOv;EtdKH{`2`v^SbAp?^*7-=iYmssjtkl@0dBA>=>EIBoZqtDK;|L^BAWB z6ZWfbqZAGPPXZqX^dInH1mCb24Mx(U2+DHoiV80B%7`fj{2vy8EO=1DLzVQ=4v0j$ zz)T{of#W0q! z>0*>NkpkPI_LmRTKeS2riPms5iX^UcURP0l^BI`X&U*?Iyewq~w)^?v8a-xsY?Hqqo;16uzMo`^8~ z({k4K!|quAIhKI+u?F>3wbJ+2Qxz%A}`+grXtYD zPq@tT-QOo^lP?YTS_+NmI}}_z`mJ9#%-w#g$-SQ~--WBLby)TpB{>Ycw623Ucb}fo zYq)Owi|rXtnP6dERY0s-@#lcz+jZ-0^97>y>q-PB^m;Ol;#?l|${0$`cqYe?E4a8s zpS1CR<(AYv+AvX&uIkufyf=hn=*MPzPmPD$IX%)C7xMzkgKS1e4m1zGuH7=D2J%1( zj+<44OJ>hw})rp`0g-lD{j!>U}HV zEj(PvgdrqB>*vvcFkL|(2SjKt;_=H8UtfPFT=EngRZ9LU5w<3U z3_K#o=IY+cfdIFIuPd-pla{UQN?3DY5W_&k%^-GIeFXtxvf?}e(x=i+Je8}7GH{}6 zUwzJ8Z5%OzD zORqI2>UK$o(~iqit#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?gu_$UdkC&V1~+-}58h?J*~5@!u){dal1E-05G}#o%XB=D z7Wguo37M7>1d6^wfsGE3^Wu}RumX``SZGU?XgWfyv?)X{F?2)_VIl95NxnAf+@P)! zz)rzEgYy53qT?@O8#V{Ui+torzv!ai(n}aFN{k-c+M=0Gkfje>Skq2W(ZeMJB2${- z9Efv)O4;0bGv~W<5qkvs+WoZ)Puj~QD5nb`j<_f@f2mReg0Vq< z+LJ+(=3!&r2uhv%8>c9Q;($=(U1IkFjM67Ae?q5g)LS!GD3E)LD64u_U`sY9Vb-Cy zFiV4IJ4c$fkr+MPAlC0?m?Z~RxRE>@wpv%IR748bpuHAHIfP0kEk%b zp8{TX-^|i2cSv!{Kc4b`T8Df-DEkC29fXMS%XDD8$EKEZ9*~w#TUetWo2`Q^om{@a zZ7N8Ve^2|L(hmiK)uW&w-b1sZE?E#I|D?eDgMbjJi@|ey%r`_~jwis6IQ(~m2U0}- zqSb>UiB>CY#Ct1Shqz0gkRq2KB+phgkd{ESF}#n96^1m?Ky6Ast^fGB3Fn2cXKy2} zd}7|xg2+-jZT)YsAhdNvnzL!WAZxSaEIQEL3lK%aLh_WoL7e?54fc9%CUypvnue)* zpr-d`PI2B4RR#cY{(!)LHkU~D#$ik^1sR6v->Xu_2=2pvD8#)`h~!IBRjR)-ivLeB zOl^muvfv+|O@A2=K~^QG5%L8(U>6v2Xp=>NSx;#$Ee!ZIdk$RngCIMKx|LL7%dv#x)l zibNH9<0OAuya6f%Lm4=Zg(jYVuK@yqPzsp^5tAUac}H5+pMlAN|H!l;w5KP#rO5<> zAb^N4NiJx!Z=Hq7iT}uS;Cv7u^Ph;t{`wC`d|MPwp#XSE5TF5FgEw0~AQ;m1;~$R^ zoaBQpvcoU!X#V?QK&QlCVV*5OhK_&Ur>-OAHB0!Z$>jJb@#L%sT|64WM`{{!j$nI`}M diff --git a/src/main/java/io/supertokens/pluginInterface/StorageUtils.java b/src/main/java/io/supertokens/pluginInterface/StorageUtils.java new file mode 100644 index 00000000..a5edd1ac --- /dev/null +++ b/src/main/java/io/supertokens/pluginInterface/StorageUtils.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2024, 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; + +import io.supertokens.pluginInterface.authRecipe.AuthRecipeStorage; +import io.supertokens.pluginInterface.authRecipe.sqlStorage.AuthRecipeSQLStorage; +import io.supertokens.pluginInterface.dashboard.sqlStorage.DashboardSQLStorage; +import io.supertokens.pluginInterface.emailpassword.sqlStorage.EmailPasswordSQLStorage; +import io.supertokens.pluginInterface.emailverification.sqlStorage.EmailVerificationSQLStorage; +import io.supertokens.pluginInterface.multitenancy.MultitenancyStorage; +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.useridmapping.UserIdMappingStorage; +import io.supertokens.pluginInterface.usermetadata.sqlStorage.UserMetadataSQLStorage; +import io.supertokens.pluginInterface.userroles.sqlStorage.UserRolesSQLStorage; + +public class StorageUtils { + public static AuthRecipeSQLStorage getAuthRecipeStorage(Storage storage) { + if (storage.getType() != STORAGE_TYPE.SQL) { + // we only support SQL for now + throw new UnsupportedOperationException(""); + } + + return (AuthRecipeSQLStorage) storage; + } + + public static EmailPasswordSQLStorage getEmailPasswordStorage(Storage storage) { + if (storage.getType() != STORAGE_TYPE.SQL) { + // we only support SQL for now + throw new UnsupportedOperationException(""); + } + return (EmailPasswordSQLStorage) storage; + } + + public static PasswordlessSQLStorage getPasswordlessStorage(Storage storage) { + if (storage.getType() != STORAGE_TYPE.SQL) { + // we only support SQL for now + throw new UnsupportedOperationException(""); + } + return (PasswordlessSQLStorage) storage; + } + + public static ThirdPartySQLStorage getThirdPartyStorage(Storage storage) { + if (storage.getType() != STORAGE_TYPE.SQL) { + // we only support SQL for now + throw new UnsupportedOperationException(""); + } + return (ThirdPartySQLStorage) storage; + } + + public static EmailVerificationSQLStorage getEmailVerificationStorage(Storage storage) { + if (storage.getType() != STORAGE_TYPE.SQL) { + // we only support SQL for now + throw new UnsupportedOperationException(""); + } + return (EmailVerificationSQLStorage) storage; + } + + public static SessionStorage getSessionStorage(Storage storage) { + return (SessionStorage) storage; + } + + public static UserMetadataSQLStorage getUserMetadataStorage(Storage storage) { + if (storage.getType() != STORAGE_TYPE.SQL) { + // we only support SQL for now + throw new UnsupportedOperationException(""); + } + + return (UserMetadataSQLStorage) storage; + } + + public static UserIdMappingStorage getUserIdMappingStorage(Storage storage) { + if (storage.getType() != STORAGE_TYPE.SQL) { + // we only support SQL for now + throw new UnsupportedOperationException(""); + } + + return (UserIdMappingStorage) storage; + } + + public static UserRolesSQLStorage getUserRolesStorage(Storage storage) { + if (storage.getType() != STORAGE_TYPE.SQL) { + // we only support SQL for now + throw new UnsupportedOperationException(""); + } + return (UserRolesSQLStorage) storage; + } + + public static DashboardSQLStorage getDashboardStorage(Storage storage) { + if (storage.getType() != STORAGE_TYPE.SQL) { + // we only support SQL for now + throw new UnsupportedOperationException(""); + } + return (DashboardSQLStorage) storage; + } + + public static TOTPSQLStorage getTOTPStorage(Storage storage) { + if (storage.getType() != STORAGE_TYPE.SQL) { + // we only support SQL for now + throw new UnsupportedOperationException(""); + } + return (TOTPSQLStorage) storage; + } + + public static ActiveUsersStorage getActiveUsersStorage(Storage storage) { + if (storage.getType() != STORAGE_TYPE.SQL) { + // we only support SQL for now + throw new UnsupportedOperationException(""); + } + return (ActiveUsersStorage) storage; + } + + public static MultitenancyStorage getMultitenancyStorage(Storage storage) { + if (storage.getType() != STORAGE_TYPE.SQL) { + // we only support SQL for now + throw new UnsupportedOperationException(""); + } + return (MultitenancyStorage) storage; + } +} diff --git a/src/main/java/io/supertokens/pluginInterface/authRecipe/sqlStorage/AuthRecipeSQLStorage.java b/src/main/java/io/supertokens/pluginInterface/authRecipe/sqlStorage/AuthRecipeSQLStorage.java index eacc4aa2..4da3ffed 100644 --- a/src/main/java/io/supertokens/pluginInterface/authRecipe/sqlStorage/AuthRecipeSQLStorage.java +++ b/src/main/java/io/supertokens/pluginInterface/authRecipe/sqlStorage/AuthRecipeSQLStorage.java @@ -20,7 +20,6 @@ import io.supertokens.pluginInterface.authRecipe.AuthRecipeUserInfo; import io.supertokens.pluginInterface.exceptions.StorageQueryException; import io.supertokens.pluginInterface.multitenancy.AppIdentifier; -import io.supertokens.pluginInterface.multitenancy.AppIdentifierWithStorage; import io.supertokens.pluginInterface.sqlStorage.SQLStorage; import io.supertokens.pluginInterface.sqlStorage.TransactionConnection; diff --git a/src/main/java/io/supertokens/pluginInterface/multitenancy/AppIdentifier.java b/src/main/java/io/supertokens/pluginInterface/multitenancy/AppIdentifier.java index 0aa4aedf..9241ccf3 100644 --- a/src/main/java/io/supertokens/pluginInterface/multitenancy/AppIdentifier.java +++ b/src/main/java/io/supertokens/pluginInterface/multitenancy/AppIdentifier.java @@ -80,8 +80,4 @@ public int hashCode() { public TenantIdentifier getAsPublicTenantIdentifier() { return new TenantIdentifier(this.getConnectionUriDomain(), this.getAppId(), null); } - - public AppIdentifierWithStorage withStorage(Storage storage) { - return new AppIdentifierWithStorage(this.getConnectionUriDomain(), this.getAppId(), storage); - } } diff --git a/src/main/java/io/supertokens/pluginInterface/multitenancy/AppIdentifierWithStorage.java b/src/main/java/io/supertokens/pluginInterface/multitenancy/AppIdentifierWithStorage.java deleted file mode 100644 index b3c14185..00000000 --- a/src/main/java/io/supertokens/pluginInterface/multitenancy/AppIdentifierWithStorage.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2023, 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.multitenancy; - -import io.supertokens.pluginInterface.ActiveUsersSQLStorage; -import io.supertokens.pluginInterface.STORAGE_TYPE; -import io.supertokens.pluginInterface.Storage; -import io.supertokens.pluginInterface.authRecipe.AuthRecipeStorage; -import io.supertokens.pluginInterface.dashboard.sqlStorage.DashboardSQLStorage; -import io.supertokens.pluginInterface.emailpassword.sqlStorage.EmailPasswordSQLStorage; -import io.supertokens.pluginInterface.emailverification.sqlStorage.EmailVerificationSQLStorage; -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.useridmapping.UserIdMappingStorage; -import io.supertokens.pluginInterface.usermetadata.sqlStorage.UserMetadataSQLStorage; -import io.supertokens.pluginInterface.userroles.sqlStorage.UserRolesSQLStorage; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class AppIdentifierWithStorage extends AppIdentifier { - - @Nonnull - private final Storage storage; - - private final Storage[] storages; - - public AppIdentifierWithStorage(@Nullable String connectionUriDomain, @Nullable String appId, @Nonnull - Storage storage) { - super(connectionUriDomain, appId); - this.storage = storage; - this.storages = new Storage[]{storage}; - } - - public AppIdentifierWithStorage(@Nullable String connectionUriDomain, @Nullable String appId, @Nonnull - Storage storage, @Nonnull Storage[] storages) { - super(connectionUriDomain, appId); - this.storage = storage; - this.storages = storages; - } - - @Nonnull - public Storage getStorage() { - return storage; - } - - @Nonnull - public Storage[] getStorages() { - return storages; - } - - public AuthRecipeStorage getAuthRecipeStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - - return (AuthRecipeStorage) this.storage; - } - - public EmailPasswordSQLStorage getEmailPasswordStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - return (EmailPasswordSQLStorage) this.storage; - } - - public PasswordlessSQLStorage getPasswordlessStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - return (PasswordlessSQLStorage) this.storage; - } - - public ThirdPartySQLStorage getThirdPartyStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - return (ThirdPartySQLStorage) this.storage; - } - - public EmailVerificationSQLStorage getEmailVerificationStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - return (EmailVerificationSQLStorage) this.storage; - } - - public SessionStorage getSessionStorage() { - return (SessionStorage) this.storage; - } - - public UserMetadataSQLStorage getUserMetadataStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - - return (UserMetadataSQLStorage) this.storage; - } - - public UserIdMappingStorage getUserIdMappingStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - - return (UserIdMappingStorage) this.storage; - } - - public UserRolesSQLStorage getUserRolesStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - return (UserRolesSQLStorage) this.storage; - } - - public DashboardSQLStorage getDashboardStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - return (DashboardSQLStorage) this.storage; - } - - public TOTPSQLStorage getTOTPStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - return (TOTPSQLStorage) this.storage; - } - - public ActiveUsersSQLStorage getActiveUsersStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - return (ActiveUsersSQLStorage) this.storage; - } -} diff --git a/src/main/java/io/supertokens/pluginInterface/multitenancy/MultitenancyStorage.java b/src/main/java/io/supertokens/pluginInterface/multitenancy/MultitenancyStorage.java index d8363133..3fe7eccf 100644 --- a/src/main/java/io/supertokens/pluginInterface/multitenancy/MultitenancyStorage.java +++ b/src/main/java/io/supertokens/pluginInterface/multitenancy/MultitenancyStorage.java @@ -17,16 +17,11 @@ package io.supertokens.pluginInterface.multitenancy; import io.supertokens.pluginInterface.Storage; -import io.supertokens.pluginInterface.emailpassword.exceptions.DuplicateEmailException; -import io.supertokens.pluginInterface.emailpassword.exceptions.UnknownUserIdException; import io.supertokens.pluginInterface.exceptions.StorageQueryException; import io.supertokens.pluginInterface.multitenancy.exceptions.DuplicateClientTypeException; import io.supertokens.pluginInterface.multitenancy.exceptions.DuplicateTenantException; import io.supertokens.pluginInterface.multitenancy.exceptions.DuplicateThirdPartyIdException; import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException; -import io.supertokens.pluginInterface.passwordless.exception.DuplicatePhoneNumberException; -import io.supertokens.pluginInterface.thirdparty.exception.DuplicateThirdPartyUserException; -import io.supertokens.pluginInterface.userroles.exception.UnknownRoleException; public interface MultitenancyStorage extends Storage { diff --git a/src/main/java/io/supertokens/pluginInterface/multitenancy/TenantIdentifier.java b/src/main/java/io/supertokens/pluginInterface/multitenancy/TenantIdentifier.java index 9abac35a..ad782b1d 100644 --- a/src/main/java/io/supertokens/pluginInterface/multitenancy/TenantIdentifier.java +++ b/src/main/java/io/supertokens/pluginInterface/multitenancy/TenantIdentifier.java @@ -87,9 +87,4 @@ public int hashCode() { public AppIdentifier toAppIdentifier() { return new AppIdentifier(this.getConnectionUriDomain(), this.getAppId()); } - - public TenantIdentifierWithStorage withStorage(Storage storage) { - return new TenantIdentifierWithStorage(this.getConnectionUriDomain(), this.getAppId(), this.getTenantId(), - storage); - } } diff --git a/src/main/java/io/supertokens/pluginInterface/multitenancy/TenantIdentifierWithStorage.java b/src/main/java/io/supertokens/pluginInterface/multitenancy/TenantIdentifierWithStorage.java deleted file mode 100644 index a422f87b..00000000 --- a/src/main/java/io/supertokens/pluginInterface/multitenancy/TenantIdentifierWithStorage.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2023, 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.multitenancy; - -import io.supertokens.pluginInterface.STORAGE_TYPE; -import io.supertokens.pluginInterface.Storage; -import io.supertokens.pluginInterface.authRecipe.AuthRecipeStorage; -import io.supertokens.pluginInterface.emailpassword.sqlStorage.EmailPasswordSQLStorage; -import io.supertokens.pluginInterface.emailverification.sqlStorage.EmailVerificationSQLStorage; -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.useridmapping.UserIdMappingStorage; -import io.supertokens.pluginInterface.userroles.sqlStorage.UserRolesSQLStorage; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class TenantIdentifierWithStorage extends TenantIdentifier { - - @Nonnull - private final Storage storage; - - public TenantIdentifierWithStorage(@Nullable String connectionUriDomain, @Nullable String appId, - @Nullable String tenantId, @Nonnull - Storage storage) { - super(connectionUriDomain, appId, tenantId); - this.storage = storage; - } - - @Nonnull - public Storage getStorage() { - return storage; - } - - public AppIdentifierWithStorage toAppIdentifierWithStorage() { - return new AppIdentifierWithStorage(this.getConnectionUriDomain(), this.getAppId(), this.getStorage()); - } - - public AuthRecipeStorage getAuthRecipeStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - - return (AuthRecipeStorage) this.storage; - } - - public UserIdMappingStorage getUserIdMappingStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - - return (UserIdMappingStorage) this.storage; - } - - public EmailPasswordSQLStorage getEmailPasswordStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - - return (EmailPasswordSQLStorage) this.storage; - } - - public PasswordlessSQLStorage getPasswordlessStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - return (PasswordlessSQLStorage) this.storage; - } - - public ThirdPartySQLStorage getThirdPartyStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - return (ThirdPartySQLStorage) this.storage; - } - - public EmailVerificationSQLStorage getEmailVerificationStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - return (EmailVerificationSQLStorage) this.storage; - } - - public SessionStorage getSessionStorage() { - return (SessionStorage) this.storage; - } - - public UserRolesSQLStorage getUserRolesStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - return (UserRolesSQLStorage) this.storage; - } - - public TOTPSQLStorage getTOTPStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - return (TOTPSQLStorage) this.storage; - } - - public MultitenancyStorage getMultitenancyStorageWithTargetStorage() { - if (this.storage.getType() != STORAGE_TYPE.SQL) { - // we only support SQL for now - throw new UnsupportedOperationException(""); - } - return (MultitenancyStorage) this.storage; - } -} diff --git a/src/main/java/io/supertokens/pluginInterface/useridmapping/sqlStorage/UserIdMappingSQLStorage.java b/src/main/java/io/supertokens/pluginInterface/useridmapping/sqlStorage/UserIdMappingSQLStorage.java index 4d8ab903..445ef9b0 100644 --- a/src/main/java/io/supertokens/pluginInterface/useridmapping/sqlStorage/UserIdMappingSQLStorage.java +++ b/src/main/java/io/supertokens/pluginInterface/useridmapping/sqlStorage/UserIdMappingSQLStorage.java @@ -18,7 +18,6 @@ import io.supertokens.pluginInterface.exceptions.StorageQueryException; import io.supertokens.pluginInterface.multitenancy.AppIdentifier; -import io.supertokens.pluginInterface.multitenancy.AppIdentifierWithStorage; import io.supertokens.pluginInterface.sqlStorage.SQLStorage; import io.supertokens.pluginInterface.sqlStorage.TransactionConnection; import io.supertokens.pluginInterface.useridmapping.UserIdMapping; diff --git a/src/main/java/io/supertokens/pluginInterface/userroles/UserRolesStorage.java b/src/main/java/io/supertokens/pluginInterface/userroles/UserRolesStorage.java index 0f26d768..3928ed5f 100644 --- a/src/main/java/io/supertokens/pluginInterface/userroles/UserRolesStorage.java +++ b/src/main/java/io/supertokens/pluginInterface/userroles/UserRolesStorage.java @@ -22,13 +22,12 @@ import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException; import io.supertokens.pluginInterface.nonAuthRecipe.NonAuthRecipeStorage; import io.supertokens.pluginInterface.userroles.exception.DuplicateUserRoleMappingException; -import io.supertokens.pluginInterface.userroles.exception.UnknownRoleException; public interface UserRolesStorage extends NonAuthRecipeStorage { // associate a userId with a role that exists void addRoleToUser(TenantIdentifier tenantIdentifier, String userId, String role) - throws StorageQueryException, UnknownRoleException, DuplicateUserRoleMappingException, + throws StorageQueryException, DuplicateUserRoleMappingException, TenantOrAppNotFoundException; // get all roles associated with the input userId @@ -54,4 +53,8 @@ void addRoleToUser(TenantIdentifier tenantIdentifier, String userId, String role // delete all roles for the input userId int deleteAllRolesForUser(TenantIdentifier tenantIdentifier, String userId) throws StorageQueryException; + + // delete all user association with a role (this is called before deleting the role) + boolean deleteAllUserRoleAssociationsForRole(AppIdentifier appIdentifier, + String role) throws StorageQueryException; }