Skip to content

Commit

Permalink
Merge pull request #221 from vindex10/feature/allow_disabling_auth_check
Browse files Browse the repository at this point in the history
allow disabling auth check
  • Loading branch information
acjohnson authored Jul 19, 2023
2 parents 85ae05f + 518673a commit c27225a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 5 additions & 3 deletions grafana_backup/api_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ def main(settings):
client_cert = settings.get('CLIENT_CERT')
debug = settings.get('DEBUG')
api_health_check = settings.get('API_HEALTH_CHECK')
api_auth_check = settings.get('API_AUTH_CHECK')

if api_health_check:
(status, json_resp) = health_check(grafana_url, http_get_headers, verify_ssl, client_cert, debug)
if not status == 200:
return (status, json_resp, None, None, None)

(status, json_resp) = auth_check(grafana_url, http_get_headers, verify_ssl, client_cert, debug)
if not status == 200:
return (status, json_resp, None, None, None)
if api_auth_check:
(status, json_resp) = auth_check(grafana_url, http_get_headers, verify_ssl, client_cert, debug)
if not status == 200:
return (status, json_resp, None, None, None)

dashboard_uid_support, datasource_uid_support = uid_feature_check(grafana_url, http_get_headers, verify_ssl, client_cert, debug)
if isinstance(dashboard_uid_support, str):
Expand Down
2 changes: 1 addition & 1 deletion grafana_backup/conf/grafanaSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"debug": true,
"verify_ssl": true,
"api_health_check": true,
"api_auth_check": true,
"backup_dir": "_OUTPUT_",
"backup_file_format": "%Y%m%d%H%M",
"pretty_print": false
Expand All @@ -16,4 +17,3 @@
"admin_password": ""
}
}

6 changes: 6 additions & 0 deletions grafana_backup/grafanaSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def main(config_path):

debug = config.get('general', {}).get('debug', True)
api_health_check = config.get('general', {}).get('api_health_check', True)
api_auth_check = config.get('general', {}).get('api_auth_check', True)
verify_ssl = config.get('general', {}).get('verify_ssl', False)
client_cert = config.get('general', {}).get('client_cert', None)
backup_dir = config.get('general', {}).get('backup_dir', '_OUTPUT_')
Expand Down Expand Up @@ -96,6 +97,10 @@ def main(config_path):
if isinstance(API_HEALTH_CHECK, str):
API_HEALTH_CHECK = json.loads(API_HEALTH_CHECK.lower()) # convert environment variable string to bool

API_AUTH_CHECK = os.getenv('API_AUTH_CHECK', api_auth_check)
if isinstance(API_AUTH_CHECK, str):
API_AUTH_CHECK = json.loads(API_AUTH_CHECK.lower()) # convert environment variable string to bool

CLIENT_CERT = os.getenv('CLIENT_CERT', client_cert)

BACKUP_DIR = os.getenv('BACKUP_DIR', backup_dir)
Expand Down Expand Up @@ -145,6 +150,7 @@ def main(config_path):
config_dict['SEARCH_API_LIMIT'] = SEARCH_API_LIMIT
config_dict['DEBUG'] = DEBUG
config_dict['API_HEALTH_CHECK'] = API_HEALTH_CHECK
config_dict['API_AUTH_CHECK'] = API_AUTH_CHECK
config_dict['VERIFY_SSL'] = VERIFY_SSL
config_dict['CLIENT_CERT'] = CLIENT_CERT
config_dict['BACKUP_DIR'] = BACKUP_DIR
Expand Down

0 comments on commit c27225a

Please sign in to comment.