Created
January 21, 2015 03:28
-
-
Save astyfx/3fe88fa78567b0ea9d46 to your computer and use it in GitHub Desktop.
Decorator for flask-HTTPAuth authentication header. In AngularJS for prevent basic authentication popup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_authentication_header(f): | |
''' | |
Decorator for flask-HTTPAuth authentication header. | |
In AngularJS for prevent basic authentication popup | |
:param f: | |
:return: | |
''' | |
@wraps(f) | |
def decorated(*args, **kwargs): | |
res = f(*args, **kwargs) | |
print res | |
if 'WWW-Authenticate' in res.headers.keys(): | |
res.headers['WWW-Authenticate'] = res.headers['WWW-Authenticate'].replace('Basic ', 'Response ') | |
return res | |
return decorated |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment