简体   繁体   中英

pyinstaller: include keyring module?

i wrote a small python app to automatically login a user to specific service using the keyring module (for storing the password in the windows credential vault) and wxpython for a login gui. The login tool for this service doesnt support the storage of login credentials but has a cmd login method i am using in my script.

The script is now finished and works perfectly but i would like to deploy this as exe to several other systems.

Keyring doesnt seem to play nice with pyinstaller but i got my program to start atleast after adding a huge list of hidden imports:

'json', 
'json.decoder', 
'json.encoder', 
'json.scanner',
'keyring.backends.file',
'keyring.backends.Gnome',
'keyring.backends.Google',
'keyring.backends.keyczar',
'keyring.backends.kwallet',
'keyring.backends.multi',
'keyring.backends.OS_X',
'keyring.backends.pyfs',
'keyring.backends.SecretService',
'keyring.backends.Windows',
'keyring.backends._win_crypto',
'keyring.util.escape',
'keyring.util.XDG',
'keyring.credentials'

With those the app starts without any errors of missing modules but it still crashes when it tries to access the credential vault:

c:\PY\novell_login>dist\thread_test\thread_test.exe
Logging in User: test
Traceback (most recent call last):
  File "c:\PY\build\thread_test\out00-PYZ.pyz\wx._core", line 16766, in <lambda>
  File "<string>", line 119, in LongTaskDone
  File "c:\PY\build\thread_test\out00-PYZ.pyz\keyring.core", line 44, in set_password
  File "c:\PY\build\thread_test\out00-PYZ.pyz\keyring.backends.file", line 87, in set_password
  File "c:\PY\build\thread_test\out00-PYZ.pyz\keyring.backends.Windows", line 81, in encrypt
NameError: global name '_win_crypto' is not defined

I dont know what else to do to fix this... Can anyone help me to properly include keyring or knows an alternative i could use. I would really like to keep using the windows crendential vault for storing the password.

Thanks!

Python: 2.7.9 pyinstaller: 2.1 keyring: 5.6 pywin: Build 219

After a week of no success even after posting here and on the pyinstaller github i made my own solution. I ditched the keyring module and used win32crypt module to use the windows function CryptProtectData which after some research uses the same protection as keyring.

I hash the password into a string stored in the user appdata folder and decrypt it when needed. This works great and should be as secure as the keyring method because its only decryptable from the same user, resetting the password to get access wont work aswell. Secure enough for me.

And of course this works with pyinstaller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM