Commit cbb0dc58 authored by Lukas Burgey's avatar Lukas Burgey

Remove the obsolete authgroup handling

parent 4db0e5da
......@@ -25,9 +25,6 @@ class OIDCConfig(db_models.Model):
enabled = db_models.BooleanField(default=False)
name = db_models.CharField(max_length=200)
# does this idp provide us with group informations?
group_provider = db_models.BooleanField(default=False)
# scopes as a list of strings
scopes = JSONField(
default=scopes_default,
......@@ -75,14 +72,6 @@ class OIDCConfig(db_models.Model):
)
return auth_req.request(client.authorization_endpoint)
def get_user_groupinformation(self, userinfo):
if not self.group_provider:
return models.AuthGroup.objects.none()
LOGGER.debug('Retrieving group information for %s', userinfo)
# TODO actually retrieve the group information
return models.AuthGroup.objects.none()
def default_idp():
return OIDCConfig.objects.filter(enabled=True).first()
......
......@@ -80,14 +80,12 @@ class DeploymentSerializer(serializers.ModelSerializer):
# contains properties which change less often
class UserSerializer(serializers.ModelSerializer):
auth_groups = backend_serializers.AuthGroupSerializer(many=True)
groups = backend_serializers.GroupSerializer(many=True)
ssh_keys = backend_serializers.SSHPublicKeySerializer(many=True)
class Meta:
model = models.User
fields = [
'auth_groups',
'email',
'groups',
'id',
......
......@@ -411,17 +411,23 @@ class User(AbstractUser):
for dep in self.deployments.all():
dep.deactivate()
# authorisation groups
class AuthGroup(models.Model):
name = models.CharField(
max_length=200,
)
users = models.ManyToManyField(
User,
related_name='auth_groups',
blank=True,
)
def update_userinfo(self, userinfo):
self.userinfo = userinfo
self.save()
groups = userinfo.get('groups', [])
# FIXME probably inefficient
self.groups.clear()
for group_name in groups:
query = Group.objects.filter(name=group_name)
if not query.exists():
LOGGER.info("Adding group %s", group_name)
group = Group(name=group_name)
group.save()
self.groups.add(group)
else:
for group in query.all():
self.groups.add(group)
class Site(models.Model):
......
......@@ -3,7 +3,7 @@
from django.contrib.auth.models import Group
from rest_framework import serializers
from .models import SSHPublicKey, AuthGroup
from .models import SSHPublicKey
class GroupSerializer(serializers.ModelSerializer):
......@@ -15,15 +15,6 @@ class GroupSerializer(serializers.ModelSerializer):
]
class AuthGroupSerializer(serializers.ModelSerializer):
class Meta:
model = AuthGroup
fields = [
'id',
'name',
]
class SSHPublicKeySerializer(serializers.ModelSerializer):
class Meta:
model = SSHPublicKey
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment