From be0cf4c0f5ee5f806f3b94ab0c0ef66ffbef5f0f Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Thu, 26 Sep 2024 13:31:40 +0200 Subject: [PATCH] chore(kanidm): Rename client to klient --- src/dgsi/forms.py | 4 ++-- src/dgsi/models.py | 6 +++--- src/dgsi/views.py | 16 ++++++++-------- src/shared/kanidm.py | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/dgsi/forms.py b/src/dgsi/forms.py index 404328c..1f5e474 100644 --- a/src/dgsi/forms.py +++ b/src/dgsi/forms.py @@ -3,13 +3,13 @@ from django.core.exceptions import ValidationError from django.forms import BooleanField, CharField, EmailField, forms from django.utils.translation import gettext_lazy as _ -from shared.kanidm import client +from shared.kanidm import klient @async_to_sync async def name_validator(value: str) -> None: try: - await client.person_account_get(value) + await klient.person_account_get(value) except ValueError: return diff --git a/src/dgsi/models.py b/src/dgsi/models.py index a851d3e..54a8e7c 100644 --- a/src/dgsi/models.py +++ b/src/dgsi/models.py @@ -13,7 +13,7 @@ from django.utils.translation import gettext_lazy as _ from kanidm.exceptions import NoMatchingEntries from kanidm.models.person import Person -from shared.kanidm import client +from shared.kanidm import klient ADMIN_GROUP = "dgnum_admins@sso.dgnum.eu" @@ -159,10 +159,10 @@ class User(AbstractUser): @async_to_sync async def kanidm(self) -> Optional[KanidmProfile]: try: - radius_data = (await client.get_radius_token(self.username)).data + radius_data = (await klient.get_radius_token(self.username)).data return KanidmProfile( - person=(await client.person_account_get(self.username)), + person=(await klient.person_account_get(self.username)), radius_secret=radius_data and radius_data.get("secret"), ) except NoMatchingEntries: diff --git a/src/dgsi/views.py b/src/dgsi/views.py index c842073..623b104 100644 --- a/src/dgsi/views.py +++ b/src/dgsi/views.py @@ -16,7 +16,7 @@ from django.views.generic.detail import SingleObjectMixin from dgsi.forms import CreateKanidmAccountForm, CreateSelfAccountForm from dgsi.mixins import StaffRequiredMixin from dgsi.models import Bylaws, Service, Statutes, User -from shared.kanidm import client +from shared.kanidm import klient class Link(NamedTuple): @@ -122,13 +122,13 @@ class CreateSelfAccountView(AccessMixin, SuccessMessageMixin, FormView): u = User.from_request(self.request) # Create the base account - await client.person_account_create(u.username, d["displayname"]) + await klient.person_account_create(u.username, d["displayname"]) # Update the information - await client.person_account_update(u.username, mail=[d["mail"]]) + await klient.person_account_update(u.username, mail=[d["mail"]]) # FIXME: Will maybe change when kanidm gets its shit together and switches to POST - r = await client.call_get( + r = await klient.call_get( f"/v1/person/{u.username}/_credential/_update_intent/{ttl}" ) @@ -228,17 +228,17 @@ class CreateKanidmAccountView(StaffRequiredMixin, SuccessMessageMixin, FormView) d = form.cleaned_data # Create the base account - await client.person_account_create(d["name"], d["displayname"]) + await klient.person_account_create(d["name"], d["displayname"]) # Update the information - await client.person_account_update(d["name"], mail=[d["mail"]]) + await klient.person_account_update(d["name"], mail=[d["mail"]]) # If necessary, add the user to the active members group if d["active"]: - await client.group_add_members("dgnum_members", [d["name"]]) + await klient.group_add_members("dgnum_members", [d["name"]]) # FIXME: Will maybe change when kanidm gets its shit together and switches to POST - r = await client.call_get( + r = await klient.call_get( f"/v1/person/{d['name']}/_credential/_update_intent/{ttl}" ) diff --git a/src/shared/kanidm.py b/src/shared/kanidm.py index 32a77e1..3102da4 100644 --- a/src/shared/kanidm.py +++ b/src/shared/kanidm.py @@ -3,6 +3,6 @@ from loadcredential import Credentials credentials = Credentials(env_prefix="DGSI_") -client = KanidmClient( +klient = KanidmClient( uri=credentials["KANIDM_URI"], token=credentials["KANIDM_AUTH_TOKEN"] )