Handle missing issuers (from Gnome Authenticator) and add refs to Gnome
This commit is contained in:
parent
54a2161004
commit
a9c95ce234
4 changed files with 12 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
||||||
# andotp2freeotp
|
# andotp2freeotp
|
||||||
|
|
||||||
Convert the JSON backup of unmaintained andOTP app to a format readable by FreeOTP.
|
Convert the JSON backup from Gnome Authenticator or the unmaintained andOTP app to a format readable by FreeOTP.
|
||||||
Current conversion to JSON format doesn't work since I have an math issue converting the andOTP secrets to FreeOTP ones.
|
Current conversion to JSON format doesn't work since I have an math issue converting the secrets to FreeOTP ones.
|
||||||
See https://github.com/freeotp/freeotp-android/issues/368 and give me a hand with my math skills.
|
See https://github.com/freeotp/freeotp-android/issues/368 and give me a hand with my math skills.
|
||||||
But URI format works as a charm.
|
But URI format works as a charm.
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ sudo python3 setup.py install
|
||||||
andotp2freeotp.py [--debug-level|-d CRITICAL|ERROR|WARNING|INFO|DEBUG|NOTSET] # Other parameters
|
andotp2freeotp.py [--debug-level|-d CRITICAL|ERROR|WARNING|INFO|DEBUG|NOTSET] # Other parameters
|
||||||
|
|
||||||
-l, --log-file TEXT File to store all debug messages.
|
-l, --log-file TEXT File to store all debug messages.
|
||||||
-i, --input TEXT JSON file from andOTP to convert [required]
|
-i, --input TEXT JSON file from andOTP or Gnome Authenticator to convert [required]
|
||||||
-o, --output TEXT JSON/URI file to write for FreeOTP [required]
|
-o, --output TEXT JSON/URI file to write for FreeOTP [required]
|
||||||
-f, --format [uris|json] Format for the output. Either URIs or JSON. JSON doesn't work right now, pending on minor issue with conversion of secrets. See https://github.com/freeotp/freeotp-android/issues/368 and help me.
|
-f, --format [uris|json] Format for the output. Either URIs or JSON. JSON doesn't work right now, pending on minor issue with conversion of secrets. See https://github.com/freeotp/freeotp-android/issues/368 and help me.
|
||||||
--config FILE Read configuration from FILE.
|
--config FILE Read configuration from FILE.
|
||||||
|
|
|
@ -98,7 +98,10 @@ https://github.com/freeotp/freeotp-android/issues/368"""
|
||||||
self.uris = []
|
self.uris = []
|
||||||
for item in self.data:
|
for item in self.data:
|
||||||
uri_type = item['type'].lower()
|
uri_type = item['type'].lower()
|
||||||
label = quote(f"{item['label']}@{item['issuer']}")
|
issuer = item.get('issuer', '')
|
||||||
|
if issuer == '' and 'tags' in item and len(item['tags']) > 0:
|
||||||
|
issuer = item['tags'][0]
|
||||||
|
label = quote(f"{item['label']}@{issuer}")
|
||||||
uri = f"otpauth://{uri_type}/{label}?secret={item['secret']}"
|
uri = f"otpauth://{uri_type}/{label}?secret={item['secret']}"
|
||||||
other_fields = [
|
other_fields = [
|
||||||
'algorithm', 'digits', 'period', 'issuer', 'counter'
|
'algorithm', 'digits', 'period', 'issuer', 'counter'
|
||||||
|
@ -172,7 +175,8 @@ https://github.com/freeotp/freeotp-android/issues/368"""
|
||||||
# @click.option("--dummy","-n", is_flag=True,
|
# @click.option("--dummy","-n", is_flag=True,
|
||||||
# help="Don't do anything, just show what would be done.")
|
# help="Don't do anything, just show what would be done.")
|
||||||
@click.option(
|
@click.option(
|
||||||
'--input', '-i', required=True, help='JSON file from andOTP to convert'
|
'--input', '-i', required=True,
|
||||||
|
help='JSON file from andOTP or Gnome Authenticator to convert'
|
||||||
)
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
'--output', '-o', required=True, help='JSON/URI file to write for FreeOTP'
|
'--output', '-o', required=True, help='JSON/URI file to write for FreeOTP'
|
||||||
|
|
|
@ -7,7 +7,7 @@ Homepage = ""
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "andotp2freeotp"
|
name = "andotp2freeotp"
|
||||||
version = "0.0.1"
|
version = "0.0.2"
|
||||||
description = "Convert andOTP json backups to FreeOTP format"
|
description = "Convert andOTP json backups to FreeOTP format"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = [{ name = "Antonio J. Delgado", email = "" }]
|
authors = [{ name = "Antonio J. Delgado", email = "" }]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[metadata]
|
[metadata]
|
||||||
name = andotp2freeotp
|
name = andotp2freeotp
|
||||||
version = 0.0.1
|
version = 0.0.2
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
packages = andotp2freeotp
|
packages = andotp2freeotp
|
||||||
|
|
Loading…
Reference in a new issue