Commit 9e19c405 authored by Sven Lukrafka's avatar Sven Lukrafka

Delete Private Data

parent ef10d61f
# General settings for both development and productiv mode
TASK_PRIVATE_ATTRIBUTES = ['mail', 'telephoneNumber']
from general.settings import DEVELOPMENT_MODE
if DEVELOPMENT_MODE:
......
......@@ -5,7 +5,7 @@ from general.class_provider import get_class, get_function
import json
class granted:
def execute(self, user_ldap_entry):
def execute(self, user_ldap_entry, user_dn):
if not getattr(settings, 'CRUST_TASK_URL_1') == '':
json_body = provide_request_body(user_ldap_entry)
#headers = {'X-TENANT-ID': 'lui2backend', 'Authorization': 'Basic ' + base64.b64encode('crust:Unity-Grease-Cow-Sensitive-Despair-5'.encode()).decode()}
......@@ -24,11 +24,12 @@ class granted:
response = requests.post(getattr(settings, 'CRUST_TASK_URL_3'), timeout=1, data=json_body)
if response.status_code is not 200:
return response.status_code
delete_private_data(user_dn)
return response.status_code
class denied:
def execute(self,user_ldap_entry):
def execute(self,user_ldap_entry, user_dn):
pass
......@@ -39,4 +40,8 @@ def provide_request_body(ldap_entry):
if attribute in ldap_entry:
json_body[attribute] = ldap_entry[attribute]
return json.dumps(json_body)
def delete_private_data(dn):
delete_class = get_class('DeleteRequest', 'ldap_app.processors.dispatcher.Request')(dn)
private_attributes = getattr(settings, 'TASK_PRIVATE_ATTRIBUTES')
delete_class.run(private_attributes)
......@@ -5,7 +5,7 @@ from general.class_provider import get_class, get_function
import json
class granted:
def execute(self, user_ldap_entry):
def execute(self, user_ldap_entry, user_dn):
if not getattr(settings, 'CRUST_TASK_URL_1') == '':
json_body = provide_request_body(user_ldap_entry)
#headers = {'X-TENANT-ID': 'lui2backend', 'Authorization': 'Basic ' + base64.b64encode('crust:Unity-Grease-Cow-Sensitive-Despair-5'.encode()).decode()}
......@@ -24,11 +24,12 @@ class granted:
response = requests.post(getattr(settings, 'CRUST_TASK_URL_3'), timeout=1, data=json_body)
if response.status_code is not 200:
return response.status_code
delete_all_private_data(user_dn)
return response.status_code
class denied:
def execute(self,user_ldap_entry):
def execute(self,user_ldap_entry, user_dn):
pass
......@@ -39,4 +40,8 @@ def provide_request_body(ldap_entry):
if attribute in ldap_entry:
json_body[attribute] = ldap_entry[attribute]
return json.dumps(json_body)
def delete_all_private_data(dn):
delete_class = get_class('DeleteRequest', 'ldap_app.processors.dispatcher.Request')(dn)
delete_class.run()
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