Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixes storage handling for non-auth recipes #942

Merged
merged 31 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eb4496b
fix: non auth recipe stuff
sattvikc Feb 29, 2024
d267312
fix: user roles
sattvikc Feb 29, 2024
6b2a45c
fix: half done
sattvikc Mar 1, 2024
fadf205
fix: thirdparty changes
sattvikc Mar 1, 2024
9a0ff85
fix: passwordless changes
sattvikc Mar 1, 2024
89fd936
fix: active users
sattvikc Mar 1, 2024
458c3b6
fix: session changes
sattvikc Mar 1, 2024
9eb76a1
fix: user metadata
sattvikc Mar 1, 2024
4843083
fix: user roles
sattvikc Mar 1, 2024
69a2466
fix: totp
sattvikc Mar 1, 2024
6728665
fix: email verification
sattvikc Mar 1, 2024
c61c7d7
fix: multitenancy and other minor fixes
sattvikc Mar 1, 2024
c1edaba
fix: compile errors
sattvikc Mar 1, 2024
dd688da
fix: bugs and tests
sattvikc Mar 1, 2024
c5fc6a3
fix: bugs and tests
sattvikc Mar 1, 2024
5f00b5e
fix: func rename
sattvikc Mar 1, 2024
311b9b0
fix: PR comments
sattvikc Mar 4, 2024
75b5a14
fix: pr comments
sattvikc Mar 4, 2024
38c11fd
fix: pr comments
sattvikc Mar 4, 2024
06569c0
fix: pr comments
sattvikc Mar 4, 2024
d94a381
fix: user role multitenant tests
sattvikc Mar 4, 2024
83b802c
fix: email verification tests
sattvikc Mar 4, 2024
3d93ab5
fix: user role deletion
sattvikc Mar 4, 2024
d7cbcfa
fix: user roles
sattvikc Mar 4, 2024
fb2234c
fix: user roles
sattvikc Mar 4, 2024
8945be1
fix: get tenant identifier refactor
sattvikc Mar 4, 2024
a5d7aad
fix: pr comments
sattvikc Mar 4, 2024
88539e5
fix: query
sattvikc Mar 4, 2024
8a31166
fix: tests version and changelog
sattvikc Mar 5, 2024
644b5d6
Update CHANGELOG.md
sattvikc Mar 5, 2024
0bfad8b
fix: pr comments
sattvikc Mar 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [8.0.0] - 2024-03-04

### Breaking changes

- The following app specific APIs return a 403 when not called using `public` tenant
sattvikc marked this conversation as resolved.
Show resolved Hide resolved
- GET `/recipe/accountlinking/user/primary/check`
- GET `/recipe/accountlinking/user/link/check`
- POST `/recipe/accountlinking/user/primary`
- POST `/recipe/accountlinking/user/link`
- POST `/recipe/accountlinking/user/unlink`
- GET `/users/count/active`
- POST `/user/remove`
- GET `/ee/featureflag`
- GET `/user/id`
- PUT `/ee/license`
- DELETE `/ee/license`
- GET `/ee/license`
- GET `/requests/stats`
- GET `/recipe/user` when querying by `userId`
- GET `/recipe/jwt/jwks`
- POST `/recipe/jwt`

### Fixes

- Fixes issue with non-auth recipe related storage handling

## [7.0.18] - 2024-02-19

- Fixes vulnerabilities in dependencies
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ compileTestJava { options.encoding = "UTF-8" }
// }
//}

version = "7.0.18"
version = "8.0.0"


repositories {
Expand Down
2 changes: 1 addition & 1 deletion ee/src/main/java/io/supertokens/ee/EEFeatureFlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private JsonObject getMultiTenancyStats()
return stats;
}

private JsonObject getAccountLinkingStats() throws StorageQueryException {
private JsonObject getAccountLinkingStats() throws StorageQueryException, TenantOrAppNotFoundException {
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved
JsonObject result = new JsonObject();
Storage[] storages = StorageLayer.getStoragesForApp(main, this.appIdentifier);
boolean usesAccountLinking = false;
Expand Down
35 changes: 12 additions & 23 deletions src/main/java/io/supertokens/ActiveUsers.java
Original file line number Diff line number Diff line change
@@ -1,56 +1,45 @@
package io.supertokens;

import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.StorageUtils;
import io.supertokens.pluginInterface.authRecipe.sqlStorage.AuthRecipeSQLStorage;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.exceptions.StorageTransactionLogicException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifierWithStorage;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;
import io.supertokens.storageLayer.StorageLayer;
import org.jetbrains.annotations.TestOnly;

public class ActiveUsers {

public static void updateLastActive(AppIdentifierWithStorage appIdentifierWithStorage, Main main, String userId)
public static void updateLastActive(AppIdentifier appIdentifier, Main main, String userId)
throws TenantOrAppNotFoundException {
Storage storage = StorageLayer.getStorage(appIdentifier.getAsPublicTenantIdentifier(), main);
try {
appIdentifierWithStorage.getActiveUsersStorage().updateLastActive(appIdentifierWithStorage, userId);
StorageUtils.getActiveUsersStorage(storage).updateLastActive(appIdentifier, userId);
} catch (StorageQueryException ignored) {
}
}

@TestOnly
public static void updateLastActive(Main main, String userId) {
try {
ActiveUsers.updateLastActive(new AppIdentifierWithStorage(null, null, StorageLayer.getStorage(main)), main,
userId);
ActiveUsers.updateLastActive(new AppIdentifier(null, null),
main, userId);
} catch (TenantOrAppNotFoundException e) {
throw new IllegalStateException(e);
}
}

public static int countUsersActiveSince(AppIdentifierWithStorage appIdentifierWithStorage, Main main, long time)
public static int countUsersActiveSince(Main main, AppIdentifier appIdentifier, long time)
throws StorageQueryException, TenantOrAppNotFoundException {
return appIdentifierWithStorage.getActiveUsersStorage().countUsersActiveSince(appIdentifierWithStorage, time);
Storage storage = StorageLayer.getStorage(appIdentifier.getAsPublicTenantIdentifier(), main);
return StorageUtils.getActiveUsersStorage(storage).countUsersActiveSince(appIdentifier, time);
}

@TestOnly
public static int countUsersActiveSince(Main main, long time)
throws StorageQueryException, TenantOrAppNotFoundException {
return countUsersActiveSince(new AppIdentifierWithStorage(null, null, StorageLayer.getStorage(main)), main,
time);
}

public static void removeActiveUser(AppIdentifierWithStorage appIdentifierWithStorage, String userId)
throws StorageQueryException {
try {
((AuthRecipeSQLStorage) appIdentifierWithStorage.getActiveUsersStorage()).startTransaction(con -> {
appIdentifierWithStorage.getActiveUsersStorage().deleteUserActive_Transaction(con, appIdentifierWithStorage, userId);
((AuthRecipeSQLStorage) appIdentifierWithStorage.getActiveUsersStorage()).commitTransaction(con);
return null;
});

} catch (StorageTransactionLogicException e) {
throw new StorageQueryException(e.actualException);
}
return countUsersActiveSince(main, new AppIdentifier(null, null), time);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,21 @@

package io.supertokens;

import io.supertokens.pluginInterface.multitenancy.AppIdentifierWithStorage;
import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.useridmapping.UserIdMapping;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public class AppIdentifierWithStorageAndUserIdMapping {
public class StorageAndUserIdMapping {
@Nullable
public final io.supertokens.pluginInterface.useridmapping.UserIdMapping userIdMapping;

@Nonnull
public final AppIdentifierWithStorage appIdentifierWithStorage;
public final Storage storage;

public AppIdentifierWithStorageAndUserIdMapping(AppIdentifierWithStorage appIdentifierWithStorage, UserIdMapping userIdMapping) {
this.appIdentifierWithStorage = appIdentifierWithStorage;
public StorageAndUserIdMapping(Storage storage, UserIdMapping userIdMapping) {
this.storage = storage;
this.userIdMapping = userIdMapping;

assert(this.appIdentifierWithStorage != null);
}
}

This file was deleted.

Loading
Loading