當前位置: 首頁>>代碼示例>>Python>>正文


Python flask_httpauth.HTTPBasicAuth方法代碼示例

本文整理匯總了Python中flask_httpauth.HTTPBasicAuth方法的典型用法代碼示例。如果您正苦於以下問題:Python flask_httpauth.HTTPBasicAuth方法的具體用法?Python flask_httpauth.HTTPBasicAuth怎麽用?Python flask_httpauth.HTTPBasicAuth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flask_httpauth的用法示例。


在下文中一共展示了flask_httpauth.HTTPBasicAuth方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: register_extensions

# 需要導入模塊: import flask_httpauth [as 別名]
# 或者: from flask_httpauth import HTTPBasicAuth [as 別名]
def register_extensions(self):
        self.auth = HTTPBasicAuth()
        self.csrf = CSRFProtect()
        self.csrf.init_app(self) 
開發者ID:eNMS-automation,項目名稱:eNMS,代碼行數:6,代碼來源:server.py

示例2: setup_http_basic_auth

# 需要導入模塊: import flask_httpauth [as 別名]
# 或者: from flask_httpauth import HTTPBasicAuth [as 別名]
def setup_http_basic_auth(self):
        auth = HTTPBasicAuth()
        self.verify_password = auth.verify_password(self.verify_password)
        return auth 
開發者ID:hakyimlab,項目名稱:ukbrest,代碼行數:6,代碼來源:auth.py

示例3: __init__

# 需要導入模塊: import flask_httpauth [as 別名]
# 或者: from flask_httpauth import HTTPBasicAuth [as 別名]
def __init__(self, source):
        self.auth = HTTPBasicAuth()

        self.source = source

        @self.auth.verify_password
        def verify_password(username, password):
            for user in self.source.users:
                if user.username == username:
                    return check_password_hash(user.password, password)
            return False

        @self.auth.error_handler
        def unauthorized():
            # return 403 instead of 401 to prevent browsers from displaying the default
            # auth dialog
            return make_response(jsonify({'message': 'Unauthorized access'}), 403)

        self.second_auth = HTTPTokenAuth()

        @self.second_auth.verify_token
        def verify_token(token):
            self.clean_tokens()
            headers = request.headers
            token = headers.get("X-Api-Key")
            for user in self.source.users:
                for current_token in user.tokens:
                    if user.tokens[current_token][0] == token:
                        return True
            return False

        @self.second_auth.error_handler
        def unauthorized():
            # return 403 instead of 401 to prevent browsers from displaying the default
            # auth dialog
            return make_response(jsonify({'message': 'Unauthorized access'}), 403) 
開發者ID:FSecureLABS,項目名稱:captcha22,代碼行數:38,代碼來源:server.py


注:本文中的flask_httpauth.HTTPBasicAuth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。