mirror of
https://github.com/wassname/flask-security.git
synced 2026-07-26 13:18:38 +08:00
Include WWW-Authenticate headers in @auth_required.
When using @http_auth_required, the WWW-Authenticate header is included,
but when using @auth_required('basic'), it is not. This change includes
that header in every @auth_required call that contains the 'basic'
method.
This commit is contained in:
@@ -226,6 +226,19 @@ def test_multi_auth_basic(client):
|
||||
assert response.status_code == 401
|
||||
|
||||
|
||||
def test_multi_auth_basic_invalid(client):
|
||||
response = client.get('/multi_auth', headers={
|
||||
'Authorization': 'Basic %s' % base64.b64encode(b"bogus:bogus").decode('utf-8')
|
||||
})
|
||||
assert b'<h1>Unauthorized</h1>' in response.data
|
||||
assert 'WWW-Authenticate' in response.headers
|
||||
assert 'Basic realm="Login Required"' == response.headers['WWW-Authenticate']
|
||||
|
||||
response = client.get('/multi_auth')
|
||||
print(response.headers)
|
||||
assert response.status_code == 401
|
||||
|
||||
|
||||
def test_multi_auth_token(client):
|
||||
response = json_authenticate(client)
|
||||
token = response.jdata['response']['user']['authentication_token']
|
||||
|
||||
Reference in New Issue
Block a user