Merge pull request #8 from titilambert/improve_unlock
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Tobias Trabelsi 2023-01-19 18:33:59 +01:00 committed by GitHub
commit 67692b372f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import os
import json
import subprocess
class BitwardenCommandException(Exception):
@ -8,6 +9,11 @@ def get_secret_from_bitwarden(id):
return command_wrapper(command=f"get item {id}")
def unlock_bw(logger):
status_output = command_wrapper("status")
status = json.loads(status_output)['status']
if status == 'unlocked':
logger.info("Already unlocked")
return
token_output = command_wrapper("unlock --passwordenv BW_PASSWORD")
tokens = token_output.split('"')[1::2]
os.environ["BW_SESSION"] = tokens[1]