-
Notifications
You must be signed in to change notification settings - Fork 392
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
[#2235][part-1] feat(api,core): Add the role entity #2772
Conversation
3516475
to
c76cd2e
Compare
String simpleString(); | ||
|
||
/** The name of this privilege. */ | ||
enum Name { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only list parts of privileges to avoid a too large pull request. The extra privileges will be submitted by another pull request.
core/src/main/java/com/datastrato/gravitino/authorization/RoleManager.java
Outdated
Show resolved
Hide resolved
d567611
to
65a1916
Compare
5e1f6b1
to
7715876
Compare
7715876
to
748ffbb
Compare
core/src/main/java/com/datastrato/gravitino/authorization/AccessControlManager.java
Show resolved
Hide resolved
748ffbb
to
bd564ac
Compare
bd564ac
to
83d897e
Compare
f2d5a18
to
46e2879
Compare
46e2879
to
03c627f
Compare
* The resource is the entity of the authorization. Gravitino organizes the resources using tree | ||
* structure. The resource may be a catalog, a table or a schema, etc. For example, | ||
* `catalog1.schema1.table1` represents a table named `table1`. It's in the schema named `schema1`. | ||
* The schema is in the catalog named `catalog1`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you represent the resources with name "*", would you please add more comments about the different types of resources and how you define them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved some comments from other places.
* | ||
* @return The parent resource. | ||
*/ | ||
Resource parent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you tag this method as @Nullable
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
+ " If you want to create an another resource which represents all entities," | ||
+ " you can use its parent entity, For example," | ||
+ " if you want to have read table privileges of all tables of `catalog1.schema1`," | ||
+ " you can use add `read table` privilege for `catalog1.schema1` directly"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Frankly saying, It's weird to add table privilege to the schema, it will confuse the users. Why do you hesitate to use "*"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, we give a resource a privileges list. It's a little weird to add load catalog
and load schema
privilege to catalog1.*
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Databricks follows similar style. Parent doesn't use *. https://docs.databricks.com/en/sql/language-manual/sql-ref-privileges.html
* @param names The names of the resource | ||
* @return The created {@link Resource} | ||
*/ | ||
public static Resource of(String... names) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do users use this Resource
concept, what is the relationship to the catalogs, schemas, and tables? I think the introduction of Resource
increase the understanding burden to users, users may not know how to use it, I was thinking if there's a better way to clearly define it, which will be easy for users to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about letting me user pass the names like
ofCatalog
. ofCatalog.ofSchema
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Databricks has the similar concept securable objects
.
Snowflake use securable object
, too. I will change the name to securable object
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -292,6 +292,10 @@ public Catalog createCatalog( | |||
throw new IllegalArgumentException("Can't create a catalog with with reserved name `system`"); | |||
} | |||
|
|||
if (Entity.RESOURCE_ENTITY_RESERVED_NAME.equals(ident.name())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is the basic name constraint for entities, better to let @mchades know about this and do it using Capability
framework.
@Override | ||
public String toString() { | ||
if (parent != null) { | ||
return parent + "." + name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explicitly write like parent.toString() + "." + name
to let others know that this method is recursive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
What changes were proposed in this pull request?
This pull request adds the role entity and one privilege.
I avoid to create a large pull request. I will add more privileges in the later pull request.
Why are the changes needed?
Fix: #2235
Does this PR introduce any user-facing change?
No.
How was this patch tested?
new ut.