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 = {} self.remote_openers = {}
if self.get('META_URL') != None: if self.get('META_URL') != None:
auth_client_session = PGPClientSession(self.__auth) 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): def blockchain(self):
@ -113,7 +113,7 @@ class CmdCtrl:
typ = self.get('AUTH_TYPE') typ = self.get('AUTH_TYPE')
if typ != 'gnupg': if typ != 'gnupg':
raise NotImplementedError('Valid aut implementations are: 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) 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 = PGPAuthCrypt(auth_db_path, self.get('AUTH_KEY'), self.get('AUTH_KEYRING_PATH'))
self.__auth.get_secret(self.get('AUTH_PASSPHRASE')) 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()) token_dir = '/run/user/{}/clicada/usumbufu/.token'.format(os.getuid())
def __init__(self, url, auth=None): def __init__(self, url, auth=None, origin=None):
logg.debug('auth auth {}'.format(auth))
self.base_url = url self.base_url = url
url_parts = urllib.parse.urlsplit(self.base_url) url_parts = urllib.parse.urlsplit(self.base_url)
url_parts_origin = (url_parts[0], url_parts[1], '', '', '',) 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 = hashlib.sha256()
h.update(self.base_url.encode('utf-8')) h.update(self.base_url.encode('utf-8'))

View File

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

View File

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

View File

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