From b1e0ce5c81042bf229849725f7e937bca382cf03 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Thu, 21 Mar 2024 13:22:01 +0530 Subject: [PATCH] fix: backport --- CHANGELOG.md | 6 ++++++ build.gradle | 2 +- src/main/java/io/supertokens/storage/mongodb/Queries.java | 4 ++-- src/main/java/io/supertokens/storage/mongodb/Start.java | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de333fb..abe38f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [1.25.2] - 2024-03-21 + +- Adds a new `useStaticKey` param to `updateSessionInfo_Transaction` + - This enables smooth switching between `useDynamicAccessTokenSigningKey` settings by allowing refresh calls to + change the signing key type of a session + ## [1.25.1] - Fixes issue where error logs were printed to StdOut instead of StdErr. diff --git a/build.gradle b/build.gradle index 1e6fe8a..a31532d 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ plugins { id 'java-library' } -version = "1.25.1" +version = "1.25.2" repositories { mavenCentral() diff --git a/src/main/java/io/supertokens/storage/mongodb/Queries.java b/src/main/java/io/supertokens/storage/mongodb/Queries.java index 413d702..7b02f48 100644 --- a/src/main/java/io/supertokens/storage/mongodb/Queries.java +++ b/src/main/java/io/supertokens/storage/mongodb/Queries.java @@ -264,7 +264,7 @@ static SessionInfoWithLastUpdated getSessionInfo_Transaction(Start start, String } static boolean updateSessionInfo_Transaction(Start start, String sessionHandle, String refreshTokenHash2, - long expiry, String lastUpdatedSign) throws StorageQueryException { + long expiry, String lastUpdatedSign, boolean useStaticKey) throws StorageQueryException { if (lastUpdatedSign == null) { throw new StorageQueryException(new Exception("lastUpdatedSign cannot be null for this update operation")); @@ -274,7 +274,7 @@ static boolean updateSessionInfo_Transaction(Start start, String sessionHandle, MongoCollection collection = client.getCollection(Config.getConfig(start).getSessionInfoCollection()); Document toUpdate = new Document("$set", new Document("refresh_token_hash_2", refreshTokenHash2) - .append("expires_at", expiry).append("last_updated_sign", Utils.getUUID())); + .append("expires_at", expiry).append("last_updated_sign", Utils.getUUID()).append("use_static_key", useStaticKey)); UpdateResult result = collection.updateOne( Filters.and(Filters.eq("_id", sessionHandle), Filters.eq("last_updated_sign", lastUpdatedSign)), diff --git a/src/main/java/io/supertokens/storage/mongodb/Start.java b/src/main/java/io/supertokens/storage/mongodb/Start.java index 99ae55f..1bce5c9 100644 --- a/src/main/java/io/supertokens/storage/mongodb/Start.java +++ b/src/main/java/io/supertokens/storage/mongodb/Start.java @@ -139,10 +139,10 @@ public int getNumberOfSessions(TenantIdentifier tenantIdentifier) throws Storage @Override public boolean updateSessionInfo_Transaction(String sessionHandle, String refreshTokenHash2, long expiry, - String lastUpdatedSign) throws StorageQueryException { + String lastUpdatedSign, boolean useStaticKey) throws StorageQueryException { try { return Queries.updateSessionInfo_Transaction(this, sessionHandle, refreshTokenHash2, expiry, - lastUpdatedSign); + lastUpdatedSign, useStaticKey); } catch (MongoException e) { throw new StorageQueryException(e); }