Skip to content

Add API key expiration for DB users on Weaviate 1.41+ - #2249

Open
dirkkul wants to merge 2 commits into
dev/1.41from
user_ttl
Open

dirkkul wants to merge 2 commits into
dev/1.41from
user_ttl

Conversation

@dirkkul

@dirkkul dirkkul commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

DB users can now have an API key that expires. users.db.create takes an optional expires_at, and users.db.update_expiration changes it or, given None, makes the key never expire. users.db.get, users.db.list_all and users.get_my_user return it as expires_at.

Unless the server holds a Weaviate license key, it answers such a request with 403. An expired user still reports active as True, so a caller compares expires_at with the current time.

@dirkkul
dirkkul requested a review from a team as a code owner November 11, 2026 05:49
Copilot AI balanced review requested due to automatic review settings November 11, 2026 05:49

@orca-security-eu orca-security-eu Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

Copilot AI 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.

🟢 Approval recommended

The API key expiration changes have no active review issues.

No open issues 🎉

What changed in this PR

Adds API key expiration management to the Python client’s DB user APIs for licensed Weaviate 1.41+ servers.

Changes:

  • Supports expiration during user creation and setting or removing expiration for existing users.
  • Exposes expiration timestamps in user responses and updates synchronous and asynchronous type signatures.
  • Adds integration coverage and configures CI to test against Weaviate 1.41 with optional license credentials.
File Description
weaviate/​util.py Adds the Weaviate 1.41 version guard.
weaviate/​users/​users.py Adds expiration fields to user models.
weaviate/​users/​sync.pyi Updates synchronous API signatures for expiration support.
weaviate/​users/​base.py Implements expiration requests, response parsing, and related documentation.
weaviate/​users/​async_.pyi Updates asynchronous API signatures for expiration support.
weaviate/​rbac/​models.py Types the expiration field in DB user responses.
integration/​test_users.py Tests expiration management, key rotation, and unsupported versions.
ci/​docker-compose-rbac.yml Passes the optional license key to the RBAC server.
.github/​workflows/​main.yaml Adds Weaviate 1.41 to integration testing and supplies license credentials.

Review effort: Balanced

@codecov-commenter

codecov-commenter commented Nov 11, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 39.65517% with 70 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (dev/1.41@b0e8297). Learn more about missing BASE report.

Files with missing lines Patch % Lines
integration/test_users.py 30.10% 65 Missing ⚠️
weaviate/users/base.py 75.00% 5 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff             @@
##             dev/1.41    #2249   +/-   ##
===========================================
  Coverage            ?   92.19%           
===========================================
  Files               ?      311           
  Lines               ?    23738           
  Branches            ?        0           
===========================================
  Hits                ?    21886           
  Misses              ?     1852           
  Partials            ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dirkkul
dirkkul changed the base branch from main to dev/1.41 November 17, 2026 12:40

@orca-security-eu orca-security-eu Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca

Comment thread weaviate/users/base.py

Args:
user_id: The id of the new user.
expires_at: The time at which the user's API key stops authenticating, which must be in the future. Weaviate stores it in UTC to the millisecond. If None, the key never expires. Requires Weaviate 1.41+ and a Weaviate license key on the server.

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.

The "expires_at" essentially relates to the user as it carries over when the key rotates. So I wonder if we should phrase all the docstrings around the db user: e.g.:

expires_at: The future time at which the db user can no longer authenticate. Weaviate stores it in UTC to the millisecond. If None, the key never expires...

Comment thread weaviate/users/users.py
created_at: Optional[datetime] = field(default=None)
last_used_time: Optional[datetime] = field(default=None)
api_key_first_letters: Optional[str] = field(default=None)
expires_at: Optional[datetime] = field(default=None)

@databyjp databyjp Nov 17, 2026 •

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.

Active & expired may be confusing. Wdyt about adding a comment to active: bool? Like:

# Administratively enabled; expiration does not change this value.

This branch has not been deployed

No deployments
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