Merge pull request #29 from Weidows/master
fix encoding and add session param
This commit is contained in:
commit
00860658a6
|
@ -28,3 +28,4 @@ Fetches SSH keys stored in Bitwarden vault and adds them to `ssh-agent`.
|
||||||
* `--foldername`/`-f` - Folder name to use to search for SSH keys _(default: ssh-agent)_
|
* `--foldername`/`-f` - Folder name to use to search for SSH keys _(default: ssh-agent)_
|
||||||
* `--customfield`/`-c` - Custom field name where private key filename is stored _(default: private)_
|
* `--customfield`/`-c` - Custom field name where private key filename is stored _(default: private)_
|
||||||
* `--passphrasefield`/`-p` - Custom field name where passphrase for the key is stored _(default: passphrase)_
|
* `--passphrasefield`/`-p` - Custom field name where passphrase for the key is stored _(default: passphrase)_
|
||||||
|
* `--session`/`-s` - session key of bitwarden
|
||||||
|
|
|
@ -56,11 +56,12 @@ def cli_supports(feature: str) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_session() -> str:
|
def get_session(session: str) -> str:
|
||||||
"""
|
"""
|
||||||
Function to return a valid Bitwarden session
|
Function to return a valid Bitwarden session
|
||||||
"""
|
"""
|
||||||
# Check for an existing, user-supplied Bitwarden session
|
# Check for an existing, user-supplied Bitwarden session
|
||||||
|
if not session:
|
||||||
session = os.environ.get('BW_SESSION', '')
|
session = os.environ.get('BW_SESSION', '')
|
||||||
if session:
|
if session:
|
||||||
logging.debug('Existing Bitwarden session found')
|
logging.debug('Existing Bitwarden session found')
|
||||||
|
@ -101,6 +102,7 @@ def get_folders(session: str, foldername: str) -> str:
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
universal_newlines=True,
|
universal_newlines=True,
|
||||||
check=True,
|
check=True,
|
||||||
|
encoding = "utf-8",
|
||||||
)
|
)
|
||||||
|
|
||||||
folders = json.loads(proc_folders.stdout)
|
folders = json.loads(proc_folders.stdout)
|
||||||
|
@ -128,6 +130,7 @@ def folder_items(session: str, folder_id: str) -> List[Dict[str, Any]]:
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
universal_newlines=True,
|
universal_newlines=True,
|
||||||
check=True,
|
check=True,
|
||||||
|
encoding = "utf-8",
|
||||||
)
|
)
|
||||||
|
|
||||||
data: List[Dict[str, Any]] = json.loads(proc_items.stdout)
|
data: List[Dict[str, Any]] = json.loads(proc_items.stdout)
|
||||||
|
@ -270,6 +273,12 @@ if __name__ == '__main__':
|
||||||
default='passphrase',
|
default='passphrase',
|
||||||
help='custom field name where key passphrase is stored',
|
help='custom field name where key passphrase is stored',
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'-s',
|
||||||
|
'--session',
|
||||||
|
default='',
|
||||||
|
help='session key of bitwarden',
|
||||||
|
)
|
||||||
|
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
@ -289,7 +298,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logging.info('Getting Bitwarden session')
|
logging.info('Getting Bitwarden session')
|
||||||
session = get_session()
|
session = get_session(args.session)
|
||||||
logging.debug('Session = %s', session)
|
logging.debug('Session = %s', session)
|
||||||
|
|
||||||
logging.info('Getting folder list')
|
logging.info('Getting folder list')
|
||||||
|
|
Loading…
Reference in a new issue