Add settable origin to http session instantiation

This commit is contained in:
nolash 2021-11-11 16:38:05 +01:00
parent 5a337db2b0
commit cacd8dbab8
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
5 changed files with 12 additions and 7 deletions

View File

@ -50,7 +50,7 @@ class CmdCtrl:
self.remote_openers = {}
if self.get('META_URL') != None:
auth_client_session = PGPClientSession(self.__auth)
self.remote_openers['meta'] = HTTPSession(self.get('META_URL'), auth=auth_client_session)
self.remote_openers['meta'] = HTTPSession(self.get('META_URL'), auth=auth_client_session, origin=self.config.get('META_HTTP_ORIGIN'))
def blockchain(self):
@ -113,7 +113,7 @@ class CmdCtrl:
typ = self.get('AUTH_TYPE')
if typ != 'gnupg':
raise NotImplementedError('Valid aut implementations are: gnupg')
default_auth_db_path = os.path.join(os.environ['HOME'], '.clicada/auth')
default_auth_db_path = os.path.join(os.environ['HOME'], '.local/share/cic/clicada')
auth_db_path = self.get('AUTH_DB_PATH', default_auth_db_path)
self.__auth = PGPAuthCrypt(auth_db_path, self.get('AUTH_KEY'), self.get('AUTH_KEYRING_PATH'))
self.__auth.get_secret(self.get('AUTH_PASSPHRASE'))

View File

@ -45,12 +45,15 @@ class HTTPSession:
token_dir = '/run/user/{}/clicada/usumbufu/.token'.format(os.getuid())
def __init__(self, url, auth=None):
logg.debug('auth auth {}'.format(auth))
def __init__(self, url, auth=None, origin=None):
self.base_url = url
url_parts = urllib.parse.urlsplit(self.base_url)
url_parts_origin = (url_parts[0], url_parts[1], '', '', '',)
self.origin = urllib.parse.urlunsplit(url_parts_origin)
self.origin = origin
if self.origin == None:
self.origin = urllib.parse.urlunsplit(url_parts_origin)
else:
logg.debug('overriding http origin for {} with {}'.format(url, self.origin))
h = hashlib.sha256()
h.update(self.base_url.encode('utf-8'))

View File

@ -1,12 +1,14 @@
[meta]
lookup_method = phone
url =
http_origin =
[filestore]
ttl = 86400
[tx]
cache_url =
http_origin =
[cic]
registry_address =

View File

@ -16,4 +16,4 @@ def main():
if __name__ == '__main__':
main(ctrl)
main()

View File

@ -1,6 +1,6 @@
[metadata]
name = clicada
version = 0.0.1a7
version = 0.0.1a8
description = CLI CRM tool for the cic-stack custodial wallet system
author = Louis Holbrook
author_email = dev@holbrook.no