Added commands to fill only username and password
This commit is contained in:
parent
aef61caf06
commit
752373bda1
|
@ -36,7 +36,9 @@ CMD_OP_GET_TOTP = "op get totp {uuid} --session={session_id}"
|
||||||
QUTE_FIFO = os.environ["QUTE_FIFO"]
|
QUTE_FIFO = os.environ["QUTE_FIFO"]
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("command", help="fill_credentials, fill_totp")
|
parser.add_argument(
|
||||||
|
"command", help="fill_credentials, fill_totp, fill_username, fill_password"
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--auto-submit", help="Auto submit after filling", action="store_true"
|
"--auto-submit", help="Auto submit after filling", action="store_true"
|
||||||
)
|
)
|
||||||
|
@ -82,6 +84,12 @@ class Qute:
|
||||||
if submit:
|
if submit:
|
||||||
cls.fake_key("<Return>")
|
cls.fake_key("<Return>")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def fill_single_field_tabmode(cls, value, submit=False):
|
||||||
|
cls.fake_key(value)
|
||||||
|
if submit:
|
||||||
|
cls.fake_key("<Return>")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def fill_totp(cls, totp, submit=True):
|
def fill_totp(cls, totp, submit=True):
|
||||||
cls.fake_key(totp)
|
cls.fake_key(totp)
|
||||||
|
@ -226,7 +234,7 @@ class OnePass:
|
||||||
)
|
)
|
||||||
Qute.message_warning("Filled incomplete credentials")
|
Qute.message_warning("Filled incomplete credentials")
|
||||||
|
|
||||||
return username, password
|
return {"username": username, "password": password}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_totp(cls, uuid):
|
def get_totp(cls, uuid):
|
||||||
|
@ -259,18 +267,39 @@ class CLI:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
return item
|
return item
|
||||||
|
|
||||||
def fill_credentials(self):
|
def _store_last_item(self, item):
|
||||||
item = self._get_item()
|
"""
|
||||||
username, password = OnePass.get_credentials(item)
|
Stores a reference to an item to easily get single information from it (password, TOTP)
|
||||||
Qute.fill_credentials_tabmode(
|
right after filling the username or credentials.
|
||||||
username, password, submit=self.arguments.auto_submit
|
"""
|
||||||
)
|
|
||||||
# Store a reference to this items in case we need a quick reference to the UUID
|
|
||||||
# to get the TOTP later
|
|
||||||
last_item = {"host": extract_host(os.environ["QUTE_URL"]), "uuid": item["uuid"]}
|
last_item = {"host": extract_host(os.environ["QUTE_URL"]), "uuid": item["uuid"]}
|
||||||
with open(LAST_ITEM_PATH, "w") as handler:
|
with open(LAST_ITEM_PATH, "w") as handler:
|
||||||
handler.write(json.dumps(last_item))
|
handler.write(json.dumps(last_item))
|
||||||
|
|
||||||
|
def _fill_single_field(self, field):
|
||||||
|
item = self._get_item()
|
||||||
|
credentials = OnePass.get_credentials(item)
|
||||||
|
Qute.fill_single_field_tabmode(
|
||||||
|
credentials[field], submit=self.arguments.auto_submit
|
||||||
|
)
|
||||||
|
return item
|
||||||
|
|
||||||
|
def fill_username(self):
|
||||||
|
item = self._fill_single_field("username")
|
||||||
|
self._store_last_item(item)
|
||||||
|
|
||||||
|
def fill_password(self):
|
||||||
|
item = self._fill_single_field("password")
|
||||||
|
self._store_last_item(item)
|
||||||
|
|
||||||
|
def fill_credentials(self):
|
||||||
|
item = self._get_item()
|
||||||
|
credentials = OnePass.get_credentials(item)
|
||||||
|
Qute.fill_credentials_tabmode(
|
||||||
|
*credentials.values(), submit=self.arguments.auto_submit
|
||||||
|
)
|
||||||
|
self._store_last_item(item)
|
||||||
|
|
||||||
def fill_totp(self):
|
def fill_totp(self):
|
||||||
# Check last item first
|
# Check last item first
|
||||||
# If theres a last_item file created in the last LAST_ITEM_DURATION seconds
|
# If theres a last_item file created in the last LAST_ITEM_DURATION seconds
|
||||||
|
|
Loading…
Reference in New Issue