Fix unencrypted delivery and key removal #130
4 changed files with 14 additions and 15 deletions
|
@ -2,21 +2,21 @@
|
||||||
|
|
||||||
This definition includes:
|
This definition includes:
|
||||||
|
|
||||||
- 'gpgmw_keys' -- temporary key storage, used by the frontend to submit keys and
|
- 'lacre_keys' -- temporary key storage, used by the frontend to submit keys and
|
||||||
by webgate-cron script to import submitted keys.
|
by webgate-cron script to import submitted keys.
|
||||||
|
|
||||||
- 'gpgmw_identities' -- identity catalogue, used by encryption logic to match
|
- 'lacre_identities' -- identity catalogue, used by encryption logic to match
|
||||||
emails with corresponding keys.
|
emails with corresponding keys.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
# Values for gpgmw_keys.status column:
|
# Values for lacre_keys.status column:
|
||||||
ST_DEFAULT, ST_IMPORTED, ST_TO_BE_DELETED = range(3)
|
ST_DEFAULT, ST_IMPORTED, ST_TO_BE_DELETED = range(3)
|
||||||
|
|
||||||
_meta = sqlalchemy.MetaData()
|
_meta = sqlalchemy.MetaData()
|
||||||
|
|
||||||
GPGMW_KEYS = sqlalchemy.Table('gpgmw_keys', _meta,
|
LACRE_KEYS = sqlalchemy.Table('lacre_keys', _meta,
|
||||||
sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True),
|
sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True),
|
||||||
sqlalchemy.Column('email', sqlalchemy.String(256)),
|
sqlalchemy.Column('email', sqlalchemy.String(256)),
|
||||||
# ASCII-armored key
|
# ASCII-armored key
|
||||||
|
@ -26,13 +26,13 @@ GPGMW_KEYS = sqlalchemy.Table('gpgmw_keys', _meta,
|
||||||
sqlalchemy.Column('status', sqlalchemy.Integer),
|
sqlalchemy.Column('status', sqlalchemy.Integer),
|
||||||
sqlalchemy.Column('time', sqlalchemy.DateTime))
|
sqlalchemy.Column('time', sqlalchemy.DateTime))
|
||||||
|
|
||||||
GPGMW_IDENTITIES = sqlalchemy.Table('gpgmw_identities', _meta,
|
LACRE_IDENTITIES = sqlalchemy.Table('lacre_identities', _meta,
|
||||||
sqlalchemy.Column('email', sqlalchemy.String(256), index=True),
|
sqlalchemy.Column('email', sqlalchemy.String(256), index=True),
|
||||||
# Key fingerprint
|
# Key fingerprint
|
||||||
sqlalchemy.Column('fingerprint', sqlalchemy.String(64), index=True))
|
sqlalchemy.Column('fingerprint', sqlalchemy.String(64), index=True))
|
||||||
|
|
||||||
def init_identities_table() -> sqlalchemy.Table:
|
def init_identities_table() -> sqlalchemy.Table:
|
||||||
return GPGMW_IDENTITIES
|
return LACRE_IDENTITIES
|
||||||
|
|
||||||
def table_metadata():
|
def table_metadata():
|
||||||
return _meta
|
return _meta
|
||||||
|
|
|
@ -6,7 +6,6 @@ module.
|
||||||
|
|
||||||
import lacre.config as conf
|
import lacre.config as conf
|
||||||
from lacre._keyringcommon import KeyRing, KeyCache
|
from lacre._keyringcommon import KeyRing, KeyCache
|
||||||
from lacre.dbschema import GPGMW_IDENTITIES
|
|
||||||
from lacre.repositories import IdentityRepository
|
from lacre.repositories import IdentityRepository
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ def connect(url):
|
||||||
|
|
||||||
class IdentityRepository(KeyRing):
|
class IdentityRepository(KeyRing):
|
||||||
def __init__(self, /, connection=None, db_url=None):
|
def __init__(self, /, connection=None, db_url=None):
|
||||||
self._identities = db.GPGMW_IDENTITIES
|
self._identities = db.LACRE_IDENTITIES
|
||||||
self._conn = connection
|
self._conn = connection
|
||||||
self._url = db_url
|
self._url = db_url
|
||||||
self._initialised = connection is not None
|
self._initialised = connection is not None
|
||||||
|
@ -88,13 +88,13 @@ class IdentityRepository(KeyRing):
|
||||||
|
|
||||||
|
|
||||||
class KeyConfirmationQueue:
|
class KeyConfirmationQueue:
|
||||||
"""Encapsulates access to gpgmw_keys table."""
|
"""Encapsulates access to lacre_keys table."""
|
||||||
|
|
||||||
# Default number of items retrieved from the database.
|
# Default number of items retrieved from the database.
|
||||||
keys_read_max = 100
|
keys_read_max = 100
|
||||||
|
|
||||||
def __init__(self, connection):
|
def __init__(self, connection):
|
||||||
self._keys = db.GPGMW_KEYS
|
self._keys = db.LACRE_KEYS
|
||||||
self._conn = connection
|
self._conn = connection
|
||||||
|
|
||||||
def fetch_keys(self, /, max_keys=None):
|
def fetch_keys(self, /, max_keys=None):
|
||||||
|
|
|
@ -5,7 +5,7 @@ from sqlalchemy.sql import insert
|
||||||
def define_db_schema():
|
def define_db_schema():
|
||||||
meta = sqlalchemy.MetaData()
|
meta = sqlalchemy.MetaData()
|
||||||
|
|
||||||
gpgmw_keys = sqlalchemy.Table('gpgmw_keys', meta,
|
lacre_keys = sqlalchemy.Table('lacre_keys', meta,
|
||||||
sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True),
|
sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True),
|
||||||
sqlalchemy.Column('email', sqlalchemy.String(256)),
|
sqlalchemy.Column('email', sqlalchemy.String(256)),
|
||||||
sqlalchemy.Column('publickey', sqlalchemy.Text),
|
sqlalchemy.Column('publickey', sqlalchemy.Text),
|
||||||
|
@ -13,17 +13,17 @@ def define_db_schema():
|
||||||
sqlalchemy.Column('status', sqlalchemy.Integer),
|
sqlalchemy.Column('status', sqlalchemy.Integer),
|
||||||
sqlalchemy.Column('time', sqlalchemy.DateTime))
|
sqlalchemy.Column('time', sqlalchemy.DateTime))
|
||||||
|
|
||||||
identities = sqlalchemy.Table('gpgmw_identities', meta,
|
identities = sqlalchemy.Table('lacre_identities', meta,
|
||||||
sqlalchemy.Column('email', sqlalchemy.String(256), index=True),
|
sqlalchemy.Column('email', sqlalchemy.String(256), index=True),
|
||||||
sqlalchemy.Column('fingerprint', sqlalchemy.String(64), index=True))
|
sqlalchemy.Column('fingerprint', sqlalchemy.String(64), index=True))
|
||||||
|
|
||||||
return (meta, gpgmw_keys, identities)
|
return (meta, lacre_keys, identities)
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
print("ERROR: output database missing")
|
print("ERROR: output database missing")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
(meta, gpgmw_keys, identities) = define_db_schema()
|
(meta, lacre_keys, identities) = define_db_schema()
|
||||||
|
|
||||||
dbname = sys.argv[1]
|
dbname = sys.argv[1]
|
||||||
test_db = sqlalchemy.create_engine(f"sqlite:///{dbname}")
|
test_db = sqlalchemy.create_engine(f"sqlite:///{dbname}")
|
||||||
|
@ -34,7 +34,7 @@ meta.create_all(test_db)
|
||||||
conn = test_db.connect()
|
conn = test_db.connect()
|
||||||
|
|
||||||
# Populate the database with dummy data
|
# Populate the database with dummy data
|
||||||
conn.execute(gpgmw_keys.insert(), [
|
conn.execute(lacre_keys.insert(), [
|
||||||
{"id": 1, "email": "alice@disposlab", "publickey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\
|
{"id": 1, "email": "alice@disposlab", "publickey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\
|
||||||
\n\
|
\n\
|
||||||
mQGNBGDYY5oBDAC+HAVjA05jsIpHfQ2KQ9m2olo1Qnlk+dkjD+Gagxj1ACezyiGL\n\
|
mQGNBGDYY5oBDAC+HAVjA05jsIpHfQ2KQ9m2olo1Qnlk+dkjD+Gagxj1ACezyiGL\n\
|
||||||
|
|
Loading…
Reference in a new issue