Skip to content

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

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

dirkkul wants to merge 4 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 user_expires_at, and users.db.update_user_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 user_expires_at. users.db.rotate_key keeps it for the new key.

Setting an expiration against a server below 1.41 raises WeaviateUnsupportedFeatureError before any request goes out. Unless the server holds a Weaviate license key, it answers with 403. An expired user still reports active as True, so a caller compares user_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 Resolved
Comment thread weaviate/users/users.py Outdated
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.

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 your line to active as is. The docstrings of get and list_all also say that active stays True after the user expires, so a caller has to compare expires_at with the current time

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.

Active & expired may be confusing.

I think the reason for it being confusing is that the UserDB.expires_at implies that expiry is a property of a user, but it isn't.
A user is either active or inactive, and it's the API key that can expire.

I suggest renaming expires_at to api_key_expires_at, similarly to api_key_first_letters above. Maybe even prefix it everywhere, including when it's a parameter to create and in the method name, i.e. update_api_key_expiry

@dirkkul dirkkul left a comment

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.

reviewed with claude code, I went through every comment below myself

Comment thread weaviate/users/base.py Resolved
Comment thread weaviate/users/users.py Outdated
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)

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 your line to active as is. The docstrings of get and list_all also say that active stays True after the user expires, so a caller has to compare expires_at with the current time

Comment thread weaviate/users/users.py Outdated
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)

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.

Active & expired may be confusing.

I think the reason for it being confusing is that the UserDB.expires_at implies that expiry is a property of a user, but it isn't.
A user is either active or inactive, and it's the API key that can expire.

I suggest renaming expires_at to api_key_expires_at, similarly to api_key_first_letters above. Maybe even prefix it everywhere, including when it's a parameter to create and in the method name, i.e. update_api_key_expiry

Comment thread weaviate/users/base.py Outdated
status_codes=_ExpectedStatusCodes(ok_in=[201], error="Create user"),
)

def update_expiration(

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.

Suggested change
def update_expiration(
def update_expiry(

nit: I think "expiry" is more commonly used with API tokens, for example in oauth2 package

wdyt @databyjp?

@dirkkul dirkkul changed the title Add API key expiration for DB users on Weaviate 1.41+ Add expiration for DB users on Weaviate 1.41+ Nov 18, 2026

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.

5 participants