corpusops / bitwardentools

bitwarden python api client and additional tools like for migrating from vaultier to bitwarden (bitwarden_rs)
Other
38 stars 15 forks source link

Organizations not found after Vaultwarden upgrade #31

Open karlism opened 2 months ago

karlism commented 2 months ago

Hello,

We've upgraded our Vaultwarden server from 1.30.5 to 1.31.0 and some of our python scripts that rely on bitwardentools stopped working. Further investigation showed that it cannot fetch organizations from Vaultwarden anymore.

Steps to reproduce: 1) create new Vaultwarden instance 2) create new user and organization "test" 3) try to fetch organizations with bitwardentools by running client.get_organizations() and it will fail.

Example script:

#!/usr/bin/env python3

from bitwardentools import Client

from pprint import pprint

client = Client('https://bitwarden.example.com', 'username@example.com', 'password')

client.sync()
organizations = client.get_organizations()
pprint(organizations)

org = client.get_organization('test')
pprint(vars(org))

Vaultwarden 1.30.5:

$ /tmp/bitwardentools_org.py 
{'externalId': OrderedDict(),
 'id': {'ffbc564f-18f1-4f26-a1a2-cf021f3901cb': <bitwardentools.client.Organization object at 0x6827b8738d0>},
 'name': {'test': OrderedDict([('ffbc564f-18f1-4f26-a1a2-cf021f3901cb',
                                 <bitwardentools.client.Organization object at 0x6827b8738d0>)])},
 'sync': True,
 'vaultiersecretid': OrderedDict()}
{'_client': <bitwardentools.client.Client object at 0x6827b2c4f10>,
 '_complete': False,
 'broken_objs': OrderedDict(),
 'enabled': True,
 'hasPublicAndPrivateKeys': True,
 'id': 'ffbc564f-18f1-4f26-a1a2-cf021f3901cb',
 'identifier': None,
 'json': {'enabled': True,
          'hasPublicAndPrivateKeys': True,
          'id': 'ffbc564f-18f1-4f26-a1a2-cf021f3901cb',
          'identifier': None,
          'key': '4.GKxLgtXqrvG2k1elOb74V9Jr2QGZGPE1JImeZEyFn9pwbSklaWbtIXMcddq2dhxk0sYiQV+yd610Hcy7pMmu8rr5yoUyVQ6wVqiU1a1EYCZbGFLzjYnZT1Kugd5ezjYi6UfRwF32gKs3e0Iipoi2HIXF4EbSjonGEAeVooki2Emx25PysC391M1nZr4/Y4tbaWDfoc06VyAIgTgK7lNpH7XYWNWJ4IQU4ao3qmFNtJqu17OHMhbn8e+08X45omH8KcYDsiezLc3G+T7/pfAexGOSsWEkRG05WPxB9bSDcJstAq5esu2ugFSexJ7BTibHUUKf4mEp7Qhb23b5nFerXw==',
          'maxCollections': 10,
          'maxStorageGb': 10,
          'name': 'test',
          'object': 'organization',
          'providerId': None,
          'providerName': None,
          'resetPasswordEnrolled': False,
          'seats': 10,
          'selfHost': True,
          'ssoBound': False,
          'status': 2,
          'type': 0,
          'use2fa': True,
          'useApi': True,
          'useDirectory': False,
          'useEvents': True,
          'useGroups': False,
          'usePolicies': True,
          'useResetPassword': True,
          'useSso': False,
          'useTotp': True,
          'userId': '2fc62d7b-9fae-4d3b-9afd-1f359e0c048b',
          'usersGetPremium': True},
 'key': '4.GKxLgtXqrvG2k1elOb74V9Jr2QGZGPE1JImeZEyFn9pwbSklaWbtIXMcddq2dhxk0sYiQV+yd610Hcy7pMmu8rr5yoUyVQ6wVqiU1a1EYCZbGFLzjYnZT1Kugd5ezjYi6UfRwF32gKs3e0Iipoi2HIXF4EbSjonGEAeVooki2Emx25PysC391M1nZr4/Y4tbaWDfoc06VyAIgTgK7lNpH7XYWNWJ4IQU4ao3qmFNtJqu17OHMhbn8e+08X45omH8KcYDsiezLc3G+T7/pfAexGOSsWEkRG05WPxB9bSDcJstAq5esu2ugFSexJ7BTibHUUKf4mEp7Qhb23b5nFerXw==',
 'maxCollections': 10,
 'maxStorageGb': 10,
 'name': 'test',
 'object': 'organization',
 'providerId': None,
 'providerName': None,
 'resetPasswordEnrolled': False,
 'seats': 10,
 'selfHost': True,
 'ssoBound': False,
 'status': 2,
 'type': 0,
 'use2fa': True,
 'useApi': True,
 'useDirectory': False,
 'useEvents': True,
 'useGroups': False,
 'usePolicies': True,
 'useResetPassword': True,
 'useSso': False,
 'useTotp': True,
 'userId': '2fc62d7b-9fae-4d3b-9afd-1f359e0c048b',
 'usersGetPremium': True,
 'vaultier': None,
 'vaultiersecretid': None}

Vaultwarden 1.31.0:

$ /tmp/bitwardentools_org.py
{'id': {}, 'name': {}, 'sync': True}
Traceback (most recent call last):
  File "/tmp/bitwardentools_org.py", line 13, in <module>
    org = client.get_organization('test')
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/.local/lib/python3.11/site-packages/bitwardentools/client.py", line 1056, in get_organization
    raise exc
bitwardentools.client.OrganizationNotFound: No such organization found test
$ python3 --version
Python 3.11.9
$ pip list | grep bitwardentools
bitwardentools                1.0.57

We also tried upgrading to the latest Vaultwarden version 1.32.0, but this issue persists.

karlism commented 2 months ago

Possibly related to this issue: https://github.com/dani-garcia/vaultwarden/issues/4818

commonism commented 2 months ago

100% - may look into https://github.com/corpusops/bitwardentools/issues/32 as well

maciej-rek commented 2 months ago

Hello @karlism, I've the same problem with getting organizations. Maybe did you resolved that?

commonism commented 2 months ago

https://github.com/corpusops/bitwardentools/pull/29