Skip to content
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

Add admin interface and operation attributes things for Attribute-Based Access Control #2405

Merged
merged 13 commits into from
Dec 24, 2024

Conversation

brfrn169
Copy link
Collaborator

Description

This PR adds the admin interface and operation attributes things for Attribute-Based Access Control (ABAC).

Related issues and/or PRs

N/A

Changes made

  • Added AbacAdmin and made DistributedTransactionAdmin extend it.
  • Added AbacOperationAttributes to manipulate the operation attributes for ABAC.
  • Support the operation attributes for ABAC in the operation builders.

Checklist

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

Release notes

N/A

@brfrn169 brfrn169 added the enhancement New feature or request label Dec 13, 2024
@brfrn169 brfrn169 self-assigned this Dec 13, 2024
Comment on lines 691 to 696
ABAC_NOT_ENABLED(
Category.USER_ERROR,
"0151",
"The Attribute-Based Access Control feature is not enabled. To use this feature, you must enable it. Note that this feature is supported only in the ScalarDB Enterprise edition",
"",
""),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josh-wong Could you please take a look at this message? 🙇

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to many of our other features (group commit, encryption, etc.), should we lowercase the naming for this feature as follows?:

Suggested change
ABAC_NOT_ENABLED(
Category.USER_ERROR,
"0151",
"The Attribute-Based Access Control feature is not enabled. To use this feature, you must enable it. Note that this feature is supported only in the ScalarDB Enterprise edition",
"",
""),
ABAC_NOT_ENABLED(
Category.USER_ERROR,
"0151",
"The attribute-based access control feature is not enabled. To use this feature, you must enable it. Note that this feature is supported only in the ScalarDB Enterprise edition",
"",
""),

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 11f38db. Thanks!

Copy link
Member

@josh-wong josh-wong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added one comment. PTAL!

Comment on lines 691 to 696
ABAC_NOT_ENABLED(
Category.USER_ERROR,
"0151",
"The Attribute-Based Access Control feature is not enabled. To use this feature, you must enable it. Note that this feature is supported only in the ScalarDB Enterprise edition",
"",
""),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to many of our other features (group commit, encryption, etc.), should we lowercase the naming for this feature as follows?:

Suggested change
ABAC_NOT_ENABLED(
Category.USER_ERROR,
"0151",
"The Attribute-Based Access Control feature is not enabled. To use this feature, you must enable it. Note that this feature is supported only in the ScalarDB Enterprise edition",
"",
""),
ABAC_NOT_ENABLED(
Category.USER_ERROR,
"0151",
"The attribute-based access control feature is not enabled. To use this feature, you must enable it. Note that this feature is supported only in the ScalarDB Enterprise edition",
"",
""),

* @param policyName the policy name
* @param username the username
* @param levelShortName the level short name
* @param defaultLevelShortName the default level short name. If null, the default is the level
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If null, the default is the level

What does "the level" exactly mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"the level" refers to the level specified by the argument levelShortName. The sentence might be confusing. 😓 Do you have any ideas for it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parameter is optional actually, and levelShortName is used instead like as a default value if defaultLevelShortName is null. So, I think the prefix of this parameter default is confusing...

If you can't change the parameter name, how about "If null, levelShortName is used instead" ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 661d076. Thanks.

* @param username the username
* @param levelShortName the level short name
* @param defaultLevelShortName the default level short name. If null, the default is the level
* @param rowLevelShortName the row level short name. If null, the default is the default level
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If null, the default is the default level

The first "the default" is different from the second "the default"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

The first "the default" means the default value of the rowLevelShortName. And the second means the default level specified by the argument defaultLevelShortName.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it feels confusing. How about using the actual parameter names like "If null, defaultLevelShortName is used instead" ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the second means the default level specified by the argument defaultLevelShortName.

defaultLevelShortName can be null. If it's null, levelShortName is used?

Copy link
Collaborator Author

@brfrn169 brfrn169 Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 661d076. Thanks.

*
* @return the level short name
*/
String getLevelShortName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess User Tag should have MaxLevel and MinLevel. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In ABAC in ScalarDB, we don’t have MinLevel. We only have MaxLevel, which is referred to simply as level.

@brfrn169 brfrn169 requested a review from josh-wong December 18, 2024 04:40
@brfrn169 brfrn169 requested a review from komamitsu December 18, 2024 04:50
Copy link
Member

@josh-wong josh-wong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left just a minor suggestion regarding the capitalization of attribute-based access control in code comments. Other than that, LGTM. Thank you!🙇🏻‍♂️

core/src/main/java/com/scalar/db/api/AbacAdmin.java Outdated Show resolved Hide resolved
Copy link
Contributor

@komamitsu komamitsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
Left some comments and suggestions.
The suggestions are mainly for the Javadoc comments.
PTAL!

core/src/main/java/com/scalar/db/api/AbacAdmin.java Outdated Show resolved Hide resolved
core/src/main/java/com/scalar/db/api/AbacAdmin.java Outdated Show resolved Hide resolved
core/src/main/java/com/scalar/db/api/AbacAdmin.java Outdated Show resolved Hide resolved
core/src/main/java/com/scalar/db/api/AbacAdmin.java Outdated Show resolved Hide resolved
core/src/main/java/com/scalar/db/api/AbacAdmin.java Outdated Show resolved Hide resolved
core/src/main/java/com/scalar/db/api/AbacAdmin.java Outdated Show resolved Hide resolved
core/src/main/java/com/scalar/db/api/AbacAdmin.java Outdated Show resolved Hide resolved
core/src/main/java/com/scalar/db/api/AbacAdmin.java Outdated Show resolved Hide resolved
core/src/main/java/com/scalar/db/api/AbacAdmin.java Outdated Show resolved Hide resolved
}

@Override
public Buildable writeTag(String policyName, String writeTag) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a confirmation. The reason for not having writeTag in InsertBuilder is that insertion uses the default tag?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the writeTag is not the rowTag. The writeTag is used for access control on existing records. Since insert operations involve adding new records, the writeTag is not applicable to them. Therefore, the InsertBuilder does not include the writeTag. Thanks.

* @param tableName the table name
* @throws ExecutionException if the operation fails
*/
default void applyPolicyToTable(String policyName, String namespaceName, String tableName)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed this method in 2c387a7.

* @param namespaceName the namespace name
* @throws ExecutionException if the operation fails
*/
default void applyPolicyToNamespace(String policyName, String namespaceName)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed this method in 2c387a7.

@brfrn169 brfrn169 requested a review from feeblefakie December 23, 2024 05:13
Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

Copy link
Contributor

@Torch3333 Torch3333 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had comments regarding the Javadoc, besides this LGTM.

core/src/main/java/com/scalar/db/api/AbacAdmin.java Outdated Show resolved Hide resolved
core/src/main/java/com/scalar/db/api/AbacAdmin.java Outdated Show resolved Hide resolved
@brfrn169 brfrn169 requested a review from Torch3333 December 24, 2024 08:56
Copy link
Contributor

@Torch3333 Torch3333 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@brfrn169 brfrn169 merged commit e982d74 into master Dec 24, 2024
48 checks passed
@brfrn169 brfrn169 deleted the add-abac branch December 24, 2024 09:51
feeblefakie pushed a commit that referenced this pull request Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants