Skip to content

Commit 3eaf946

Browse files
LowaizLujeni
authored andcommitted
fix(api-fields): fix api fields for vaultwarden v1.33.x
1 parent 51b3536 commit 3eaf946

6 files changed

Lines changed: 25 additions & 12 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
python-version: [ '3.10', '3.11', '3.12' ]
16+
python-version: [ '3.10', '3.11', '3.12', '3.13' ]
1717
os: [ ubuntu-latest ]
18-
vaultwarden-version: [ '1.30.5', '1.31.0' , '1.32.0']
18+
vaultwarden-version: [ '1.30.5', '1.31.0' , '1.32.7', '1.33.2' ]
1919
runs-on: ${{ matrix.os }}
2020
steps:
2121
- uses: actions/checkout@v3
@@ -54,7 +54,7 @@ jobs:
5454
- name: Setup Python
5555
uses: actions/setup-python@v4
5656
with:
57-
python-version: '3.12'
57+
python-version: '3.13'
5858
- name: Install Python dependencies
5959
run: |
6060
python -m pip install --upgrade hatch

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ test = "coverage run --source=src/vaultwarden -m unittest discover -p 'test_*.py
7373
_coverage = ["test", "coverage xml", "coverage report --show-missing"]
7474
with-coverage = "test"
7575
[[tool.hatch.envs.test.matrix]]
76-
python = ["3.10", "3.11", "3.12"]
76+
python = ["3.10", "3.11", "3.12", "3.13"]
7777
type = ["default"]
7878
[tool.hatch.envs.test.overrides]
7979
matrix.type.scripts = [

src/vaultwarden/clients/vaultwarden.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def invite(self, email: str) -> bool:
144144
self._load_users()
145145
return res
146146

147-
def delete(self, identifier: str) -> bool:
147+
def delete(self, identifier: str | UUID) -> bool:
148148
logger.info(f"Deleting {identifier} account")
149149
res = True
150150
try:

src/vaultwarden/models/bitwarden.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def update_collection(self, collections: list[UUID]):
9191
class CollectionAccess(BitwardenBaseModel):
9292
ReadOnly: bool = False
9393
HidePasswords: bool = False
94+
Manage: bool = False
9495

9596

9697
class CollectionUser(CollectionAccess):
@@ -154,24 +155,26 @@ def set_users(
154155
users: list[CollectionUser] | list[UUID],
155156
default_readonly: bool = False,
156157
default_hide_passwords: bool = False,
158+
default_manage: bool = False,
157159
):
158160
users_payload = []
159161
if users is not None and len(users) > 0:
160162
if isinstance(users[0], CollectionUser):
161-
users = cast(list[CollectionUser], users)
163+
users = cast("list[CollectionUser]", users)
162164
users_payload = [
163165
user.model_dump(
164166
exclude={"CollectionId"}, by_alias=True, mode="json"
165167
)
166168
for user in users
167169
]
168170
else:
169-
users = cast(list[UUID], users)
171+
users = cast("list[UUID]", users)
170172
users_payload = [
171173
{
172174
"id": str(user_id),
173175
"readOnly": default_readonly,
174176
"hidePasswords": default_hide_passwords,
177+
"manage": default_manage,
175178
}
176179
for user_id in users
177180
]
@@ -203,6 +206,7 @@ class OrganizationUserDetails(BitwardenBaseModel):
203206
Collections: list[UserCollection]
204207
Groups: list | None = None
205208
TwoFactorEnabled: bool
209+
Permissions: dict | None = None
206210

207211
@field_validator("OrganizationId")
208212
@classmethod
@@ -221,6 +225,7 @@ def add_collections(self, collections: list[UUID]):
221225
UserId=self.Id,
222226
ReadOnly=False,
223227
HidePasswords=False,
228+
Manage=False,
224229
)
225230
user.bitwarden_client = self.api_client
226231
self.Collections.append(user)
@@ -231,6 +236,7 @@ def add_collections(self, collections: list[UUID]):
231236
"CollectionId": True,
232237
"ReadOnly": True,
233238
"HidePasswords": True,
239+
"Manage": True,
234240
}
235241
},
236242
"Groups": True,
@@ -348,14 +354,18 @@ def invite(
348354
) = None,
349355
access_all: bool = False,
350356
user_type: OrganizationUserType = OrganizationUserType.User,
357+
permissions=None,
351358
default_readonly: bool = False,
352359
default_hide_passwords: bool = False,
360+
default_manage: bool = False,
353361
):
362+
if permissions is None:
363+
permissions = {}
354364
collections_payload = []
355365
if collections is not None and len(collections) > 0:
356366
for coll in collections:
357367
if isinstance(coll, UserCollection):
358-
coll = cast(UserCollection, coll)
368+
coll = cast("UserCollection", coll)
359369
ex: dict[str, Literal[True]] = {"UserId": True}
360370
collections_payload.append(
361371
coll.model_dump(
@@ -366,18 +376,19 @@ def invite(
366376
)
367377
else:
368378
if isinstance(coll, OrganizationCollection):
369-
coll = cast(OrganizationCollection, coll)
379+
coll = cast("OrganizationCollection", coll)
370380
coll_id = str(coll.Id)
371381
elif isinstance(coll, UUID):
372-
coll = cast(UUID, coll)
382+
coll = cast("UUID", coll)
373383
coll_id = str(coll)
374384
else:
375-
coll_id = cast(str, coll)
385+
coll_id = cast("str", coll)
376386
collections_payload.append(
377387
{
378388
"id": coll_id,
379389
"readOnly": default_readonly,
380390
"hidePasswords": default_hide_passwords,
391+
"manage": default_manage,
381392
}
382393
)
383394

@@ -387,6 +398,7 @@ def invite(
387398
"type": user_type,
388399
"collections": collections_payload,
389400
"groups": [],
401+
"permissions": permissions,
390402
}
391403
resp = self.api_client.api_request(
392404
"POST", f"api/organizations/{self.Id}/users/invite", json=payload

src/vaultwarden/models/enum.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class OrganizationUserType(IntEnum):
1313
Admin = 1
1414
User = 2
1515
Manager = 3
16+
Custom = 4
1617

1718

1819
class CipherType(IntEnum):

tests/e2e/run_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
if [[ -z "${VAULTWARDEN_VERSION}" ]]; then
4-
VAULTWARDEN_VERSION="1.32.0"
4+
VAULTWARDEN_VERSION="1.33.2"
55
fi
66

77
temp_dir=$(mktemp -d)

0 commit comments

Comments
 (0)