Skip to content

Commit

Permalink
merge latest (#141)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
sattvikc and rishabhpoddar authored Mar 7, 2024
1 parent 93336d8 commit 8016591
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 314 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Binary file not shown.
136 changes: 136 additions & 0 deletions src/main/java/io/supertokens/pluginInterface/StorageUtils.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Loading

0 comments on commit 8016591

Please sign in to comment.