Пример #1
0
    def check_oauth2_auth(self, user: User, auth_backend):
        ip = self.get_request_ip()
        request = self.request

        self._set_partial_credential_error(user.username, ip, request)

        if user.is_expired:
            self.raise_credential_error(errors.reason_user_expired)
        elif not user.is_active:
            self.raise_credential_error(errors.reason_user_inactive)

        self._check_is_block(user.username)
        self._check_login_acl(user, ip)

        LoginBlockUtil(user.username, ip).clean_failed_count()
        LoginIpBlockUtil(ip).clean_block_if_need()
        MFABlockUtils(user.username, ip).clean_failed_count()

        self.mark_password_ok(user, False)
        return user
Пример #2
0
    def check_oauth2_auth(self, user: User, auth_backend):
        ip = self.get_request_ip()
        request = self.request

        self._set_partial_credential_error(user.username, ip, request)

        if user.is_expired:
            self.raise_credential_error(errors.reason_user_expired)
        elif not user.is_active:
            self.raise_credential_error(errors.reason_user_inactive)

        self._check_is_block(user.username)
        self._check_login_acl(user, ip)

        LoginBlockUtil(user.username, ip).clean_failed_count()
        MFABlockUtils(user.username, ip).clean_failed_count()

        request.session['auth_password'] = 1
        request.session['user_id'] = str(user.id)
        request.session['auth_backend'] = auth_backend
        return user
Пример #3
0
 def incr_mfa_failed_time(username, ip):
     util = MFABlockUtils(username, ip)
     util.incr_failed_count()
Пример #4
0
 def perform_update(self, serializer):
     user = self.get_object()
     username = user.username if user else ''
     LoginBlockUtil.unblock_user(username)
     MFABlockUtils.unblock_user(username)
Пример #5
0
 def unblock_login(self):
     from users.utils import LoginBlockUtil, MFABlockUtils
     LoginBlockUtil.unblock_user(self.username)
     MFABlockUtils.unblock_user(self.username)