Skip to content

fix(authz): include realm identifier in OPA authorization input for tenant isolation#4992

Merged
dimas-b merged 4 commits into
apache:mainfrom
vigneshio:fix/opa-realm-authorization-input
Jul 14, 2026
Merged

fix(authz): include realm identifier in OPA authorization input for tenant isolation#4992
dimas-b merged 4 commits into
apache:mainfrom
vigneshio:fix/opa-realm-authorization-input

Conversation

@vigneshio

@vigneshio vigneshio commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

This PR adds the realm identifier to the OPA authorization input so policies can properly enforce isolation across realms.

Previously the input sent to OPA was essentially identical for the same principal/role/resource names in different realms (only the random request_id differed), unlike the Ranger authorizer which deliberately scopes by realm.

Changes

  • Added required realm field to the OPA Context model
  • Thread realm from RealmContext through constructor injection in OpaPolarisAuthorizerFactory (same pattern as other factory dependencies)
  • Updated OpaPolarisAuthorizer to accept realm as a required constructor parameter and always include it in buildContext()
  • Regenerated opa-input-schema.json so realm is marked required

This closes the cross-realm authorization gap when using polaris.authorization.type=opa with multiple realms pointing at the same policy.

Checklist

  • Don't disclose security issues!
  • Clearly explained why
  • Added/updated tests
  • Updated CHANGELOG.md
  • Updated site docs (if user-facing)

@dimas-b

dimas-b commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

FYI: @gracechen09

dimas-b
dimas-b previously approved these changes Jul 7, 2026

@dimas-b dimas-b left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change looks reasonable to me 👍 Let's collect some more reviews, though, particularly from people working more closely with OPA 😉

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Jul 7, 2026
@vigneshio
vigneshio force-pushed the fix/opa-realm-authorization-input branch from 80f2629 to 74318bd Compare July 8, 2026 11:29
dimas-b
dimas-b previously approved these changes Jul 8, 2026

@dimas-b dimas-b left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, @vigneshio !

@gracechen09

Copy link
Copy Markdown
Contributor

Looks good to me, thanks @vigneshio for putting together the PR! This change makes sense and enables OPA authorizer to perform realm-based authorization

flyrain
flyrain previously approved these changes Jul 9, 2026

@flyrain flyrain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM overall. Left two minor comments.

Comment thread CHANGELOG.md Outdated
@vigneshio
vigneshio dismissed stale reviews from flyrain and dimas-b via 65ea87c July 9, 2026 11:00
@vigneshio
vigneshio force-pushed the fix/opa-realm-authorization-input branch 2 times, most recently from 65ea87c to ad5c427 Compare July 9, 2026 11:41
dimas-b
dimas-b previously approved these changes Jul 10, 2026
@dimas-b

dimas-b commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@vigneshio : there are odd CI failures... Could you try rebasing, please?

…enant isolation

The OPA authorizer was not receiving any realm/tenant information.
This meant that for the same principal/role/resource names, the
authorization input sent to OPA was identical across realms (except
for the random request_id).

- Add optional 'realm' field to the Context model
- Thread realm from RealmContext in OpaPolarisAuthorizerFactory
  (same pattern as RangerPolarisAuthorizerFactory)
- Update authorizer to include it in buildContext()
- Regenerate schema + update test/docs/CHANGELOG

This fixes cross-realm authorization confusion when using OPA
with multi-realm + shared policy.
@vigneshio
vigneshio force-pushed the fix/opa-realm-authorization-input branch from ad5c427 to c1bb787 Compare July 13, 2026 18:34
Comment thread CHANGELOG.md Outdated
@dimas-b
dimas-b merged commit d0a8dff into apache:main Jul 14, 2026
25 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Basic Kanban Board Jul 14, 2026
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.

4 participants