mirror of
https://github.com/kennethreitz/httpbin.git
synced 2026-06-05 23:00:18 +00:00
Merge pull request #386 from vanillajonathan/patch-1
Add endpoint for Bearer authentication
This commit is contained in:
@@ -478,6 +478,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')
|
||||
|
||||
Reference in New Issue
Block a user