Skip to content

Commit f6c98bd

Browse files
authored
Merge pull request postmanlabs#386 from vanillajonathan/patch-1
Add endpoint for Bearer authentication
2 parents c0f5f0a + c432e78 commit f6c98bd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

httpbin/core.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,20 @@ def hidden_basic_auth(user='user', passwd='passwd'):
478478
return jsonify(authenticated=True, user=user)
479479

480480

481+
@app.route('/bearer')
482+
def bearer_auth():
483+
"""Authenticates using bearer authentication."""
484+
if 'Authorization' not in request.headers:
485+
response = app.make_response('')
486+
response.headers['WWW-Authenticate'] = 'Bearer'
487+
response.status_code = 401
488+
return response
489+
authorization = request.headers.get('Authorization')
490+
token = authorization.lstrip('Bearer ')
491+
492+
return jsonify(authenticated=True, token=token)
493+
494+
481495
@app.route('/digest-auth/<qop>/<user>/<passwd>')
482496
def digest_auth_md5(qop=None, user='user', passwd='passwd'):
483497
return digest_auth(qop, user, passwd, "MD5", 'never')

0 commit comments

Comments
 (0)