def handle_unauthorized(): authenticate = WWWAuthenticate() authenticate.set_basic('AdminLDAP Login') response = make_response( error_response(u'Authentifizierung erforderlich', 401)) response.headers['WWW-Authenticate'] = authenticate.to_header() return response
def handle_unauthorized(): authenticate = WWWAuthenticate() authenticate.set_basic('AdminLDAP Login') response = make_response(error_response( u'Authentifizierung erforderlich',401)) response.headers['WWW-Authenticate'] = authenticate.to_header() return response
def test_unauthorized_www_authenticate(): basic = WWWAuthenticate() basic.set_basic("test") digest = WWWAuthenticate() digest.set_digest("test", "test") exc = exceptions.Unauthorized(www_authenticate=basic) h = dict(exc.get_headers({})) assert h['WWW-Authenticate'] == str(basic) exc = exceptions.Unauthorized(www_authenticate=[digest, basic]) h = dict(exc.get_headers({})) assert h['WWW-Authenticate'] == ', '.join((str(digest), str(basic)))
def test_unauthorized_www_authenticate(): basic = WWWAuthenticate() basic.set_basic("test") digest = WWWAuthenticate() digest.set_digest("test", "test") exc = exceptions.Unauthorized(www_authenticate=basic) h = dict(exc.get_headers({})) assert h["WWW-Authenticate"] == str(basic) exc = exceptions.Unauthorized(www_authenticate=[digest, basic]) h = dict(exc.get_headers({})) assert h["WWW-Authenticate"] == ", ".join((str(digest), str(basic)))
def test_unauthorized_www_authenticate(): basic = WWWAuthenticate() basic.set_basic("test") digest = WWWAuthenticate() digest.set_digest("test", "test") exc = exceptions.Unauthorized(www_authenticate=basic) h = Headers(exc.get_headers({})) assert h["WWW-Authenticate"] == str(basic) exc = exceptions.Unauthorized(www_authenticate=[digest, basic]) h = Headers(exc.get_headers({})) assert h.get_all("WWW-Authenticate") == [str(digest), str(basic)] exc = exceptions.Unauthorized() h = Headers(exc.get_headers({})) assert "WWW-Authenticate" not in h
def get_basic_auth(realm=None): basic_auth = WWWAuthenticate() basic_auth.set_basic(realm=realm or 'Authentication required') return basic_auth.to_header()
def unauthorized(): auth = WWWAuthenticate() auth.set_basic() abort(401, www_authenticate=auth)
def _create_unauthorized(description, realm=DEFAULT_REALM): www_authenticate = WWWAuthenticate() www_authenticate.set_basic(realm=realm) return Unauthorized(description=description, www_authenticate=www_authenticate.to_header())