-
Notifications
You must be signed in to change notification settings - Fork 345
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
[#5336] feat(auth-ranger): Remove MANAGED_BY_GRAVITINO limit and compatible for existing ranger policy #5629
base: main
Are you sure you want to change the base?
Conversation
hi @theoryxu Thank you for your attention to this problem The problem now is that Gravitino will only maintain a Ranger Policy with the
But that's a pretty big limitation.
|
… compatible for existing ranger policy
f2f328b
to
642983d
Compare
...thorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerHelper.java
Outdated
Show resolved
Hide resolved
...thorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerHelper.java
Outdated
Show resolved
Hide resolved
...thorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerHelper.java
Outdated
Show resolved
Hide resolved
… compatible for existing ranger policy
...thorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerHelper.java
Outdated
Show resolved
Hide resolved
...thorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerHelper.java
Outdated
Show resolved
Hide resolved
...thorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerHelper.java
Outdated
Show resolved
Hide resolved
...thorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerHelper.java
Outdated
Show resolved
Hide resolved
...thorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerHelper.java
Show resolved
Hide resolved
… compatible for existing ranger policy
… compatible for existing ranger policy
… compatible for existing ranger policy
...thorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerHelper.java
Show resolved
Hide resolved
… compatible for existing ranger policy
… compatible for existing ranger policy
… compatible for existing ranger policy
… compatible for existing ranger policy
… compatible for existing ranger policy
… compatible for existing ranger policy
public static final String GRAVITINO_METALAKE_OWNER_ROLE = "GRAVITINO_METALAKE_OWNER_ROLE"; | ||
public static final String GRAVITINO_CATALOG_OWNER_ROLE = "GRAVITINO_CATALOG_OWNER_ROLE"; | ||
|
||
// marking owner policy items | ||
public static final String GRAVITINO_PLACEHOLDER_OWNER_ROLE = "GRAVITINO_PLACEHOLDER_OWNER_ROLE"; | ||
|
||
public static final String GRAVITINO_ROLE_PREFIX = "GRAVITINO_"; | ||
|
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's better to change these code
public static final String GRAVITINO_ROLE_PREFIX = "GRAVITINO_";
public static final String GRAVITINO_METALAKE_OWNER_ROLE = GRAVITINO_ROLE_PREFIX + "METALAKE_OWNER_ROLE";
public static final String GRAVITINO_CATALOG_OWNER_ROLE = GRAVITINO_ROLE_PREFIX + "CATALOG_OWNER_ROLE";
// marking owner policy items
public static final String GRAVITINO_OWNER_ROLE = GRAVITINO_ROLE_PREFIX + "OWNER_ROLE";
The GRAVITINO_PLACEHOLDER_OWNER_ROLE
is too long.
I think we need to add a description(GRAVITINO_ROLE_PREFIX
, GRAVITINO_METALAKE_OWNER_ROLE
, GRAVITINO_CATALOG_OWNER_ROLE
and GRAVITINO_OWNER_ROLE
) in the https://github.com/apache/gravitino/blob/main/docs/security/authorization-pushdown.md
try { | ||
policy.setPolicyItems( | ||
policy.getPolicyItems().stream() | ||
.filter(i -> !isGravitinoManagedPolicyItemAccess(i)) |
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 better to change i
to item
.
"The role name should be GRAVITINO_METALAKE_OWNER_ROLE or GRAVITINO_CATALOG_OWNER_ROLE"); | ||
|| roleName.equalsIgnoreCase(GRAVITINO_CATALOG_OWNER_ROLE) | ||
|| roleName.equalsIgnoreCase(GRAVITINO_PLACEHOLDER_OWNER_ROLE), | ||
"The role name should be GRAVITINO_METALAKE_OWNER_ROLE or GRAVITINO_CATALOG_OWNER_ROLE or GRAVITINO_PLACEHOLDER_OWNER_ROLE"); |
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 better change
"The role name should be GRAVITINO_METALAKE_OWNER_ROLE or GRAVITINO_CATALOG_OWNER_ROLE or GRAVITINO_PLACEHOLDER_OWNER_ROLE"
to
String.format("The role name should be %s or %s or %s", GRAVITINO_METALAKE_OWNER_ROLE, GRAVITINO_CATALOG_OWNER_ROLE, GRAVITINO_PLACEHOLDER_OWNER_ROLE)
@@ -376,6 +425,8 @@ protected void updatePolicyOwner(RangerPolicy policy, Owner preOwner, Owner newO | |||
} else { | |||
policyItem.getGroups().add(newOwner.name()); | |||
} | |||
// mark the policy item is created by Gravitino | |||
policyItem.getRoles().add(GRAVITINO_PLACEHOLDER_OWNER_ROLE); |
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.
Maybe we need to add judgment?
if (!policyItem. getRoles().contains(GRAVITINO_PLACEHOLDER_OWNER_ROLE)) {
policyItem.getRoles().add(GRAVITINO_PLACEHOLDER_OWNER_ROLE);
}
if (!policyItem.getRoles().contains(generateGravitinoRoleName(ownerRoleName))) { | ||
policyItem.getRoles().add(generateGravitinoRoleName(ownerRoleName)); | ||
} |
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 saw many place need add role into policy item.
I think maybe we need to add a function to add a rule in the policyItem.
AddRoleToPolicyItemIfNoExists(PolicyItem policyItem, String roleName)
{
String gravitinoRoleName = generateGravitinoRoleName(roleName);
if (!policyItem.getRoles().contains(gravitinoRoleName) {
policyItem.getRoles().add(gravitinoRoleName);
}
}
Assertions.assertTrue( | ||
policyItems.stream() | ||
.anyMatch( | ||
i -> |
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's better to change i
to item
.
Assertions.assertTrue( | ||
policyItems.stream() | ||
.anyMatch( | ||
i -> |
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's better to change i
to item
.
Assertions.assertFalse( | ||
policyItems.stream() | ||
.anyMatch( | ||
i -> |
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's better to change i
to item
.
Assertions.assertTrue( | ||
policyItems.stream() | ||
.anyMatch( | ||
i -> |
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's better to change i
to item
.
List<RangerPolicy.RangerPolicyItem> items, String roleName) { | ||
return items.stream() | ||
.anyMatch( | ||
i -> |
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's better to change i
to item
.
What changes were proposed in this pull request?
Many clients and users have used Ranger for a while. Gravitino should be compatible with these cases.
There are some principles Gravitino needs to follow when it pushes down policies:
For the target, this PR includes the following changes:
wildcardSearchPolies
removes theMANAGED_BY_GRAVITINO
filter.GRAVITINO_
.Despite doing these, users should be cautious about directly managing the ranger policy. There are some restricts:
Why are the changes needed?
Fix: #5336
Does this PR introduce any user-facing change?
N/A
How was this patch tested?
Added ITs