Commit cbb0dc58 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Remove the obsolete authgroup handling

parent 4db0e5da
...@@ -25,9 +25,6 @@ class OIDCConfig(db_models.Model): ...@@ -25,9 +25,6 @@ class OIDCConfig(db_models.Model):
enabled = db_models.BooleanField(default=False) enabled = db_models.BooleanField(default=False)
name = db_models.CharField(max_length=200) 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 as a list of strings
scopes = JSONField( scopes = JSONField(
default=scopes_default, default=scopes_default,
...@@ -75,14 +72,6 @@ class OIDCConfig(db_models.Model): ...@@ -75,14 +72,6 @@ class OIDCConfig(db_models.Model):
) )
return auth_req.request(client.authorization_endpoint) 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(): def default_idp():
return OIDCConfig.objects.filter(enabled=True).first() return OIDCConfig.objects.filter(enabled=True).first()
......
...@@ -80,14 +80,12 @@ class DeploymentSerializer(serializers.ModelSerializer): ...@@ -80,14 +80,12 @@ class DeploymentSerializer(serializers.ModelSerializer):
# contains properties which change less often # contains properties which change less often
class UserSerializer(serializers.ModelSerializer): class UserSerializer(serializers.ModelSerializer):
auth_groups = backend_serializers.AuthGroupSerializer(many=True)
groups = backend_serializers.GroupSerializer(many=True) groups = backend_serializers.GroupSerializer(many=True)
ssh_keys = backend_serializers.SSHPublicKeySerializer(many=True) ssh_keys = backend_serializers.SSHPublicKeySerializer(many=True)
class Meta: class Meta:
model = models.User model = models.User
fields = [ fields = [
'auth_groups',
'email', 'email',
'groups', 'groups',
'id', 'id',
......
...@@ -411,17 +411,23 @@ class User(AbstractUser): ...@@ -411,17 +411,23 @@ class User(AbstractUser):
for dep in self.deployments.all(): for dep in self.deployments.all():
dep.deactivate() dep.deactivate()
def update_userinfo(self, userinfo):
# authorisation groups self.userinfo = userinfo
class AuthGroup(models.Model): self.save()
name = models.CharField( groups = userinfo.get('groups', [])
max_length=200, # FIXME probably inefficient
) self.groups.clear()
users = models.ManyToManyField(
User, for group_name in groups:
related_name='auth_groups', query = Group.objects.filter(name=group_name)
blank=True, 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): class Site(models.Model):
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from rest_framework import serializers from rest_framework import serializers
from .models import SSHPublicKey, AuthGroup from .models import SSHPublicKey
class GroupSerializer(serializers.ModelSerializer): class GroupSerializer(serializers.ModelSerializer):
...@@ -15,15 +15,6 @@ 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 SSHPublicKeySerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = SSHPublicKey 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