Repository navigation
[Server] Add a migration flag for stricter privilege checks #2023
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 |
|---|---|---|
|
|
@@ -110,6 +110,26 @@ values under that pattern can steer JWKS fetches (an SSRF-style surface). | |
| Use wildcard issuers only where necessary, only for domains you control, and avoid patterns that | ||
| cover internal or sensitive hosts. Prefer exact issuer URLs and `https://` issuers when possible. | ||
|
|
||
| ### Permission-check migration | ||
|
|
||
| `server.authorization.strict-privilege-checks` is a temporary migration setting. It defaults to | ||
| `true` and will be removed in a future release. Permission fixes that use this setting apply the | ||
| corrected rules by default. | ||
|
|
||
| The access checks apply only when `server.authorization=enable`. | ||
|
|
||
| To keep the previous rules during a migration, set: | ||
|
|
||
| ```properties | ||
| server.authorization.strict-privilege-checks=false | ||
| ``` | ||
|
|
||
| The setting does not disable authorization. It selects the previous rules for these checks, | ||
| including access that the corrected rules would deny. Use `false` only while updating applications | ||
| and grants. Set it back to `true` when the migration is complete. | ||
|
Comment on lines
+127
to
+129
Collaborator
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. [AI Assisted] Which checks are "these checks"?
To keep it in sync, this PR could add the heading and each dependent PR its own bullet. Also worth one sentence on scope: the expression-based checks only apply when
Collaborator
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. yeah, ive added it per dependent PR now. |
||
|
|
||
| Use the same value on every server instance. Restart each instance after changing it. | ||
|
|
||
| ### Multiple server instances | ||
|
|
||
| Authorization decisions use an in-memory Casbin policy loaded from the shared `casbin_rule` table. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ class UnityAccessEvaluatorTest { | |
| @Test | ||
| void evaluateSkipsRefreshWhenExpressionAllows() throws Exception { | ||
| UnityCatalogAuthorizer authorizer = mock(UnityCatalogAuthorizer.class); | ||
| UnityAccessEvaluator evaluator = new UnityAccessEvaluator(authorizer); | ||
| UnityAccessEvaluator evaluator = new UnityAccessEvaluator(authorizer, true); | ||
|
Collaborator
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. Should we parameterize these tests so both These four tests hard-code JUnit is 5.13.4 here, so
Collaborator
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’d leave these as is. The flag doesn’t affect refresh, and the new test already checks both values. |
||
|
|
||
| assertThat( | ||
| evaluator.evaluate( | ||
|
|
@@ -35,7 +35,7 @@ void evaluateSkipsRefreshWhenExpressionAllows() throws Exception { | |
| void evaluateKeepsDenyWhenRefreshReturnsFalse() throws Exception { | ||
| UnityCatalogAuthorizer authorizer = mock(UnityCatalogAuthorizer.class); | ||
| when(authorizer.refreshAuthorizations(anyLong())).thenReturn(false); | ||
| UnityAccessEvaluator evaluator = new UnityAccessEvaluator(authorizer); | ||
| UnityAccessEvaluator evaluator = new UnityAccessEvaluator(authorizer, true); | ||
|
|
||
| assertThat( | ||
| evaluator.evaluate( | ||
|
|
@@ -49,7 +49,7 @@ void evaluateKeepsDenyWhenRefreshThrows() throws Exception { | |
| UnityCatalogAuthorizer authorizer = mock(UnityCatalogAuthorizer.class); | ||
| when(authorizer.refreshAuthorizations(anyLong())) | ||
| .thenThrow(new RuntimeException("reload failed")); | ||
| UnityAccessEvaluator evaluator = new UnityAccessEvaluator(authorizer); | ||
| UnityAccessEvaluator evaluator = new UnityAccessEvaluator(authorizer, true); | ||
|
|
||
| assertThat( | ||
| evaluator.evaluate( | ||
|
|
@@ -68,7 +68,7 @@ void evaluateAllowsAfterSuccessfulRefresh() throws Exception { | |
| .thenReturn(false, true); | ||
| when(authorizer.refreshAuthorizations(anyLong())).thenReturn(true); | ||
|
|
||
| UnityAccessEvaluator evaluator = new UnityAccessEvaluator(authorizer); | ||
| UnityAccessEvaluator evaluator = new UnityAccessEvaluator(authorizer, true); | ||
|
|
||
| assertThat( | ||
| evaluator.evaluate( | ||
|
|
@@ -80,4 +80,19 @@ void evaluateAllowsAfterSuccessfulRefresh() throws Exception { | |
| verify(authorizer, times(1)).refreshAuthorizations(anyLong()); | ||
| verify(authorizer, times(2)).authorize(eq(principal), eq(catalog), eq(Privileges.OWNER)); | ||
| } | ||
|
|
||
| @Test | ||
| void evaluateUsesServerPrivilegeChecksSetting() throws Exception { | ||
| UnityCatalogAuthorizer authorizer = mock(UnityCatalogAuthorizer.class); | ||
| for (boolean strictPrivilegeChecks : new boolean[] {true, false}) { | ||
| UnityAccessEvaluator evaluator = new UnityAccessEvaluator(authorizer, strictPrivilegeChecks); | ||
| assertThat( | ||
| evaluator.evaluate( | ||
| UUID.randomUUID(), | ||
| "#strict_privilege_checks", | ||
| Map.of(), | ||
| Map.of("strict_privilege_checks", !strictPrivilegeChecks))) | ||
| .isEqualTo(strictPrivilegeChecks); | ||
| } | ||
| } | ||
| } | ||
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 we say here that this flag is temporary, and when it goes away? For example: "This setting is temporary and will be removed before the first stable (1.0) release. Set it to
falseonly while you update applications and grants."Right now the docs say to use
falseonly during a migration but give no deadline, and the PR description says the fallback "can be deleted after the migration" with no date. A removal target tells operators when they must have fixed their grants and scripts. It also tells contributors when the fallback conditions in the follow-up PRs can be deleted.mainis at 0.8.0-SNAPSHOT, so the flag first ships in the next release.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.
Added that it’s temporary. I’d leave the removal version open for now.