Skip to content

Commit a9d72a7

Browse files
committed
fix: fixing auto-merge issues
1 parent 70328ff commit a9d72a7

File tree

3 files changed

+11
-205
lines changed

3 files changed

+11
-205
lines changed

CHANGELOG.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@ CREATE TABLE IF NOT EXISTS oauth_clients (
2323
FOREIGN KEY(app_id) REFERENCES apps(app_id) ON DELETE CASCADE
2424
);
2525

26-
CREATE TABLE IF NOT EXISTS oauth_revoke (
26+
CREATE TABLE IF NOT EXISTS oauth_sessions (
27+
gid VARCHAR(255),
2728
app_id VARCHAR(64) DEFAULT 'public',
28-
target_type VARCHAR(16) NOT NULL,
29-
target_value VARCHAR(128) NOT NULL,
30-
timestamp BIGINT NOT NULL,
29+
client_id VARCHAR(255) NOT NULL,
30+
session_handle VARCHAR(128),
31+
external_refresh_token VARCHAR(255) UNIQUE,
32+
internal_refresh_token VARCHAR(255) UNIQUE,
33+
jti TEXT NOT NULL,
3134
exp BIGINT NOT NULL,
32-
PRIMARY KEY (app_id, target_type, target_value),
33-
FOREIGN KEY(app_id) REFERENCES apps(app_id) ON DELETE CASCADE
35+
PRIMARY KEY (gid),
36+
FOREIGN KEY(app_id, client_id) REFERENCES oauth_clients(app_id, client_id) ON DELETE CASCADE
3437
);
3538

36-
CREATE INDEX IF NOT EXISTS oauth_revoke_timestamp_index ON oauth_revoke(timestamp DESC, app_id DESC);
37-
CREATE INDEX IF NOT EXISTS oauth_revoke_exp_index ON oauth_revoke(exp DESC);
39+
CREATE INDEX IF NOT EXISTS oauth_session_exp_index ON oauth_sessions(exp DESC);
40+
CREATE INDEX IF NOT EXISTS oauth_session_external_refresh_token_index ON oauth_sessions(app_id, external_refresh_token DESC);
3841

3942
CREATE TABLE IF NOT EXISTS oauth_m2m_tokens (
4043
app_id VARCHAR(64) DEFAULT 'public',

src/main/java/io/supertokens/storage/postgresql/Start.java

Lines changed: 0 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -3101,33 +3101,6 @@ public int countUsersThatHaveMoreThanOneLoginMethodOrTOTPEnabledAndActiveSince(A
31013101
}
31023102
}
31033103

3104-
@Override
3105-
public boolean doesOAuthClientIdExist(AppIdentifier appIdentifier, String clientId)
3106-
throws StorageQueryException {
3107-
try {
3108-
return OAuthQueries.doesOAuthClientIdExist(this, clientId, appIdentifier);
3109-
} catch (SQLException e) {
3110-
throw new StorageQueryException(e);
3111-
}
3112-
}
3113-
3114-
@Override
3115-
public void addOrUpdateOauthClient(AppIdentifier appIdentifier, String clientId, boolean isClientCredentialsOnly)
3116-
throws StorageQueryException, TenantOrAppNotFoundException {
3117-
try {
3118-
OAuthQueries.addOrUpdateOauthClient(this, appIdentifier, clientId, isClientCredentialsOnly);
3119-
} catch (SQLException e) {
3120-
PostgreSQLConfig config = Config.getConfig(this);
3121-
if (e instanceof PSQLException) {
3122-
ServerErrorMessage serverMessage = ((PSQLException) e).getServerErrorMessage();
3123-
3124-
if (isForeignKeyConstraintError(serverMessage, config.getOAuthClientsTable(), "app_id")) {
3125-
throw new TenantOrAppNotFoundException(appIdentifier);
3126-
}
3127-
}
3128-
throw new StorageQueryException(e);
3129-
}
3130-
}
31313104

31323105
@Override
31333106
public boolean deleteOAuthClient(AppIdentifier appIdentifier, String clientId) throws StorageQueryException {
@@ -3138,156 +3111,7 @@ public boolean deleteOAuthClient(AppIdentifier appIdentifier, String clientId) t
31383111
}
31393112
}
31403113

3141-
@Override
3142-
public List<String> listOAuthClients(AppIdentifier appIdentifier) throws StorageQueryException {
3143-
try {
3144-
return OAuthQueries.listOAuthClients(this, appIdentifier);
3145-
} catch (SQLException e) {
3146-
throw new StorageQueryException(e);
3147-
}
3148-
}
3149-
3150-
@Override
3151-
public void revokeOAuthTokensBasedOnTargetFields(AppIdentifier appIdentifier, OAuthRevokeTargetType targetType, String targetValue, long exp)
3152-
throws StorageQueryException, TenantOrAppNotFoundException {
3153-
try {
3154-
OAuthQueries.revokeOAuthTokensBasedOnTargetFields(this, appIdentifier, targetType, targetValue, exp);
3155-
} catch (SQLException e) {
3156-
PostgreSQLConfig config = Config.getConfig(this);
3157-
if (e instanceof PSQLException) {
3158-
ServerErrorMessage serverMessage = ((PSQLException) e).getServerErrorMessage();
3159-
3160-
if (isForeignKeyConstraintError(serverMessage, config.getOAuthRevokeTable(), "app_id")) {
3161-
throw new TenantOrAppNotFoundException(appIdentifier);
3162-
}
3163-
}
3164-
throw new StorageQueryException(e);
3165-
}
3166-
3167-
}
3168-
3169-
@Override
3170-
public boolean isOAuthTokenRevokedBasedOnTargetFields(AppIdentifier appIdentifier, OAuthRevokeTargetType[] targetTypes, String[] targetValues, long issuedAt)
3171-
throws StorageQueryException {
3172-
try {
3173-
return OAuthQueries.isOAuthTokenRevokedBasedOnTargetFields(this, appIdentifier, targetTypes, targetValues, issuedAt);
3174-
} catch (SQLException e) {
3175-
throw new StorageQueryException(e);
3176-
}
3177-
}
3178-
3179-
@Override
3180-
public void addOAuthM2MTokenForStats(AppIdentifier appIdentifier, String clientId, long iat, long exp)
3181-
throws StorageQueryException, OAuthClientNotFoundException {
3182-
try {
3183-
OAuthQueries.addOAuthM2MTokenForStats(this, appIdentifier, clientId, iat, exp);
3184-
} catch (SQLException e) {
3185-
PostgreSQLConfig config = Config.getConfig(this);
3186-
if (e instanceof PSQLException) {
3187-
ServerErrorMessage serverMessage = ((PSQLException) e).getServerErrorMessage();
31883114

3189-
if (isForeignKeyConstraintError(serverMessage, config.getOAuthM2MTokensTable(), "client_id")) {
3190-
throw new OAuthClientNotFoundException();
3191-
}
3192-
}
3193-
throw new StorageQueryException(e);
3194-
}
3195-
}
3196-
3197-
@Override
3198-
public void cleanUpExpiredAndRevokedOAuthTokensList() throws StorageQueryException {
3199-
try {
3200-
OAuthQueries.cleanUpExpiredAndRevokedOAuthTokensList(this);
3201-
} catch (SQLException e) {
3202-
throw new StorageQueryException(e);
3203-
}
3204-
}
3205-
3206-
@Override
3207-
public void addOAuthLogoutChallenge(AppIdentifier appIdentifier, String challenge, String clientId,
3208-
String postLogoutRedirectionUri, String sessionHandle, String state, long timeCreated)
3209-
throws StorageQueryException, DuplicateOAuthLogoutChallengeException, OAuthClientNotFoundException {
3210-
try {
3211-
OAuthQueries.addOAuthLogoutChallenge(this, appIdentifier, challenge, clientId, postLogoutRedirectionUri, sessionHandle, state, timeCreated);
3212-
} catch (SQLException e) {
3213-
PostgreSQLConfig config = Config.getConfig(this);
3214-
if (e instanceof PSQLException) {
3215-
ServerErrorMessage serverMessage = ((PSQLException) e).getServerErrorMessage();
3216-
3217-
if (isPrimaryKeyError(serverMessage, config.getOAuthLogoutChallengesTable())) {
3218-
throw new DuplicateOAuthLogoutChallengeException();
3219-
} else if (isForeignKeyConstraintError(serverMessage, config.getOAuthLogoutChallengesTable(), "client_id")) {
3220-
throw new OAuthClientNotFoundException();
3221-
}
3222-
}
3223-
throw new StorageQueryException(e);
3224-
}
3225-
}
3226-
3227-
@Override
3228-
public OAuthLogoutChallenge getOAuthLogoutChallenge(AppIdentifier appIdentifier, String challenge) throws StorageQueryException {
3229-
try {
3230-
return OAuthQueries.getOAuthLogoutChallenge(this, appIdentifier, challenge);
3231-
} catch (SQLException e) {
3232-
throw new StorageQueryException(e);
3233-
}
3234-
}
3235-
3236-
@Override
3237-
public void deleteOAuthLogoutChallenge(AppIdentifier appIdentifier, String challenge) throws StorageQueryException {
3238-
try {
3239-
OAuthQueries.deleteOAuthLogoutChallenge(this, appIdentifier, challenge);
3240-
} catch (SQLException e) {
3241-
throw new StorageQueryException(e);
3242-
}
3243-
}
3244-
3245-
@Override
3246-
public void deleteOAuthLogoutChallengesBefore(long time) throws StorageQueryException {
3247-
try {
3248-
OAuthQueries.deleteOAuthLogoutChallengesBefore(this, time);
3249-
} catch (SQLException e) {
3250-
throw new StorageQueryException(e);
3251-
}
3252-
}
3253-
3254-
@Override
3255-
public int countTotalNumberOfOAuthClients(AppIdentifier appIdentifier) throws StorageQueryException {
3256-
try {
3257-
return OAuthQueries.countTotalNumberOfClients(this, appIdentifier, false);
3258-
} catch (SQLException e) {
3259-
throw new StorageQueryException(e);
3260-
}
3261-
}
3262-
3263-
@Override
3264-
public int countTotalNumberOfClientCredentialsOnlyOAuthClients(AppIdentifier appIdentifier)
3265-
throws StorageQueryException {
3266-
try {
3267-
return OAuthQueries.countTotalNumberOfClients(this, appIdentifier, true);
3268-
} catch (SQLException e) {
3269-
throw new StorageQueryException(e);
3270-
}
3271-
}
3272-
3273-
@Override
3274-
public int countTotalNumberOfOAuthM2MTokensCreatedSince(AppIdentifier appIdentifier, long since)
3275-
throws StorageQueryException {
3276-
try {
3277-
return OAuthQueries.countTotalNumberOfOAuthM2MTokensCreatedSince(this, appIdentifier, since);
3278-
} catch (SQLException e) {
3279-
throw new StorageQueryException(e);
3280-
}
3281-
}
3282-
3283-
@Override
3284-
public int countTotalNumberOfOAuthM2MTokensAlive(AppIdentifier appIdentifier) throws StorageQueryException {
3285-
try {
3286-
return OAuthQueries.countTotalNumberOfOAuthM2MTokensAlive(this, appIdentifier);
3287-
} catch (SQLException e) {
3288-
throw new StorageQueryException(e);
3289-
}
3290-
}
32913115

32923116
@TestOnly
32933117
public int getDbActivityCount(String dbname) throws SQLException, StorageQueryException {
@@ -3335,15 +3159,6 @@ public void addOrUpdateOauthClient(AppIdentifier appIdentifier, String clientId,
33353159
}
33363160
}
33373161

3338-
@Override
3339-
public boolean deleteOAuthClient(AppIdentifier appIdentifier, String clientId) throws StorageQueryException {
3340-
try {
3341-
return OAuthQueries.deleteOAuthClient(this, clientId, appIdentifier);
3342-
} catch (SQLException e) {
3343-
throw new StorageQueryException(e);
3344-
}
3345-
}
3346-
33473162
@Override
33483163
public List<OAuthClient> getOAuthClients(AppIdentifier appIdentifier, List<String> clientIds) throws StorageQueryException {
33493164
try {

src/main/java/io/supertokens/storage/postgresql/config/PostgreSQLConfig.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -434,22 +434,10 @@ public String getDashboardSessionsTable() {
434434
return addSchemaAndPrefixToTableName("dashboard_user_sessions");
435435
}
436436

437-
public String getOAuthClientsTable() {
438-
return addSchemaAndPrefixToTableName("oauth_clients");
439-
}
440-
441437
public String getOAuthRevokeTable() {
442438
return addSchemaAndPrefixToTableName("oauth_revoke");
443439
}
444440

445-
public String getOAuthM2MTokensTable() {
446-
return addSchemaAndPrefixToTableName("oauth_m2m_tokens");
447-
}
448-
449-
public String getOAuthLogoutChallengesTable() {
450-
return addSchemaAndPrefixToTableName("oauth_logout_challenges");
451-
}
452-
453441
public String getTotpUsersTable() {
454442
return addSchemaAndPrefixToTableName("totp_users");
455443
}

0 commit comments

Comments
 (0)