get ABAC_URL from config in user model

This commit is contained in:
Cayo Puigdefabregas 2024-01-23 18:08:16 +01:00
parent 53289b0dfc
commit c9238e8e6a
1 changed files with 3 additions and 2 deletions

View File

@ -195,16 +195,17 @@ class User(UserMixin, Thing):
def _call_abac(self, path): def _call_abac(self, path):
abac_tk = app.config.get('ABAC_TOKEN') abac_tk = app.config.get('ABAC_TOKEN')
abac_coockie = app.config.get('ABAC_COOKIE') abac_coockie = app.config.get('ABAC_COOKIE')
domain = app.config.get('ABAC_URL')
eth_pub_key = session.get('eth_pub_key') eth_pub_key = session.get('eth_pub_key')
abac_path = path abac_path = path
if not (abac_tk and eth_pub_key and abac_path): if not (abac_tk and eth_pub_key and abac_path and domain):
return '' return ''
header = { header = {
'Authorization': f'Bearer {abac_tk}', 'Authorization': f'Bearer {abac_tk}',
'Cookie': abac_coockie 'Cookie': abac_coockie
} }
domain = 'https://abac-oracle.stable.iota-ec.net/accounts/'
url = f'{domain}{eth_pub_key}/{abac_path}' url = f'{domain}{eth_pub_key}/{abac_path}'
return requests.get(url, headers=header) return requests.get(url, headers=header)