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

Change the package structure drastically

parent 6ecb2371
import logging
from django.db import models
from polymorphic.models import PolymorphicModel
from rest_framework import serializers
from rest_polymorphic.serializers import PolymorphicSerializer
LOGGER = logging.getLogger(__name__)
class Credential(PolymorphicModel):
# name of the credential
name = models.CharField(
max_length=150,
)
# the credential itself (e.g. the ssh public key)
value = models.TextField(
max_length=1000
)
class SSHKey(Credential):
@property
def type(self):
return 'ssh_public_key'
class PasswordHash(Credential):
# the used hash algorithm
hash_algorithm = models.CharField(
max_length=150,
)
@property
def type(self):
return 'password_hash'
class SSHKeySerializer(serializers.ModelSerializer):
class Meta:
model = SSHKey
fields = ('name', 'value', 'type',)
class PasswordHashSerializer(serializers.ModelSerializer):
class Meta:
model = PasswordHash
fields = ('name', 'value', 'type', 'hash_algorithm',)
class CredentialSerializer(PolymorphicSerializer):
mode_serializer_mapping = {
SSHKey: SSHKeySerializer,
PasswordHash: PasswordHashSerializer,
}
from json import dumps
from logging import getLogger
from django.contrib.auth.models import Group
from django.db import models
from django_mysql.models import JSONField
......
......@@ -8,6 +8,8 @@ from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django_mysql.models import JSONField
from polymorphic.models import PolymorphicModel
from rest_polymorphic.serializers import PolymorphicSerializer
from .auth.v1.models import OIDCConfig
......@@ -252,6 +254,7 @@ class User(AbstractUser):
key.save()
@receiver(post_save, sender=User)
def deactivate_user(sender, instance=None, created=False, **kwargs):
if created:
......
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