Add endpoint for Bearer authentication

Closes #385
This commit is contained in:
Jonathan
2017-09-24 21:48:09 +02:00
committed by GitHub
parent cd60b61d77
commit c432e7819f
+14
View File
@@ -454,6 +454,20 @@ def hidden_basic_auth(user='user', passwd='passwd'):
return jsonify(authenticated=True, user=user)
@app.route('/bearer')
def bearer_auth():
"""Authenticates using bearer authentication."""
if 'Authorization' not in request.headers:
response = app.make_response('')
response.headers['WWW-Authenticate'] = 'Bearer'
response.status_code = 401
return response
authorization = request.headers.get('Authorization')
token = authorization.lstrip('Bearer ')
return jsonify(authenticated=True, token=token)
@app.route('/digest-auth/<qop>/<user>/<passwd>')
def digest_auth_md5(qop=None, user='user', passwd='passwd'):
return digest_auth(qop, user, passwd, "MD5", 'never')