Commit a6ae9e38 authored by Lukas Burgey's avatar Lukas Burgey

Rename withdraw into remove

parent 8aa8b7e6
...@@ -83,7 +83,7 @@ def _webpage_client_valid(request): ...@@ -83,7 +83,7 @@ def _webpage_client_valid(request):
def user_endpoint(request): def user_endpoint(request):
if _webpage_client_valid(request): if _webpage_client_valid(request):
LOGGER.info('Authenticated webpage client') #LOGGER.info('Authenticated webpage client')
return ALLOW return ALLOW
user = authenticate( user = authenticate(
......
...@@ -141,7 +141,7 @@ class AuthCallback(View): ...@@ -141,7 +141,7 @@ class AuthCallback(View):
class LogoutView(views.APIView): class LogoutView(views.APIView):
def post(self, request): def post(self, request):
LOGGER.debug('logged out %s', request.user) LOGGER.info('Logging out %s', request.user)
logout(request) logout(request)
return Response(state_view_data(request)) return Response(state_view_data(request))
......
...@@ -25,11 +25,11 @@ class DeploymentSerializer(serializers.ModelSerializer): ...@@ -25,11 +25,11 @@ class DeploymentSerializer(serializers.ModelSerializer):
user = UserSerializer() user = UserSerializer()
service = ServiceSerializer() service = ServiceSerializer()
ssh_keys = backend_serializers.SSHPublicKeySerializer(many=True) ssh_keys = backend_serializers.SSHPublicKeySerializer(many=True)
ssh_keys_to_withdraw = backend_serializers.SSHPublicKeySerializer(many=True) ssh_keys_to_remove = backend_serializers.SSHPublicKeySerializer(many=True)
class Meta: class Meta:
model = models.Deployment model = models.Deployment
fields = ['user', 'service', 'ssh_keys', 'ssh_keys_to_withdraw'] fields = ['user', 'service', 'ssh_keys', 'ssh_keys_to_remove']
class DeploymentsSerializer(serializers.Serializer): class DeploymentsSerializer(serializers.Serializer):
......
...@@ -64,7 +64,7 @@ class DeploymentStateSerializer(serializers.ModelSerializer): ...@@ -64,7 +64,7 @@ class DeploymentStateSerializer(serializers.ModelSerializer):
class DeploymentSerializer(serializers.ModelSerializer): class DeploymentSerializer(serializers.ModelSerializer):
service = ServiceSerializer() service = ServiceSerializer()
ssh_keys = backend_serializers.SSHPublicKeySerializer(many=True) ssh_keys = backend_serializers.SSHPublicKeySerializer(many=True)
ssh_keys_to_withdraw = backend_serializers.SSHPublicKeySerializer(many=True) ssh_keys_to_remove = backend_serializers.SSHPublicKeySerializer(many=True)
states = DeploymentStateSerializer(many=True) states = DeploymentStateSerializer(many=True)
class Meta: class Meta:
...@@ -72,7 +72,7 @@ class DeploymentSerializer(serializers.ModelSerializer): ...@@ -72,7 +72,7 @@ class DeploymentSerializer(serializers.ModelSerializer):
fields = [ fields = [
'service', 'service',
'ssh_keys', 'ssh_keys',
'ssh_keys_to_withdraw', 'ssh_keys_to_remove',
'states', 'states',
'id', 'id',
] ]
......
...@@ -169,4 +169,4 @@ class UserDeletionView(views.APIView): ...@@ -169,4 +169,4 @@ class UserDeletionView(views.APIView):
# this also logs out the user # this also logs out the user
request.user.remove() request.user.remove()
logout(request) logout(request)
return _api_state_response(request) return Response({'deleted': True})
...@@ -364,7 +364,7 @@ class User(AbstractUser): ...@@ -364,7 +364,7 @@ class User(AbstractUser):
def msg(self, msg): def msg(self, msg):
return '[{}] {}'.format(self, msg) return '[{}] {}'.format(self, msg)
# oidcuser: withdraw and delete all credentials and delete the user # oidcuser: remove and delete all credentials and delete the user
def remove(self): def remove(self):
if self.user_type == 'oidcuser': if self.user_type == 'oidcuser':
self.deactivate() self.deactivate()
...@@ -400,7 +400,7 @@ class User(AbstractUser): ...@@ -400,7 +400,7 @@ class User(AbstractUser):
self.save() self.save()
LOGGER.info(self.msg('deactivated')) LOGGER.info(self.msg('deactivated'))
# oidcuser: withdraw all credentials # oidcuser: remove all credentials
if self.user_type == 'oidcuser': if self.user_type == 'oidcuser':
for dep in self.deployments.all(): for dep in self.deployments.all():
...@@ -501,9 +501,9 @@ class SSHPublicKey(models.Model): ...@@ -501,9 +501,9 @@ class SSHPublicKey(models.Model):
return True return True
return False return False
# does not directly delete the key if the key is deployed or withdrawn # does not directly delete the key if the key is deployed or removen
# somewhere # somewhere
# the receiver 'delete_withdrawn_ssh_key' does the actual deletion # the receiver 'delete_removen_ssh_key' does the actual deletion
def delete_key(self): def delete_key(self):
# if this key is not deployed anywhere we delete it now # if this key is not deployed anywhere we delete it now
if not self.deployed_anywhere: if not self.deployed_anywhere:
...@@ -515,16 +515,16 @@ class SSHPublicKey(models.Model): ...@@ -515,16 +515,16 @@ class SSHPublicKey(models.Model):
self.deleted = True self.deleted = True
self.save() self.save()
# delete implies withdrawing the key from all clients # delete implies removeing the key from all clients
for deployment in self.deployments.all(): for deployment in self.deployments.all():
deployment.remove_key(self) deployment.remove_key(self)
# when a key is withdrawn by a client we try to finally delete it # when a key is removen by a client we try to finally delete it
def try_final_deletion(self): def try_final_deletion(self):
if self.deleted: if self.deleted:
if not self.deployed_anywhere: if not self.deployed_anywhere:
LOGGER.info(self.msg('All clients have withdrawn this key. Final deletion')) LOGGER.info(self.msg('All clients have removen this key. Final deletion'))
self._final_deletion() self._final_deletion()
def _final_deletion(self): def _final_deletion(self):
...@@ -568,9 +568,9 @@ class Deployment(models.Model): ...@@ -568,9 +568,9 @@ class Deployment(models.Model):
related_name='deployments', related_name='deployments',
blank=True, blank=True,
) )
ssh_keys_to_withdraw = models.ManyToManyField( ssh_keys_to_remove = models.ManyToManyField(
SSHPublicKey, SSHPublicKey,
related_name='withdrawn_deployments', related_name='removen_deployments',
blank=True, blank=True,
) )
is_active = models.BooleanField( is_active = models.BooleanField(
...@@ -609,7 +609,7 @@ class Deployment(models.Model): ...@@ -609,7 +609,7 @@ class Deployment(models.Model):
self.save() self.save()
LOGGER.info(self.msg('activated')) LOGGER.info(self.msg('activated'))
# withdraw all credentials # remove all credentials
def deactivate(self): def deactivate(self):
if not self.is_active: if not self.is_active:
LOGGER.error(self.msg('already deactivated')) LOGGER.error(self.msg('already deactivated'))
...@@ -631,22 +631,22 @@ class Deployment(models.Model): ...@@ -631,22 +631,22 @@ class Deployment(models.Model):
self.ssh_keys.add(key) self.ssh_keys.add(key)
if key in self.ssh_keys_to_withdraw.all(): if key in self.ssh_keys_to_remove.all():
self.ssh_keys_to_withdraw.remove(key) self.ssh_keys_to_remove.remove(key)
self.save() self.save()
self._deploy_key(key) self._deploy_key(key)
# withdraw key and track changes in the key lists # remove key and track changes in the key lists
def remove_key(self, key): def remove_key(self, key):
if not self.is_active: if not self.is_active:
LOGGER.error(self.msg('cannot withdraw while deactivated')) LOGGER.error(self.msg('cannot remove while deactivated'))
raise Exception('deployment deactivated') raise Exception('deployment deactivated')
self.ssh_keys.remove(key) self.ssh_keys.remove(key)
# keys which are to be withdrawn by the clients # keys which are to be removen by the clients
self.ssh_keys_to_withdraw.add(key) self.ssh_keys_to_remove.add(key)
self.save() self.save()
self._remove_key(key) self._remove_key(key)
...@@ -763,24 +763,26 @@ class DeploymentState(models.Model): ...@@ -763,24 +763,26 @@ class DeploymentState(models.Model):
# each state item publishes its state to the user # each state item publishes its state to the user
def publish_to_client(self): def publish_to_client(self):
# mitigating circular dependencies here if self.service is not None:
from .clientapi.serializers import DeploymentStateSerializer # mitigating circular dependencies here
msg = json.dumps(DeploymentStateSerializer(self).data) from .clientapi.serializers import DeploymentStateSerializer
msg = json.dumps(DeploymentStateSerializer(self).data)
RabbitMQInstance.load().publish_by_service(
self.service, RabbitMQInstance.load().publish_by_service(
msg, self.service,
) msg,
)
# update the state of the remote webpage # update the state of the remote webpage
def publish_to_user(self): def publish_to_user(self):
from .frontend.views import user_state if self.user is not None:
content = { from .frontend.views import user_state
'user_state': user_state(self.user), content = {
} 'user_state': user_state(self.user),
RabbitMQInstance.load().publish_to_user( }
self.user, RabbitMQInstance.load().publish_to_user(
content, self.user,
) content,
)
def msg(self, msg): def msg(self, msg):
return '[DState:{}] {}'.format(self, msg) return '[DState:{}] {}'.format(self, msg)
......
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