Add settable origin to http session instantiation
This commit is contained in:
parent
5a337db2b0
commit
cacd8dbab8
@ -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'))
|
||||
|
@ -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 = 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'))
|
||||
|
@ -1,12 +1,14 @@
|
||||
[meta]
|
||||
lookup_method = phone
|
||||
url =
|
||||
http_origin =
|
||||
|
||||
[filestore]
|
||||
ttl = 86400
|
||||
|
||||
[tx]
|
||||
cache_url =
|
||||
http_origin =
|
||||
|
||||
[cic]
|
||||
registry_address =
|
||||
|
@ -16,4 +16,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(ctrl)
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user