feat: Allow sync domain with basic auth (#861)

This commit is contained in:
jbe-dw 2021-01-16 20:37:11 +01:00 committed by GitHub
parent c3d438842f
commit dd0a5f6326
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -291,3 +291,13 @@ def dyndns_login_required(f):
return f(*args, **kwargs)
return decorated_function
def apikey_or_basic_auth(f):
@wraps(f)
def decorated_function(*args, **kwargs):
api_auth_header = request.headers.get('X-API-KEY')
if api_auth_header:
return apikey_auth(f)(*args, **kwargs)
else:
return api_basic_auth(f)(*args, **kwargs)
return decorated_function

View File

@ -24,6 +24,7 @@ from ..lib.errors import (
from ..decorators import (
api_basic_auth, api_can_create_domain, is_json, apikey_auth,
apikey_is_admin, apikey_can_access_domain, api_role_can,
apikey_or_basic_auth,
)
import random
import string
@ -987,7 +988,7 @@ def api_server_config_forward(server_id):
# The endpoint to snychronize Domains in background
@api_bp.route('/sync_domains', methods=['GET'])
@apikey_auth
@apikey_or_basic_auth
def sync_domains():
domain = Domain()
domain.update()