From cd8beb5798cdab1b3cd700be662e9659cbec8977 Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Thu, 31 Jan 2013 09:50:59 +0000 Subject: Finished check_recipient and virtual_alias_map in AliasResolver. --- src/leap/mx/alias_resolver.py | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'src/leap/mx/alias_resolver.py') diff --git a/src/leap/mx/alias_resolver.py b/src/leap/mx/alias_resolver.py index 44cb44d..e079b80 100644 --- a/src/leap/mx/alias_resolver.py +++ b/src/leap/mx/alias_resolver.py @@ -17,8 +17,7 @@ TODO: o alias.ProcessAlias() -## have uuid, need to get gpg keyid -## have key, make crypto +## have uuid -> get gpg keyid alias.ProcessAlias('/path/to/mail_reciever', *args) @@ -38,7 +37,7 @@ except ImportError: from leap.mx.util import net, log, config, exceptions -def aliasToUUID(alias): +def createUUID(alias): """ Creates Universal Unique ID by taking the SHA-1 HASH of an email alias: @@ -108,7 +107,7 @@ class AliasResolver(postfix.PostfixTCPMapServer): Resources: http://www.postfix.org/proxymap.8.html - https://www.iana.org/assignments/smtp-enhanced-status-codes/smtp-enhanced-status-codes.txt + https://www.iana.org/assignments/smtp-enhanced-status-codes/ """ def __init__(self, *args, **kwargs): """Create a server which listens for Postfix aliases to resolve.""" @@ -131,10 +130,6 @@ class AliasResolver(postfix.PostfixTCPMapServer): d.addCallbacks(self._cbGot, self._cbNot) d.addErrback(log.err) - def do_query(self, key): - """Make a query to resolve an alias.""" - self.do_get(self, key) - @defer.inlineCallbacks def do_put(self, keyAndValue): """Add a key and value to the database, provided it does not exist.""" @@ -165,6 +160,30 @@ class AliasResolver(postfix.PostfixTCPMapServer): """ raise NotImplemented + def check_recipient_access(self, key): + """Make a query to resolve an alias.""" + self.do_get(self, key) + + def virtual_alias_map(self, key): + """ + Get the Universal Unique ID for the alias address. If + virtual_transport is True, then suffix the UUID with a domain. + + xxx I don't think we actually need couchdb for this, the UUID is an + identifier, not an authenticator. And the SHA1 should always be the + same, so unless it's considered to expensive to compute (less than + querying a database, I would presume), it seems silly to do this. + + Instead, we should query CouchDB with the UUID to get the GPG keyid. + """ + ## xxx need email address parser + client_id = createUUID(key) + + if self.virtual_transport: + return client.get_urn() + '@example.com' + else: + return client.get_urn() + def _cbGot(self, value): """Callback for self.get()""" if value is None: -- cgit v1.2.3