Skip to content

[Server] Avoid reloading OPA metadata for each privilege check #2108

Closed

Description

@timothyw553

Is your feature request related to a problem? Please describe.

In the OPA authorizer proposed in #2077, authorizeAny and authorizeAll call authorize for each evaluated privilege. Each call opens a read transaction and loads the same user, resource, and parent records again.

For example:

authorizeAny(alice, TABLE, ordersId, OWNER, SELECT)

If OPA denies OWNER, UC checks SELECT next. Both checks need the same user, table, schema, and catalog metadata, but UC reads those records twice. Only the privilege differs between the OPA requests.

Describe the solution you would like

Load the shared metadata once per authorizeAny or authorizeAll call and reuse it to build each privilege request.

  • Continue sending a separate OPA request for each evaluated privilege, in the same order and with the same short-circuit behavior.
  • Keep the reused metadata within that call; do not share it across requests.
  • Preserve the existing handling of missing records, database failures, and OPA failures.

Add focused tests that verify the metadata is read once, each evaluated privilege still reaches OPA, and short-circuiting and failure handling are preserved.

Additional context

  • OPA review, Nit1 raised these repeated metadata reads.
  • #2105 discussion covers caching permission answers when list items share parent checks. This issue covers reusing metadata for different privilege checks. The two changes can be implemented independently.

Activity

  1. added
    enhancement
    good first issue
    on Nov 3, 2026
  2. changed the title [-][Server] Reuse authorization decisions and metadata within a request[/-] [+][Server] Avoid reloading OPA metadata for each privilege check[/+] on Nov 4, 2026
  3. Orcus01 commented on Nov 4, 2026

    @Orcus01
    Contributor

    Hi, I'd like to contribute this improvement. I'd first trace the OPA authorizer and its tests, then propose reusing shared metadata within each authorizeAny/authorizeAll call while keeping separate OPA requests, evaluation order, short-circuiting, and existing failure behavior. I'd add focused tests for metadata read counts and those behavioral guarantees. Is anyone already working on this, and should the change wait for #2077 to merge?

  4. timothyw553 commented on Nov 4, 2026

    @timothyw553
    CollaboratorAuthor

    Thanks for offering to take this on, @Orcus01! We haven’t started working on it, so please go ahead. #2077 is already merged, so you can start from the latest main.

    Your proposed approach and tests match what we had in mind. Please keep the change focused on reusing metadata within each call using the existing classes.

  5. added a commit that references this issue on Nov 14, 2026
    f898fb0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions