Unverified Commit d5d376f0 authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui Committed by GitHub

Merge pull request #37 from bilelmoussaoui/beta

Flatpak builds
parents a460e616 5060a71b
......@@ -8,6 +8,7 @@ tags
# C extensions
*.so
*.po~
test/
# Distribution / packaging
builddir/
......
......@@ -16,6 +16,7 @@
You ould have received a copy of the GNU General Public License
along with Authenticator. If not, see <http://www.gnu.org/licenses/>.
"""
from collections import OrderedDict
import sqlite3
from os import path, makedirs
......@@ -61,12 +62,12 @@ class Database:
try:
self.conn.execute(query, [name, secret, image])
self.conn.commit()
return {
"id": self.latest_id,
"name": name,
"secret_id": secret,
"image": image
}
return OrderedDict([
("id", self.latest_id),
("name", name),
("secret_id", secret),
("image", image)
])
except Exception as error:
Logger.error("[SQL] Couldn't add a new account")
Logger.error(str(error))
......@@ -139,11 +140,12 @@ class Database:
try:
data = self.conn.cursor().execute(query)
accounts = data.fetchall()
return [{"id": account[0],
"name": account[1],
"secret_id": account[2],
"logo": account[3]
} for account in accounts]
return [OrderedDict([
("id", account[0]),
("name", account[1]),
("secret_id", account[2]),
("logo", account[3])
]) for account in accounts]
except Exception as error:
Logger.error("[SQL] Couldn't fetch accounts list")
Logger.error(str(error))
......
......@@ -43,7 +43,7 @@ class Keyring:
def get_by_id(id_):
"""Return the secret code"""
schema = Keyring.get_default().schema
password = Secret.password_lookup_sync(schema, { "id": id_ }, None)
password = Secret.password_lookup_sync(schema, { "id": str(id_)}, None)
return password
@staticmethod
......@@ -55,7 +55,7 @@ class Keyring:
"""
schema = Keyring.get_default().schema
Secret.password_store_sync(schema, {
"id": id_,
"id": str(id_),
}, Secret.COLLECTION_DEFAULT, "", secret_code, None)
@staticmethod
......@@ -66,5 +66,5 @@ class Keyring:
:return: bool
"""
schema = Keyring.get_default().schema
removed = Secret.password_clear_sync(schema, { "id": id_ }, None)
removed = Secret.password_clear_sync(schema, { "id": str(id_)}, None)
return removed
\ No newline at end of file
......@@ -21,7 +21,7 @@ from os import remove, path
from urllib.parse import urlparse, parse_qsl
from PIL import Image
import zbarlight
from pyzbar.pyzbar import decode
from .code import Code
from .logger import Logger
......@@ -34,27 +34,17 @@ class QRReader:
self._codes = None
def read(self):
with open(self.filename, 'rb') as image_file:
image = Image.open(image_file)
image.load()
self._codes = zbarlight.scan_codes('qrcode', image)
self.remove()
self._codes = decode(Image.open(self.filename))
if path.isfile(self.filename):
remove(self.filename)
if self._codes:
otpauth_url = self._codes[0].decode()
otpauth_url = self._codes[0].data.decode()
self._codes = dict(parse_qsl(urlparse(otpauth_url)[4]))
return self._codes.get("secret")
else:
Logger.error("Invalid QR image")
return None
def remove(self):
"""
remove image file for security reasons
"""
if path.isfile(self.filename):
remove(self.filename)
Logger.debug("QR code image was removed for security reasons")
def is_valid(self):
"""
Validate if the QR code is a valid tfa
......
......@@ -173,7 +173,9 @@ class AccountsList(Gtk.Box):
file = Gio.File.new_for_uri(uri)
content = str(file.load_contents(None)[1].decode("utf-8"))
data = json.loads(content)
for name, logo in data.items():
data = sorted([(name, logo) for name, logo in data.items()], key=lambda entry: entry[0])
for entry in data:
name, logo = entry
self._listbox.add(AccountRow(name, logo))
......
......@@ -13,7 +13,7 @@ version](https://img.shields.io/badge/python-3.3%2B-blue.svg)
- `ninja`
- `pyotp`
- `Pillow`
- `zbarlight` depends on `zbar`
- `pyzbar` depends on `zbar`
- `libzbar-dev` on Ubuntu
- `zbar` on Arch
- `libsecret`
......
......@@ -10,23 +10,13 @@
/* Wayland */
"--socket=wayland",
/* Filesystem */
"--filesystem=host",
"--filesystem=~/.config/Authenticator:ro",
/* Keyring */
"--talk-name=org.freedesktop.secrets",
/* dconf */
"--filesystem=xdg-run/dconf", "--filesystem=~/.config/dconf:ro",
"--talk-name=ca.desrt.dconf", "--env=DCONF_USER_CONFIG_DIR=.config/dconf"
],
"cleanup": [
"/include",
"/lib/pkgconfig",
"/share/pkgconfig",
"/share/aclocal",
"/man",
"/share/man",
"/share/gtk-doc",
"/share/vala",
"*.la",
"*.a"
],
"build-options": {
"cflags": "-O2 -g",
"cxxflags": "-O2 -g",
......@@ -37,12 +27,10 @@
"modules": [{
"name": "zbar",
"config-opts": [
"--prefix=/app",
"--without-qt",
"--without-gtk",
"--without-imagemagick",
"--disable-video",
"CFLAGS=-DNDEBUG"
"--disable-video"
],
"sources": [{
"type": "archive",
......@@ -102,28 +90,15 @@
]
},
{
"name": "setuptools",
"name": "pyzbar",
"buildsystem": "simple",
"build-commands": [
"python3 bootstrap.py",
"python3 setup.py install --prefix=/app --root=/"
],
"sources": [{
"type": "archive",
"url": "https://github.com/pypa/setuptools/archive/38.2.5.tar.gz",
"sha256": "999acfc0f6eae7309b4a78118573e5948478cfda68061a5719cf9d475ddced0a"
}]
},
{
"name": "zbarlight",
"buildsystem": "simple",
"build-commands": [
"python3 setup.py install --prefix=/app --root=/"
],
"sources": [{
"type": "archive",
"url": "https://github.com/Polyconseil/zbarlight/archive/2.0.tar.gz",
"sha256": "92329b5496c7a86f2103f1ee15b1269dcff6011cb096948efafd349473b955a9"
"url": "https://github.com/NaturalHistoryMuseum/pyzbar/archive/v0.1.4.tar.gz",
"sha256": "7387899656e4e9564b7e507b2c26729c4863b7a79bbaf29c80c956a5654d2ee0"
}]
},
{
......@@ -139,8 +114,9 @@
"buildsystem": "meson",
"sources": [{
"type": "git",
"url": "https://github.com/bilelmoussaoui/Authenticator"
- }]
"url": "https://github.com/bilelmoussaoui/Authenticator",
"branch": "beta"
}]
}
]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment