Skip to content

Commit

Permalink
fix: versioning and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Oct 2, 2024
1 parent f1abf7f commit 4ab6d2b
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 774 deletions.
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 = "9.2.2"
version = "9.3.0"


repositories {
Expand Down
3 changes: 2 additions & 1 deletion coreDriverInterfaceSupported.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"3.1",
"4.0",
"5.0",
"5.1"
"5.1",
"5.2"
]
}
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": [
"6.2"
"6.3"
]
}
19 changes: 14 additions & 5 deletions src/main/java/io/supertokens/inmemorydb/Start.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;
import io.supertokens.pluginInterface.multitenancy.sqlStorage.MultitenancySQLStorage;
import io.supertokens.pluginInterface.oauth.OAuthLogoutChallenge;
import io.supertokens.pluginInterface.oauth.sqlStorage.OAuthSQLStorage;
import io.supertokens.pluginInterface.oauth.OAuthStorage;
import io.supertokens.pluginInterface.oauth.exception.DuplicateOAuthLogoutChallengeException;
import io.supertokens.pluginInterface.passwordless.PasswordlessCode;
import io.supertokens.pluginInterface.passwordless.PasswordlessDevice;
import io.supertokens.pluginInterface.passwordless.exception.*;
Expand Down Expand Up @@ -104,7 +105,7 @@ public class Start
implements SessionSQLStorage, EmailPasswordSQLStorage, EmailVerificationSQLStorage, ThirdPartySQLStorage,
JWTRecipeSQLStorage, PasswordlessSQLStorage, UserMetadataSQLStorage, UserRolesSQLStorage, UserIdMappingStorage,
UserIdMappingSQLStorage, MultitenancyStorage, MultitenancySQLStorage, TOTPSQLStorage, ActiveUsersStorage,
ActiveUsersSQLStorage, DashboardSQLStorage, AuthRecipeSQLStorage, OAuthSQLStorage {
ActiveUsersSQLStorage, DashboardSQLStorage, AuthRecipeSQLStorage, OAuthStorage {

private static final Object appenderLock = new Object();
private static final String ACCESS_TOKEN_SIGNING_KEY_NAME = "access_token_signing_key";
Expand Down Expand Up @@ -3023,7 +3024,7 @@ public boolean doesClientIdExistForApp(AppIdentifier appIdentifier, String clien
public void addOrUpdateClientForApp(AppIdentifier appIdentifier, String clientId, boolean isClientCredentialsOnly)
throws StorageQueryException {
try {
OAuthQueries.insertClientIdForAppId(this, appIdentifier, clientId, isClientCredentialsOnly);
OAuthQueries.insertOrUpdateClient(this, appIdentifier, clientId, isClientCredentialsOnly);
} catch (SQLException e) {
throw new StorageQueryException(e);
}
Expand All @@ -3032,7 +3033,7 @@ public void addOrUpdateClientForApp(AppIdentifier appIdentifier, String clientId
@Override
public boolean removeAppClientAssociation(AppIdentifier appIdentifier, String clientId) throws StorageQueryException {
try {
return OAuthQueries.deleteClientIdForAppId(this, clientId, appIdentifier);
return OAuthQueries.deleteClient(this, clientId, appIdentifier);
} catch (SQLException e) {
throw new StorageQueryException(e);
}
Expand Down Expand Up @@ -3080,10 +3081,18 @@ public void addM2MToken(AppIdentifier appIdentifier, String clientId, long iat,

@Override
public void addLogoutChallenge(AppIdentifier appIdentifier, String challenge, String clientId,
String postLogoutRedirectionUri, String sessionHandle, String state, long timeCreated) throws StorageQueryException {
String postLogoutRedirectionUri, String sessionHandle, String state, long timeCreated)
throws StorageQueryException, DuplicateOAuthLogoutChallengeException {
try {
OAuthQueries.addLogoutChallenge(this, appIdentifier, challenge, clientId, postLogoutRedirectionUri, sessionHandle, state, timeCreated);
} catch (SQLException e) {
SQLiteConfig config = Config.getConfig(this);
String serverMessage = e.getMessage();

if (isPrimaryKeyError(serverMessage, config.getOAuthLogoutChallengesTable(),
new String[]{"app_id", "challenge"})) {
throw new DuplicateOAuthLogoutChallengeException();
}
throw new StorageQueryException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ public static List<String> listClientsForApp(Start start, AppIdentifier appIdent
});
}

public static void insertClientIdForAppId(Start start, AppIdentifier appIdentifier, String clientId,
boolean isClientCredentialsOnly)
public static void insertOrUpdateClient(Start start, AppIdentifier appIdentifier, String clientId,
boolean isClientCredentialsOnly)
throws SQLException, StorageQueryException {
String INSERT = "INSERT INTO " + Config.getConfig(start).getOAuthClientsTable()
+ "(app_id, client_id, is_client_credentials_only) VALUES(?, ?, ?) "
Expand All @@ -159,7 +159,7 @@ public static void insertClientIdForAppId(Start start, AppIdentifier appIdentifi
});
}

public static boolean deleteClientIdForAppId(Start start, String clientId, AppIdentifier appIdentifier)
public static boolean deleteClient(Start start, String clientId, AppIdentifier appIdentifier)
throws SQLException, StorageQueryException {
String DELETE = "DELETE FROM " + Config.getConfig(start).getOAuthClientsTable()
+ " WHERE app_id = ? AND client_id = ?";
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/io/supertokens/oauth/OAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;
import io.supertokens.pluginInterface.oauth.OAuthLogoutChallenge;
import io.supertokens.pluginInterface.oauth.OAuthStorage;
import io.supertokens.pluginInterface.oauth.exception.DuplicateOAuthLogoutChallengeException;
import io.supertokens.session.jwt.JWT.JWTException;
import io.supertokens.utils.Utils;

Expand Down Expand Up @@ -575,10 +576,16 @@ public static String createLogoutRequestAndReturnRedirectUri(Main main, AppIdent

OAuthStorage oauthStorage = StorageUtils.getOAuthStorage(storage);

String logoutChallenge = UUID.randomUUID().toString();
oauthStorage.addLogoutChallenge(appIdentifier, logoutChallenge, clientId, postLogoutRedirectionUri, sessionHandle, state, System.currentTimeMillis());
while (true) {
try {
String logoutChallenge = UUID.randomUUID().toString();
oauthStorage.addLogoutChallenge(appIdentifier, logoutChallenge, clientId, postLogoutRedirectionUri, sessionHandle, state, System.currentTimeMillis());

return "{apiDomain}/oauth/logout?logout_challenge=" + logoutChallenge;
return "{apiDomain}/oauth/logout?logout_challenge=" + logoutChallenge;
} catch (DuplicateOAuthLogoutChallengeException e) {
// retry
}
}
}

public static String consumeLogoutChallengeAndGetRedirectUri(Main main, AppIdentifier appIdentifier, Storage storage, String challenge) throws StorageQueryException, OAuthAPIException {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/supertokens/utils/SemVer.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class SemVer implements Comparable<SemVer> {
public static final SemVer v4_0 = new SemVer("4.0");
public static final SemVer v5_0 = new SemVer("5.0");
public static final SemVer v5_1 = new SemVer("5.1");
public static final SemVer v5_2 = new SemVer("5.2");

final private String version;

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/supertokens/webserver/WebserverAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ public abstract class WebserverAPI extends HttpServlet {
supportedVersions.add(SemVer.v4_0);
supportedVersions.add(SemVer.v5_0);
supportedVersions.add(SemVer.v5_1);
supportedVersions.add(SemVer.v5_2);
}

public static SemVer getLatestCDIVersion() {
return SemVer.v5_1;
return SemVer.v5_2;
}

public SemVer getLatestCDIVersionForRequest(HttpServletRequest req)
Expand Down
Loading

0 comments on commit 4ab6d2b

Please sign in to comment.