Skip to content

Instantly share code, notes, and snippets.

@astyfx
Created January 21, 2015 03:28
Show Gist options
  • Save astyfx/3fe88fa78567b0ea9d46 to your computer and use it in GitHub Desktop.
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
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