Skip to content

Commit

Permalink
adds basic auth support (#166)
Browse files Browse the repository at this point in the history
* adds basic auth support

* Update arangopipe/arangopipe/arangopipe_storage/arangopipe_admin_api.py

Co-authored-by: Anthony Mahanna <43019056+aMahanna@users.noreply.github.com>

Co-authored-by: Anthony Mahanna <43019056+aMahanna@users.noreply.github.com>
  • Loading branch information
cw00dw0rd and aMahanna committed Dec 10, 2021
1 parent 3b581d9 commit 746c47e
Showing 1 changed file with 9 additions and 1 deletion.
Expand Up @@ -12,7 +12,10 @@
from arangopipe.arangopipe_storage.managed_service_conn_parameters import ManagedServiceConnParam
import json
import requests
from requests.auth import HTTPBasicAuth
import time


#import traceback
# create logger with 'spam_application'
logger = logging.getLogger('arangopipe_admin_logger')
Expand Down Expand Up @@ -71,6 +74,7 @@ def __init__(self, reuse_connection=True, config=None, persist_conn=True,\
db_serv_port = self.cfg['arangodb'][self.mscp.DB_SERVICE_PORT]
db_end_point = self.cfg['arangodb'][self.mscp.DB_SERVICE_END_POINT]
db_serv_name = self.cfg['arangodb'][self.mscp.DB_SERVICE_NAME]


except KeyError as k:
logger.error("Connection information is missing : " + k.args[0])
Expand Down Expand Up @@ -203,7 +207,11 @@ def create_db(self, db_srv_host, db_srv_port, db_serv_name,\
self.mscp.DB_PASSWORD: db_password }
logger.info("Requesting a managed service database...")

r = requests.post(url=API_ENDPOINT, json=api_data, verify=True)

if self.mscp.DB_ROOT_USER_PASSWORD in self.cfg['arangodb'] and self.mscp.DB_ROOT_USER in self.cfg['arangodb']:
r = requests.post(url=API_ENDPOINT, auth=HTTPBasicAuth(self.cfg['arangodb'][self.mscp.DB_ROOT_USER], self.cfg['arangodb'][self.mscp.DB_ROOT_USER_PASSWORD]),json=api_data, verify=True)
else:
r = requests.post(url=API_ENDPOINT,json=api_data, verify=True)

if r.status_code == 409 or r.status_code == 400:
logger.error(
Expand Down

0 comments on commit 746c47e

Please sign in to comment.