Skip to content

[Server] Add a migration flag for stricter privilege checks - #2023

Merged
yili-db merged 1 commit into
unitycatalog:mainfrom
timothyw553:feat/strict-privilege-checks
Oct 22, 2026
Merged

yili-db merged 1 commit into
unitycatalog:mainfrom
timothyw553:feat/strict-privilege-checks

Conversation

@timothyw553

@timothyw553 timothyw553 commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

🥞 Stacked PR

Use this link to review incremental changes.


PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

Add server.authorization.strict-privilege-checks, which defaults to true.
The following permission fixes use this setting so deployments can keep the previous rules
temporarily while updating their applications and grants. Setting it to false retains the
previous behavior, including access that the corrected checks would deny.

This PR adds the validated setting and passes it to authorization expressions as the trusted
#strict_privilege_checks variable. Request values cannot change it. The setting also reaches
response filtering through the shared evaluator. This base PR does not change permission decisions.

Use the same value on every server instance and restart each instance after changing it.
The fallback conditions and the setting can be deleted after the migration.

Tests passed with JDK 17:

build/sbt javafmtAll "server/testOnly io.unitycatalog.server.utils.ServerPropertiesTest io.unitycatalog.server.UnityCatalogServerTest"
build/sbt "server/testOnly io.unitycatalog.server.auth.decorator.UnityAccessEvaluatorTest"

33 tests passed.

Combined validation with all five dependent fixes:
build/sbt -J-Xmx2G javafmtAll "server/test": 923 tests passed.

@yili-db

yili-db commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

/review

@timothyw553
timothyw553 force-pushed the feat/strict-privilege-checks branch from fd9d70d to fe4eed8 Compare October 20, 2026 21:24
@timothyw553

Copy link
Copy Markdown
Collaborator Author

/review

Comment thread docs/server/auth.md
Comment on lines +122 to +124
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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] Which checks are "these checks"? false re-allows access, and the doc asks operators to use it only while updating applications and grants, but they can't tell which grants to update, or whether they need the flag at all. Can we list the checks it covers? From the stack, roughly:

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 server.authorization=enable, while the grant validation in #2014 applies either way.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yeah, ive added it per dependent PR now.


resourceIds.forEach((k, v) -> context.setVariable(k.name().toLowerCase(), v));
nonResourceValues.forEach(context::setVariable);
// A request value must not override the server's migration setting.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This comment is unnecessary as no code is setting strictPrivilegeChecks in nonResourceValues

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed.

resourceIds.forEach((k, v) -> context.setVariable(k.name().toLowerCase(), v));
nonResourceValues.forEach(context::setVariable);
// A request value must not override the server's migration setting.
context.setVariable("strictPrivilegeChecks", strictPrivilegeChecks);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should use strict_privilege_checks

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

sounds good, renamed to strict_privilege_checks

@timothyw553
timothyw553 force-pushed the feat/strict-privilege-checks branch 2 times, most recently from eb6a7f9 to 4f805b5 Compare October 20, 2026 22:22
@timothyw553
timothyw553 requested a review from yili-db October 20, 2026 22:36
Comment thread docs/server/auth.md
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

Copy link
Copy Markdown
Collaborator

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 false only while you update applications and grants."

Right now the docs say to use false only 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. main is at 0.8.0-SNAPSHOT, so the flag first ships in the next release.

Copy link
Copy Markdown
Collaborator Author

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.

void evaluateSkipsRefreshWhenExpressionAllows() throws Exception {
UnityCatalogAuthorizer authorizer = mock(UnityCatalogAuthorizer.class);
UnityAccessEvaluator evaluator = new UnityAccessEvaluator(authorizer);
UnityAccessEvaluator evaluator = new UnityAccessEvaluator(authorizer, true);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we parameterize these tests so both true and false run until we remove the flag?

These four tests hard-code true, and none of them reads #strict_privilege_checks, so false is only exercised by the new evaluateUsesServerPrivilegeChecksSetting. The refresh and deny logic should behave the same in both modes. A parameterized run would catch a future change that accidentally ties that logic to the flag.

JUnit is 5.13.4 here, so @ParameterizedClass with @ValueSource(booleans = {true, false}) on the class (as in BaseCredRenewITTest) runs every test in both modes with one change. The new test could then use the parameter instead of its manual loop. We would delete the parameter together with the flag.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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.

@timothyw553
timothyw553 force-pushed the feat/strict-privilege-checks branch from 4f805b5 to 7e4d213 Compare October 21, 2026 19:12
@timothyw553
timothyw553 force-pushed the feat/strict-privilege-checks branch from 7e4d213 to d63e701 Compare October 21, 2026 19:33
@yili-db
yili-db merged commit 49170d2 into unitycatalog:main Oct 22, 2026
15 of 17 checks passed
@yili-db

yili-db commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

@timothyw553 Merged. Please rebase the other stacked PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants