Repository navigation
Conversation
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
There was a problem hiding this comment.
🟢 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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Secrets | View in Orca |
| 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) |
There was a problem hiding this comment.
Active & expired may be confusing. Wdyt about adding a comment to active: bool? Like:
# Administratively enabled; expiration does not change this value.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
reviewed with claude code, I went through every comment below myself
| 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) |
There was a problem hiding this comment.
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
| 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) |
There was a problem hiding this comment.
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
| status_codes=_ExpectedStatusCodes(ok_in=[201], error="Create user"), | ||
| ) | ||
|
|
||
| def update_expiration( |
There was a problem hiding this comment.
| def update_expiration( | |
| def update_expiry( |
nit: I think "expiry" is more commonly used with API tokens, for example in oauth2 package
wdyt @databyjp?
DB users can now have an API key that expires.
users.db.createtakes an optionaluser_expires_at, andusers.db.update_user_expirationchanges it or, givenNone, makes the key never expire.users.db.get,users.db.list_allandusers.get_my_userreturn it asuser_expires_at.users.db.rotate_keykeeps it for the new key.Setting an expiration against a server below 1.41 raises
WeaviateUnsupportedFeatureErrorbefore any request goes out. Unless the server holds a Weaviate license key, it answers with 403. An expired user still reportsactiveas True, so a caller comparesuser_expires_atwith the current time.