24 lines
528 B
Python
24 lines
528 B
Python
from flask_httpauth import HTTPBasicAuth
|
|
|
|
auth = HTTPBasicAuth()
|
|
|
|
|
|
@auth.verify_password
|
|
def verify_password(username_or_token, password):
|
|
|
|
if username_or_token == "user" and password == "passwd":
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
def post_login_required(func):
|
|
def post_decorator(*args, **kwargs):
|
|
print("post_decorator ", func, *args, **kwargs)
|
|
return auth.login_required(func)(*args, **kwargs)
|
|
|
|
if func.__name__ in ("post", "patch", "delete"):
|
|
return post_decorator
|
|
|
|
return func
|