-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: tenant config * fix: thirdparty providers * fix: cleanup * fix: providers non null * fix: changelog * fix: pr comments * reformats code * adds function to check if client exists for the app * feat: oauth - WIP (#158) * feat: oauth recipe id, sqlstoreage and response type * fix: review fixes * fix: review fixes * fix: review fix - renamed exception * feat: OAuthStorage isClientAlreadyExists * feat: delete from oauth table * fix: removing unused/unnecessary method, change return type of other * fix: merge with latest (#159) * adding dev-v6.2.0 tag to this commit to ensure building * adding dev-v6.2.0 tag to this commit to ensure building * fix: listClientsForApp * fix: oauth plugin interface updates (#160) * fix: revoke * fix: pr comments * fix: oauth storage * fix: update * fix: add m2m token * fix: revoke and cleanup * fix: logout (#161) * fix: logout * fix: session revoke in logout * fix: version and cleanup * fix: rename / refactor * fix: changelog * fix: changelog * fix: constraints --------- Co-authored-by: rishabhpoddar <[email protected]> Co-authored-by: Tamas Soltesz <[email protected]>
- Loading branch information
1 parent
e7f938d
commit a22c132
Showing
9 changed files
with
160 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ plugins { | |
id 'java-library' | ||
} | ||
|
||
version = "6.2.0" | ||
version = "6.3.0" | ||
|
||
repositories { | ||
mavenCentral() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/io/supertokens/pluginInterface/oauth/OAuthLogoutChallenge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.supertokens.pluginInterface.oauth; | ||
|
||
public class OAuthLogoutChallenge { | ||
public final String challenge; | ||
public final String clientId; | ||
public final String postLogoutRedirectionUri; | ||
public final String sessionHandle; | ||
public final String state; | ||
public final long timeCreated; | ||
|
||
public OAuthLogoutChallenge(String challenge, String clientId, String postLogoutRedirectionUri, String sessionHandle, String state, long timeCreated) { | ||
this.challenge = challenge; | ||
this.clientId = clientId; | ||
this.postLogoutRedirectionUri = postLogoutRedirectionUri; | ||
this.sessionHandle = sessionHandle; | ||
this.state = state; | ||
this.timeCreated = timeCreated; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/io/supertokens/pluginInterface/oauth/OAuthRevokeTargetType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.supertokens.pluginInterface.oauth; | ||
|
||
public enum OAuthRevokeTargetType { | ||
CLIENT_ID("client_id"), | ||
GID("gid"), | ||
JTI("jti"), | ||
SESSION_HANDLE("session_handle"); | ||
|
||
private final String value; | ||
|
||
OAuthRevokeTargetType(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/java/io/supertokens/pluginInterface/oauth/OAuthStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. | ||
* | ||
* This software is licensed under the Apache License, Version 2.0 (the | ||
* "License") as published by the Apache Software Foundation. | ||
* | ||
* You may not use this file except in compliance with the License. You may | ||
* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.supertokens.pluginInterface.oauth; | ||
|
||
import io.supertokens.pluginInterface.exceptions.StorageQueryException; | ||
import io.supertokens.pluginInterface.multitenancy.AppIdentifier; | ||
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException; | ||
import io.supertokens.pluginInterface.nonAuthRecipe.NonAuthRecipeStorage; | ||
import io.supertokens.pluginInterface.oauth.exception.DuplicateOAuthLogoutChallengeException; | ||
import io.supertokens.pluginInterface.oauth.exception.OAuthClientNotFoundException; | ||
|
||
import java.util.List; | ||
|
||
public interface OAuthStorage extends NonAuthRecipeStorage { | ||
|
||
public boolean doesOAuthClientIdExist(AppIdentifier appIdentifier, String clientId) throws | ||
StorageQueryException; | ||
|
||
public void addOrUpdateOauthClient(AppIdentifier appIdentifier, String clientId, boolean isClientCredentialsOnly) throws TenantOrAppNotFoundException, StorageQueryException; | ||
|
||
public boolean deleteOAuthClient(AppIdentifier appIdentifier, String clientId) throws StorageQueryException; | ||
|
||
public List<String> listOAuthClients(AppIdentifier appIdentifier) throws StorageQueryException; | ||
|
||
public void revokeOAuthTokensBasedOnTargetFields(AppIdentifier appIdentifier, OAuthRevokeTargetType targetType, String targetValue, long exp) throws TenantOrAppNotFoundException, StorageQueryException; | ||
|
||
public boolean isOAuthTokenRevokedBasedOnTargetFields(AppIdentifier appIdentifier, OAuthRevokeTargetType[] targetTypes, String[] targetValues, long issuedAt) throws StorageQueryException; | ||
|
||
public void addOAuthM2MTokenForStats(AppIdentifier appIdentifier, String clientId, long iat, long exp) throws OAuthClientNotFoundException, StorageQueryException; | ||
|
||
public void cleanUpExpiredAndRevokedOAuthTokensList() throws StorageQueryException; | ||
|
||
public void addOAuthLogoutChallenge(AppIdentifier appIdentifier, String challenge, String clientId, String postLogoutRedirectionUri, String sessionHandle, String state, long timeCreated) throws | ||
DuplicateOAuthLogoutChallengeException, OAuthClientNotFoundException, StorageQueryException; | ||
|
||
public OAuthLogoutChallenge getOAuthLogoutChallenge(AppIdentifier appIdentifier, String challenge) throws StorageQueryException; | ||
|
||
public void deleteOAuthLogoutChallenge(AppIdentifier appIdentifier, String challenge) throws StorageQueryException; | ||
|
||
public void deleteOAuthLogoutChallengesBefore(long time) throws StorageQueryException; | ||
|
||
public int countTotalNumberOfOAuthClients(AppIdentifier appIdentifier) throws StorageQueryException; | ||
|
||
public int countTotalNumberOfClientCredentialsOnlyOAuthClients(AppIdentifier appIdentifier) throws StorageQueryException; | ||
|
||
public int countTotalNumberOfOAuthM2MTokensCreatedSince(AppIdentifier appIdentifier, long since) throws StorageQueryException; | ||
|
||
public int countTotalNumberOfOAuthM2MTokensAlive(AppIdentifier appIdentifier) throws StorageQueryException; | ||
} |
21 changes: 21 additions & 0 deletions
21
...o/supertokens/pluginInterface/oauth/exception/DuplicateOAuthLogoutChallengeException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. | ||
* | ||
* This software is licensed under the Apache License, Version 2.0 (the | ||
* "License") as published by the Apache Software Foundation. | ||
* | ||
* You may not use this file except in compliance with the License. You may | ||
* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.supertokens.pluginInterface.oauth.exception; | ||
|
||
public class DuplicateOAuthLogoutChallengeException extends Exception { | ||
private static final long serialVersionUID = -7183235655606906540L; | ||
} |
24 changes: 24 additions & 0 deletions
24
...ain/java/io/supertokens/pluginInterface/oauth/exception/OAuthClientNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. | ||
* | ||
* This software is licensed under the Apache License, Version 2.0 (the | ||
* "License") as published by the Apache Software Foundation. | ||
* | ||
* You may not use this file except in compliance with the License. You may | ||
* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.supertokens.pluginInterface.oauth.exception; | ||
|
||
import java.io.Serial; | ||
|
||
public class OAuthClientNotFoundException extends Exception { | ||
@Serial | ||
private static final long serialVersionUID = 1412853176388698991L; | ||
} |