ci: upgrade pylint to latest version
core: also upgrade kombu as https://github.com/celery/kombu/issues/1101 is fixed now
This commit is contained in:
		@ -1,6 +1,5 @@
 | 
			
		||||
"""passbook OTP Settings"""
 | 
			
		||||
 | 
			
		||||
OTP_TOTP_ISSUER = 'passbook'
 | 
			
		||||
MIDDLEWARE = [
 | 
			
		||||
    'django_otp.middleware.OTPMiddleware',
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
@ -1,22 +1,17 @@
 | 
			
		||||
"""passbook OTP Utils"""
 | 
			
		||||
 | 
			
		||||
from django.conf import settings
 | 
			
		||||
from django.utils.http import urlencode
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def otpauth_url(accountname, secret, issuer=None, digits=6):
 | 
			
		||||
    """Create otpauth according to
 | 
			
		||||
    https://github.com/google/google-authenticator/wiki/Key-Uri-Format"""
 | 
			
		||||
 | 
			
		||||
    accountname = accountname
 | 
			
		||||
    issuer = issuer if issuer else getattr(settings, 'OTP_TOTP_ISSUER')
 | 
			
		||||
 | 
			
		||||
    # Ensure that the secret parameter is the FIRST parameter of the URI, this
 | 
			
		||||
    # allows Microsoft Authenticator to work.
 | 
			
		||||
    query = [
 | 
			
		||||
        ('secret', secret),
 | 
			
		||||
        ('digits', digits),
 | 
			
		||||
        ('issuer', issuer),
 | 
			
		||||
        ('issuer', 'passbook'),
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    return 'otpauth://totp/%s:%s?%s' % (issuer, accountname, urlencode(query))
 | 
			
		||||
 | 
			
		||||
@ -26,6 +26,7 @@ OTP_SESSION_KEY = 'passbook_factors_otp_key'
 | 
			
		||||
OTP_SETTING_UP_KEY = 'passbook_factors_otp_setup'
 | 
			
		||||
LOGGER = get_logger()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UserSettingsView(LoginRequiredMixin, TemplateView):
 | 
			
		||||
    """View for user settings to control OTP"""
 | 
			
		||||
 | 
			
		||||
@ -37,15 +38,16 @@ class UserSettingsView(LoginRequiredMixin, TemplateView):
 | 
			
		||||
        static = StaticDevice.objects.filter(user=self.request.user, confirmed=True)
 | 
			
		||||
        if static.exists():
 | 
			
		||||
            kwargs['static_tokens'] = StaticToken.objects.filter(device=static.first()) \
 | 
			
		||||
                                        .order_by('token')
 | 
			
		||||
                .order_by('token')
 | 
			
		||||
        totp_devices = TOTPDevice.objects.filter(user=self.request.user, confirmed=True)
 | 
			
		||||
        kwargs['state'] = totp_devices.exists() and static.exists()
 | 
			
		||||
        return kwargs
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DisableView(LoginRequiredMixin, View):
 | 
			
		||||
    """Disable TOTP for user"""
 | 
			
		||||
 | 
			
		||||
    def get(self, request, *args, **kwargs):
 | 
			
		||||
    def get(self, request: HttpRequest) -> HttpResponse:
 | 
			
		||||
        """Delete all the devices for user"""
 | 
			
		||||
        static = get_object_or_404(StaticDevice, user=request.user, confirmed=True)
 | 
			
		||||
        static_tokens = StaticToken.objects.filter(device=static).order_by('token')
 | 
			
		||||
@ -59,6 +61,7 @@ class DisableView(LoginRequiredMixin, View):
 | 
			
		||||
        Event.new(EventAction.CUSTOM, message='User disabled OTP.').from_http(request)
 | 
			
		||||
        return redirect(reverse('passbook_factors_otp:otp-user-settings'))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class EnableView(LoginRequiredMixin, FormView):
 | 
			
		||||
    """View to set up OTP"""
 | 
			
		||||
 | 
			
		||||
@ -133,6 +136,7 @@ class EnableView(LoginRequiredMixin, FormView):
 | 
			
		||||
        Event.new(EventAction.CUSTOM, message='User enabled OTP.').from_http(self.request)
 | 
			
		||||
        return redirect('passbook_factors_otp:otp-user-settings')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class QRView(NeverCacheMixin, View):
 | 
			
		||||
    """View returns an SVG image with the OTP token information"""
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -15,18 +15,18 @@ from passbook.lib.utils.urls import is_url_absolute
 | 
			
		||||
from passbook.policies.engine import PolicyEngine
 | 
			
		||||
 | 
			
		||||
LOGGER = get_logger()
 | 
			
		||||
# Argument used to redirect user after login
 | 
			
		||||
NEXT_ARG_NAME = 'next'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def _redirect_with_qs(view, get_query_set=None):
 | 
			
		||||
    """Wrapper to redirect whilst keeping GET Parameters"""
 | 
			
		||||
    target = reverse(view)
 | 
			
		||||
    if get_query_set:
 | 
			
		||||
        target += '?' + urlencode({key: value for key, value in get_query_set.items()})
 | 
			
		||||
        target += '?' + urlencode(get_query_set)
 | 
			
		||||
    return redirect(target)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Argument used to redirect user after login
 | 
			
		||||
NEXT_ARG_NAME = 'next'
 | 
			
		||||
 | 
			
		||||
class AuthenticationView(UserPassesTestMixin, View):
 | 
			
		||||
    """Wizard-like Multi-factor authenticator"""
 | 
			
		||||
 | 
			
		||||
@ -165,5 +165,6 @@ class AuthenticationView(UserPassesTestMixin, View):
 | 
			
		||||
                del self.request.session[key]
 | 
			
		||||
        LOGGER.debug("Cleaned up sessions")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class FactorPermissionDeniedView(PermissionDeniedView):
 | 
			
		||||
    """User could not be authenticated"""
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user