-
Notifications
You must be signed in to change notification settings - Fork 489
Refactor PolarisPrincipal to contain generic attributes #5085
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| import org.apache.polaris.core.config.FeatureConfiguration; | ||
| import org.apache.polaris.core.config.RealmConfig; | ||
| import org.apache.polaris.core.entity.PolarisEntityConstants; | ||
| import org.apache.polaris.core.entity.PrincipalEntity; | ||
|
|
||
| /** | ||
| * Common pre-condition checks shared across authorizer implementations for credential-related | ||
|
|
@@ -48,12 +49,21 @@ public static void checkCredentialRotationRequired( | |
| if (realmConfig.getConfig( | ||
| FeatureConfiguration.ENFORCE_PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_CHECKING) | ||
| && authzOp != PolarisAuthorizableOperation.ROTATE_CREDENTIALS | ||
| && polarisPrincipal | ||
| .getProperties() | ||
| .containsKey(PolarisEntityConstants.PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_STATE)) { | ||
| && mustRotateCredentials(polarisPrincipal)) { | ||
| throw new ForbiddenException( | ||
| "Principal '%s' is not authorized for op %s due to PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_STATE", | ||
| "Principal '%s' is not authorized for op %s because it must rotate credentials first", | ||
| polarisPrincipal.getName(), authzOp); | ||
| } | ||
| } | ||
|
|
||
| private static boolean mustRotateCredentials(PolarisPrincipal principal) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think that's correct. If the principal entity does not exist, it's because the principal is fully external. In that case, Polaris cannot know if the credentials need rotation. It's the external IDP's responsibility to deny the token request from such a user.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Polaris should not interfere with token generation for external principals. |
||
| return principal | ||
| .getAttribute(PolarisPrincipal.PRINCIPAL_ENTITY_ATTRIBUTE_KEY, PrincipalEntity.class) | ||
| .map(PrincipalEntity::getInternalPropertiesAsMap) | ||
| .map( | ||
| map -> | ||
| map.containsKey( | ||
| PolarisEntityConstants.PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_STATE)) | ||
| .orElse(false); | ||
| } | ||
| } | ||
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 guess we still need #5032 to forward user-level principal properties to authorizers... It will be a follow-up change. WDYT? CC: @iprithv
Uh oh!
There was an error while loading. Please reload this page.
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 don't think we'd need #5032, authorizers can get the user-facing properties as follows :
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.
Right, I mean that #5032 actually forwards user-level principal properties to OPA and Ranger (IIRC), so some extra change will be required to keep that behaviour after this PR.