-
Notifications
You must be signed in to change notification settings - Fork 14
feat(userroles): adds recipe interface #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
bde6333
adds recipe interface
jscyo a0a6af1
feat(userroles): fixs comments
jscyo 1eda233
feat(userroles): fixs
jscyo 48c4ee8
feat(userroles): fixs comment
jscyo 8cc03bd
adds feedback
jscyo 16ba637
fixs
jscyo 672f8a7
fixs
jscyo 07c8b80
removes version changes
jscyo 9a55c5c
removes unnecessary function
jscyo 4818582
feedback changes
jscyo e1b2970
fixs function signiture
jscyo 9ebceb5
implements feedback
jscyo 1c1838d
updates deleteRole return type
jscyo 7444561
removes duplicateRoleException
jscyo bf278ab
renames createNewRole_Transaction, removes DuplicateRolePermissionMap…
jscyo 03e68a2
removes DuplicateRolePermissionMappingException
jscyo d8f6139
renames addPermissionToRole function (#35)
jscyo 50ac578
fix: updates function signitures (#36)
jscyo af8381c
updates build.gradle (#37)
jscyo dea0f0f
chore: updates changelog (#38)
jscyo 452641d
updates CHANGELOG.md
jscyo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 = "2.13.0" | ||
| version = "2.14.0" | ||
|
|
||
| repositories { | ||
| mavenCentral() | ||
|
|
||
This file contains hidden or 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
54 changes: 54 additions & 0 deletions
54
src/main/java/io/supertokens/pluginInterface/userroles/UserRolesStorage.java
This file contains hidden or 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,54 @@ | ||
| /* | ||
| * Copyright (c) 2022, 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.userroles; | ||
|
|
||
| import com.google.gson.JsonObject; | ||
| import io.supertokens.pluginInterface.Storage; | ||
| import io.supertokens.pluginInterface.exceptions.StorageQueryException; | ||
| import io.supertokens.pluginInterface.userroles.exception.DuplicateUserRoleMappingException; | ||
| import io.supertokens.pluginInterface.userroles.exception.UnknownRoleException; | ||
|
|
||
| public interface UserRolesStorage extends Storage { | ||
|
|
||
| // associate a userId with a role that exists | ||
| void addRoleToUser(String userId, String role) | ||
| throws StorageQueryException, UnknownRoleException, DuplicateUserRoleMappingException; | ||
|
|
||
| // get all roles associated with the input userId | ||
| String[] getRolesForUser(String userId) throws StorageQueryException; | ||
|
|
||
| // get all users associated with the input role | ||
| String[] getUsersForRole(String role) throws StorageQueryException; | ||
|
|
||
| // get permissions associated with the input role | ||
| String[] getPermissionsForRole(String role) throws StorageQueryException; | ||
|
|
||
| // get roles associated with the input permission | ||
| String[] getRolesThatHavePermission(String permission) throws StorageQueryException; | ||
|
|
||
| // delete a role | ||
| boolean deleteRole(String role) throws StorageQueryException; | ||
|
|
||
| // get all created roles | ||
| String[] getRoles() throws StorageQueryException; | ||
|
|
||
| // check if input roles exists | ||
| boolean doesRoleExist(String role) throws StorageQueryException; | ||
|
|
||
| // delete all roles for the input userId | ||
| int deleteAllRolesForUser(String userId) throws StorageQueryException; | ||
| } | ||
25 changes: 25 additions & 0 deletions
25
...io/supertokens/pluginInterface/userroles/exception/DuplicateUserRoleMappingException.java
This file contains hidden or 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,25 @@ | ||
| /* | ||
| * Copyright (c) 2022, 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.userroles.exception; | ||
|
|
||
| import java.io.Serial; | ||
|
|
||
| public class DuplicateUserRoleMappingException extends UserRolesException { | ||
|
|
||
| @Serial | ||
| private static final long serialVersionUID = -7619796272179436664L; | ||
| } |
24 changes: 24 additions & 0 deletions
24
src/main/java/io/supertokens/pluginInterface/userroles/exception/UnknownRoleException.java
This file contains hidden or 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) 2022, 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.userroles.exception; | ||
|
|
||
| import java.io.Serial; | ||
|
|
||
| public class UnknownRoleException extends UserRolesException { | ||
| @Serial | ||
| private static final long serialVersionUID = -8116261429148675130L; | ||
| } |
24 changes: 24 additions & 0 deletions
24
src/main/java/io/supertokens/pluginInterface/userroles/exception/UserRolesException.java
This file contains hidden or 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) 2022, 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.userroles.exception; | ||
|
|
||
| import java.io.Serial; | ||
|
|
||
| public class UserRolesException extends Exception { | ||
| @Serial | ||
| private static final long serialVersionUID = 5476530661862027675L; | ||
| } |
48 changes: 48 additions & 0 deletions
48
src/main/java/io/supertokens/pluginInterface/userroles/sqlStorage/UserRolesSQLStorage.java
This file contains hidden or 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,48 @@ | ||
| /* | ||
| * Copyright (c) 2022, 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.userroles.sqlStorage; | ||
|
|
||
| import io.supertokens.pluginInterface.exceptions.StorageQueryException; | ||
| import io.supertokens.pluginInterface.sqlStorage.SQLStorage; | ||
| import io.supertokens.pluginInterface.sqlStorage.TransactionConnection; | ||
| import io.supertokens.pluginInterface.userroles.UserRolesStorage; | ||
| import io.supertokens.pluginInterface.userroles.exception.UnknownRoleException; | ||
|
|
||
| public interface UserRolesSQLStorage extends UserRolesStorage, SQLStorage { | ||
|
|
||
| // delete role associated with the input userId from the input roles | ||
| boolean deleteRoleForUser_Transaction(TransactionConnection con, String userId, String role) | ||
| throws StorageQueryException; | ||
|
|
||
| // create a new role if it doesnt exist | ||
| boolean createNewRoleOrDoNothingIfExists_Transaction(TransactionConnection con, String role) | ||
| throws StorageQueryException; | ||
|
|
||
| // associate a permission with a role | ||
| void addPermissionToRoleOrDoNothingIfExists_Transaction(TransactionConnection con, String role, String permission) | ||
| throws StorageQueryException, UnknownRoleException; | ||
|
|
||
| // delete a permission associated with the input role | ||
| boolean deletePermissionForRole_Transaction(TransactionConnection con, String role, String permission) | ||
| throws StorageQueryException; | ||
|
|
||
| // delete all permissions associated with the input role | ||
| int deleteAllPermissionsForRole_Transaction(TransactionConnection con, String role) throws StorageQueryException; | ||
|
|
||
| // check if a role exists | ||
| boolean doesRoleExist_Transaction(TransactionConnection con, String role) throws StorageQueryException; | ||
| } | ||
rishabhpoddar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.