Skip to content

Commit

Permalink
Move Bugzilla backend out of here. Refs #239
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Mar 22, 2018
1 parent f449c5c commit db9fc44
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions tcms/core/contrib/auth/backends.py
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-
import xmlrpc.client

from django.conf import settings
from django.core.validators import validate_email
from django.core.exceptions import ValidationError
from django.contrib.auth.models import User, Group
from django.contrib.auth.backends import ModelBackend, RemoteUserBackend

Expand All @@ -16,46 +13,6 @@ class DBModelBackend(ModelBackend):
can_logout = True


class BugzillaBackend(ModelBackend):
"""
Bugzilla authorization backend for TCMS.
It's required bugzilla xmlrpc.
"""
# Web UI Needed
can_login = True
can_register = False
can_logout = True

def authenticate(self, request, username=None, password=None):
server = xmlrpc.client.ServerProxy(settings.BUGZILLA3_RPC_SERVER)

try:
validate_email(username)
except ValidationError:
return None
else:
try:
server.bugzilla.login(username, password)
except xmlrpc.client.Fault:
return None

try:
user = User.objects.get(email=username)
user.set_password(password)
user.save()
except User.DoesNotExist:
user = User.objects.create_user(
username=username.split('@')[0],
email=username
)

user.set_unusable_password(password)

if user.check_password(password):
return user


class KerberosBackend(ModelBackend):
"""
Kerberos authorization backend for TCMS.
Expand Down

0 comments on commit db9fc44

Please sign in to comment.