Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [3.0.0] - 2023-04-05

- Adds `use_static_key` `BOOLEAN` column into `session_info`
- Adds support for plugin inteface version 2.23

### Migration

- If using `access_token_signing_key_dynamic` false in the core:
- `ALTER TABLE session_info ADD COLUMN use_static_key BOOLEAN NOT NULL DEFAULT(true);`
- ```sql
INSERT INTO jwt_signing_keys(key_id, key_string, algorithm, created_at)
select CONCAT('s-', created_at_time) as key_id, value as key_string, 'RS256' as algorithm, created_at_time as created_at
from session_access_token_signing_keys;
```
- If using `access_token_signing_key_dynamic` true in the core:
- `ALTER TABLE session_info ADD COLUMN use_static_key BOOLEAN NOT NULL DEFAULT(false);`

## [2.4.0] - 2023-03-30

- Support for Dashboard Search
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'java-library'
}

version = "2.4.0"
version = "3.0.0"

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion pluginInterfaceSupported.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"_comment": "contains a list of plugin interfaces branch names that this core supports",
"versions": [
"2.22"
"2.23"
]
}
6 changes: 3 additions & 3 deletions src/main/java/io/supertokens/storage/mysql/Start.java
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,11 @@ public void close() {
@Override
public void createNewSession(String sessionHandle, String userId, String refreshTokenHash2,
JsonObject userDataInDatabase, long expiry, JsonObject userDataInJWT,
long createdAtTime)
long createdAtTime, boolean useStaticKey)
throws StorageQueryException {
try {
SessionQueries.createNewSession(this, sessionHandle, userId, refreshTokenHash2, userDataInDatabase, expiry,
userDataInJWT, createdAtTime);
userDataInJWT, createdAtTime, useStaticKey);
} catch (SQLException e) {
throw new StorageQueryException(e);
}
Expand Down Expand Up @@ -568,7 +568,7 @@ public void addInfoToNonAuthRecipesBasedOnUserId(String className, String userId
if (className.equals(SessionStorage.class.getName())) {
try {
createNewSession("sessionHandle", userId, "refreshTokenHash", new JsonObject(),
System.currentTimeMillis() + 1000000, new JsonObject(), System.currentTimeMillis());
System.currentTimeMillis() + 1000000, new JsonObject(), System.currentTimeMillis(), false);
} catch (Exception e) {
throw new StorageQueryException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public JWTSigningKeyInfo map(ResultSet result) throws Exception {
long createdAt = result.getLong("created_at");
String algorithm = result.getString("algorithm");

if (keyString.contains("|")) {
if (keyString.contains("|") || keyString.contains(";")) {
return new JWTAsymmetricSigningKeyInfo(keyId, createdAt, algorithm, keyString);
} else {
return new JWTSymmetricSigningKeyInfo(keyId, createdAt, algorithm, keyString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ static String getQueryToCreateAccessTokenSigningKeysTable(Start start) {
}

public static void createNewSession(Start start, String sessionHandle, String userId, String refreshTokenHash2,
JsonObject userDataInDatabase, long expiry, JsonObject userDataInJWT, long createdAtTime)
JsonObject userDataInDatabase, long expiry, JsonObject userDataInJWT, long createdAtTime, boolean useStaticKey)
throws SQLException, StorageQueryException {
String QUERY = "INSERT INTO " + Config.getConfig(start).getSessionInfoTable()
+ "(session_handle, user_id, refresh_token_hash_2, session_data, expires_at, jwt_user_payload, "
+ "created_at_time)" + " VALUES(?, ?, ?, ?, ?, ?, ?)";
+ "created_at_time, use_static_key)" + " VALUES(?, ?, ?, ?, ?, ?, ?, ?)";

update(start, QUERY, pst -> {
pst.setString(1, sessionHandle);
Expand All @@ -66,13 +66,14 @@ public static void createNewSession(Start start, String sessionHandle, String us
pst.setLong(5, expiry);
pst.setString(6, userDataInJWT.toString());
pst.setLong(7, createdAtTime);
pst.setBoolean(8, useStaticKey);
});
}

public static SessionInfo getSessionInfo_Transaction(Start start, Connection con, String sessionHandle)
throws SQLException, StorageQueryException {
String QUERY = "SELECT session_handle, user_id, refresh_token_hash_2, session_data, expires_at, "
+ "created_at_time, jwt_user_payload FROM " + Config.getConfig(start).getSessionInfoTable()
+ "created_at_time, jwt_user_payload, use_static_key FROM " + Config.getConfig(start).getSessionInfoTable()
+ " WHERE session_handle = ? FOR UPDATE";
return execute(con, QUERY, pst -> {
pst.setString(1, sessionHandle);
Expand Down Expand Up @@ -159,7 +160,7 @@ public static void deleteAllExpiredSessions(Start start) throws SQLException, St

public static SessionInfo getSession(Start start, String sessionHandle) throws SQLException, StorageQueryException {
String QUERY = "SELECT session_handle, user_id, refresh_token_hash_2, session_data, expires_at, "
+ "created_at_time, jwt_user_payload FROM " + Config.getConfig(start).getSessionInfoTable()
+ "created_at_time, jwt_user_payload, use_static_key FROM " + Config.getConfig(start).getSessionInfoTable()
+ " WHERE session_handle = ?";
return execute(start, QUERY, pst -> pst.setString(1, sessionHandle), result -> {
if (result.next()) {
Expand Down Expand Up @@ -251,7 +252,8 @@ public SessionInfo map(ResultSet result) throws Exception {
result.getString("refresh_token_hash_2"),
jp.parse(result.getString("session_data")).getAsJsonObject(), result.getLong("expires_at"),
jp.parse(result.getString("jwt_user_payload")).getAsJsonObject(),
result.getLong("created_at_time"));
result.getLong("created_at_time"),
result.getBoolean("use_static_key"));
}
}

Expand Down