Returns the crypt key :return: the key
()
| 23 | |
| 24 | |
| 25 | def get_crypt_key(): |
| 26 | """ |
| 27 | Returns the crypt key |
| 28 | :return: the key |
| 29 | """ |
| 30 | enc_key = current_app.keyManager.get() |
| 31 | if enc_key is None: |
| 32 | if config.SERVER_MODE: |
| 33 | if config.MASTER_PASSWORD_REQUIRED: |
| 34 | return False, None |
| 35 | # Use the session key if available |
| 36 | if 'pass_enc_key' in session: |
| 37 | return True, session['pass_enc_key'] |
| 38 | |
| 39 | else: |
| 40 | # if desktop mode and master pass and |
| 41 | # local os secret is disabled then use the password hash |
| 42 | if not config.MASTER_PASSWORD_REQUIRED and\ |
| 43 | not config.USE_OS_SECRET_STORAGE: |
| 44 | return True, current_user.password |
| 45 | |
| 46 | # If master pass or local os secret enabled but enc_key is still None |
| 47 | # or pass_enc_key not in session |
| 48 | return False, None |
| 49 | |
| 50 | # If enc_key is available, return True with the enc_key |
| 51 | return True, enc_key |
| 52 | |
| 53 | |
| 54 | def get_master_password_key_from_os_secret(): |
no test coverage detected