mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-01-08 19:35:40 +00:00
feat: Allow sync domain with basic auth (#861)
This commit is contained in:
parent
c3d438842f
commit
dd0a5f6326
@ -291,3 +291,13 @@ def dyndns_login_required(f):
|
|||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
|
|
||||||
return decorated_function
|
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
|
||||||
|
@ -24,6 +24,7 @@ from ..lib.errors import (
|
|||||||
from ..decorators import (
|
from ..decorators import (
|
||||||
api_basic_auth, api_can_create_domain, is_json, apikey_auth,
|
api_basic_auth, api_can_create_domain, is_json, apikey_auth,
|
||||||
apikey_is_admin, apikey_can_access_domain, api_role_can,
|
apikey_is_admin, apikey_can_access_domain, api_role_can,
|
||||||
|
apikey_or_basic_auth,
|
||||||
)
|
)
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
@ -987,7 +988,7 @@ def api_server_config_forward(server_id):
|
|||||||
|
|
||||||
# The endpoint to snychronize Domains in background
|
# The endpoint to snychronize Domains in background
|
||||||
@api_bp.route('/sync_domains', methods=['GET'])
|
@api_bp.route('/sync_domains', methods=['GET'])
|
||||||
@apikey_auth
|
@apikey_or_basic_auth
|
||||||
def sync_domains():
|
def sync_domains():
|
||||||
domain = Domain()
|
domain = Domain()
|
||||||
domain.update()
|
domain.update()
|
||||||
|
Loading…
Reference in New Issue
Block a user