Skip to content

Commit 84bed30

Browse files
authored
Merge pull request #165 from supertokens/feat/oauth/allow-list
Feat/oauth/allow list
2 parents b19309b + dedb65e commit 84bed30

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package io.supertokens.pluginInterface.oauth;
2+
3+
public class OAuthClient {
4+
public final String clientId;
5+
public final String clientSecret;
6+
public final boolean isClientCredentialsOnly;
7+
public final boolean enableRefreshTokenRotation;
8+
9+
public OAuthClient(String clientId, String clientSecret, boolean isClientCredentialsOnly, boolean enableRefreshTokenRotation) {
10+
this.clientId = clientId;
11+
this.clientSecret = clientSecret;
12+
this.isClientCredentialsOnly = isClientCredentialsOnly;
13+
this.enableRefreshTokenRotation = enableRefreshTokenRotation;
14+
}
15+
}

src/main/java/io/supertokens/pluginInterface/oauth/OAuthStorage.java

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,18 @@
2727

2828
public interface OAuthStorage extends NonAuthRecipeStorage {
2929

30-
public boolean doesOAuthClientIdExist(AppIdentifier appIdentifier, String clientId) throws
31-
StorageQueryException;
30+
public OAuthClient getOAuthClientById(AppIdentifier appIdentifier, String clientId) throws
31+
OAuthClientNotFoundException, StorageQueryException;
3232

33-
public void addOrUpdateOauthClient(AppIdentifier appIdentifier, String clientId, boolean isClientCredentialsOnly) throws TenantOrAppNotFoundException, StorageQueryException;
33+
public void addOrUpdateOauthClient(AppIdentifier appIdentifier, String clientId, String clientSecret, boolean isClientCredentialsOnly, boolean enableRefreshTokenRotation) throws TenantOrAppNotFoundException, StorageQueryException;
3434

3535
public boolean deleteOAuthClient(AppIdentifier appIdentifier, String clientId) throws StorageQueryException;
3636

37-
public List<String> listOAuthClients(AppIdentifier appIdentifier) throws StorageQueryException;
38-
39-
public void revokeOAuthTokensBasedOnTargetFields(AppIdentifier appIdentifier, OAuthRevokeTargetType targetType, String targetValue, long exp) throws TenantOrAppNotFoundException, StorageQueryException;
40-
41-
public boolean isOAuthTokenRevokedBasedOnTargetFields(AppIdentifier appIdentifier, OAuthRevokeTargetType[] targetTypes, String[] targetValues, long issuedAt) throws StorageQueryException;
37+
public List<OAuthClient> getOAuthClients(AppIdentifier appIdentifier, List<String> clientIds) throws StorageQueryException;
4238

4339
public void addOAuthM2MTokenForStats(AppIdentifier appIdentifier, String clientId, long iat, long exp) throws OAuthClientNotFoundException, StorageQueryException;
4440

45-
public void cleanUpExpiredAndRevokedOAuthTokensList() throws StorageQueryException;
41+
public void deleteExpiredOAuthM2MTokens(long exp) throws StorageQueryException;
4642

4743
public void addOAuthLogoutChallenge(AppIdentifier appIdentifier, String challenge, String clientId, String postLogoutRedirectionUri, String sessionHandle, String state, long timeCreated) throws
4844
DuplicateOAuthLogoutChallengeException, OAuthClientNotFoundException, StorageQueryException;
@@ -53,11 +49,30 @@ public void addOAuthLogoutChallenge(AppIdentifier appIdentifier, String challeng
5349

5450
public void deleteOAuthLogoutChallengesBefore(long time) throws StorageQueryException;
5551

52+
public void createOrUpdateOAuthSession(AppIdentifier appIdentifier, String gid, String clientId, String externalRefreshToken, String internalRefreshToken, String sessionHandle, List<String> jtis, long exp) throws StorageQueryException, OAuthClientNotFoundException;
53+
54+
public String getRefreshTokenMapping(AppIdentifier appIdentifier, String externalRefreshToken) throws StorageQueryException;
55+
56+
public void deleteExpiredOAuthSessions(long exp) throws StorageQueryException;
57+
5658
public int countTotalNumberOfOAuthClients(AppIdentifier appIdentifier) throws StorageQueryException;
5759

5860
public int countTotalNumberOfClientCredentialsOnlyOAuthClients(AppIdentifier appIdentifier) throws StorageQueryException;
5961

6062
public int countTotalNumberOfOAuthM2MTokensCreatedSince(AppIdentifier appIdentifier, long since) throws StorageQueryException;
6163

6264
public int countTotalNumberOfOAuthM2MTokensAlive(AppIdentifier appIdentifier) throws StorageQueryException;
65+
66+
public boolean revokeOAuthTokenByGID( AppIdentifier appIdentifier, String gid) throws StorageQueryException;
67+
68+
public boolean revokeOAuthTokenByClientId(AppIdentifier appIdentifier, String clientId) throws StorageQueryException;
69+
70+
public boolean revokeOAuthTokenBySessionHandle(AppIdentifier appIdentifier, String sessionHandle) throws StorageQueryException;
71+
72+
public boolean revokeOAuthTokenByJTI(AppIdentifier appIdentifier, String gid, String jti) throws StorageQueryException;
73+
74+
public boolean isOAuthTokenRevokedByJTI(AppIdentifier appIdentifier, String gid, String jti) throws StorageQueryException;
75+
76+
public boolean isOAuthTokenRevokedByGID(AppIdentifier appIdentifier, String gid) throws StorageQueryException;
6377
}
78+

0 commit comments

Comments
 (0)