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


Python utils.verify_password方法代碼示例

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


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

示例1: test_verify_password_single_hash_list

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import verify_password [as 別名]
def test_verify_password_single_hash_list(app, sqlalchemy_datastore):
    init_app_with_options(
        app,
        sqlalchemy_datastore,
        **{
            "SECURITY_PASSWORD_HASH": "bcrypt",
            "SECURITY_PASSWORD_SALT": "salty",
            "SECURITY_PASSWORD_SINGLE_HASH": ["django_pbkdf2_sha256", "plaintext"],
            "SECURITY_PASSWORD_SCHEMES": [
                "bcrypt",
                "pbkdf2_sha256",
                "django_pbkdf2_sha256",
                "plaintext",
            ],
        }
    )
    with app.app_context():
        # double hash
        assert verify_password("pass", hash_password("pass"))
        assert verify_password("pass", pbkdf2_sha256.hash(get_hmac("pass")))
        # single hash
        assert verify_password("pass", django_pbkdf2_sha256.hash("pass"))
        assert verify_password("pass", plaintext.hash("pass")) 
開發者ID:Flask-Middleware,項目名稱:flask-security,代碼行數:25,代碼來源:test_hashing.py

示例2: _http_auth

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import verify_password [as 別名]
def _http_auth(self, user, username, password):
        """Perform basic user authentication
        - Check that the password that was passed in the request can be
          verified against the password stored in the DB

        :param user: The DB user object
        :param username: The username from the request
        :param password: The password from the request
        :return: The DB user object
        """
        self.logger.debug('Running basic HTTP authentication')
        if not user:
            raise_unauthorized_user_error(
                'Authentication failed for '
                '<User username=`{0}`>'.format(username)
            )
        if not verify_password(password, user.password):
            self._increment_failed_logins_counter(user)
            raise_unauthorized_user_error(
                'Authentication failed for {0}.'
                ' Bad credentials or locked account'.format(user)
            )
        return user 
開發者ID:cloudify-cosmo,項目名稱:cloudify-manager,代碼行數:25,代碼來源:authentication.py

示例3: correct_password

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import verify_password [as 別名]
def correct_password(email, password):
    user = User.objects.get(email=email)
    return utils.verify_password(password, user.password) 
開發者ID:fkie-cad,項目名稱:LuckyCAT,代碼行數:5,代碼來源:Users.py

示例4: post

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import verify_password [as 別名]
def post(self):
        args = parser.parse_args()
        email = args['email']
        password = args['password']
        if email is None or password is None:
            return {'message': "Email or password empty"}, 401
        user = User.query.filter_by(email=args["email"]).first()
        if security_utils.verify_password(password, user.password):
            return {'message': 'Login Successful', 'apikey': user.api_key}, 200
        return {'message': 'Login Failed'}, 401 
開發者ID:dhamaniasad,項目名稱:crestify,代碼行數:12,代碼來源:apiservice.py

示例5: test_verify_password_bcrypt_double_hash

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import verify_password [as 別名]
def test_verify_password_bcrypt_double_hash(app, sqlalchemy_datastore):
    init_app_with_options(
        app,
        sqlalchemy_datastore,
        **{
            "SECURITY_PASSWORD_HASH": "bcrypt",
            "SECURITY_PASSWORD_SALT": "salty",
            "SECURITY_PASSWORD_SINGLE_HASH": False,
        }
    )
    with app.app_context():
        assert verify_password("pass", hash_password("pass")) 
開發者ID:Flask-Middleware,項目名稱:flask-security,代碼行數:14,代碼來源:test_hashing.py

示例6: test_verify_password_bcrypt_single_hash

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import verify_password [as 別名]
def test_verify_password_bcrypt_single_hash(app, sqlalchemy_datastore):
    init_app_with_options(
        app,
        sqlalchemy_datastore,
        **{
            "SECURITY_PASSWORD_HASH": "bcrypt",
            "SECURITY_PASSWORD_SALT": None,
            "SECURITY_PASSWORD_SINGLE_HASH": True,
        }
    )
    with app.app_context():
        assert verify_password("pass", hash_password("pass")) 
開發者ID:Flask-Middleware,項目名稱:flask-security,代碼行數:14,代碼來源:test_hashing.py

示例7: test_verify_password_backward_compatibility

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import verify_password [as 別名]
def test_verify_password_backward_compatibility(app, sqlalchemy_datastore):
    init_app_with_options(
        app,
        sqlalchemy_datastore,
        **{
            "SECURITY_PASSWORD_HASH": "bcrypt",
            "SECURITY_PASSWORD_SINGLE_HASH": False,
            "SECURITY_PASSWORD_SCHEMES": ["bcrypt", "plaintext"],
        }
    )
    with app.app_context():
        # double hash
        assert verify_password("pass", hash_password("pass"))
        # single hash
        assert verify_password("pass", plaintext.hash("pass")) 
開發者ID:Flask-Middleware,項目名稱:flask-security,代碼行數:17,代碼來源:test_hashing.py

示例8: test_verify_password_argon2

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import verify_password [as 別名]
def test_verify_password_argon2(app, sqlalchemy_datastore):
    init_app_with_options(
        app, sqlalchemy_datastore, **{"SECURITY_PASSWORD_HASH": "argon2"}
    )
    with app.app_context():
        hashed_pwd = hash_password("pass")
        assert verify_password("pass", hashed_pwd)
        assert "t=10" in hashed_pwd

        # Verify double hash
        assert verify_password("pass", argon2.hash(get_hmac("pass"))) 
開發者ID:Flask-Middleware,項目名稱:flask-security,代碼行數:13,代碼來源:test_hashing.py

示例9: authenticate_user

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import verify_password [as 別名]
def authenticate_user(self, username, password):
        user = User.objects(email=username).first()
        if user and verify_password(password, user.password):
            return user 
開發者ID:opendatateam,項目名稱:udata,代碼行數:6,代碼來源:oauth2.py

示例10: authenticate

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import verify_password [as 別名]
def authenticate(username, password):
    user = user_datastore.find_user(email=username)
    if user and username == user.email and verify_password(password, user.password):
        return user
    return None 
開發者ID:graup,項目名稱:flask-restless-security,代碼行數:7,代碼來源:server.py

示例11: password_is_correct

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import verify_password [as 別名]
def password_is_correct(self, user_name, password):
        user = self.find_user(email=user_name)
        return verify_password(password, user.password) 
開發者ID:fkie-cad,項目名稱:FACT_core,代碼行數:5,代碼來源:user_role_db_interface.py


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