Merge pull request #1027 from mirko/add-WWW-Authenticate-header-for-dyndns

dyndns: Respond with HTTP header 'WWW-Authenticate' to unauthed requests
This commit is contained in:
jbe-dw 2022-04-07 13:31:03 +02:00 committed by GitHub
commit 33f1c6ad61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,7 @@
import base64
import binascii
from functools import wraps
from flask import g, request, abort, current_app, render_template
from flask import g, request, abort, current_app, Response
from flask_login import current_user
from .models import User, ApiKey, Setting, Domain, Setting
@ -409,7 +409,7 @@ def dyndns_login_required(f):
@wraps(f)
def decorated_function(*args, **kwargs):
if current_user.is_authenticated is False:
return render_template('dyndns.html', response='badauth'), 200
return Response(headers={'WWW-Authenticate': 'Basic'}, status=401)
return f(*args, **kwargs)
return decorated_function