chore(kanidm): Rename client to klient

This commit is contained in:
Tom Hubrecht 2024-09-26 13:31:40 +02:00
parent b33f13db30
commit be0cf4c0f5
Signed by: thubrecht
SSH key fingerprint: SHA256:r+nK/SIcWlJ0zFZJGHtlAoRwq1Rm+WcKAm5ADYMoQPc
4 changed files with 14 additions and 14 deletions

View file

@ -3,13 +3,13 @@ from django.core.exceptions import ValidationError
from django.forms import BooleanField, CharField, EmailField, forms from django.forms import BooleanField, CharField, EmailField, forms
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from shared.kanidm import client from shared.kanidm import klient
@async_to_sync @async_to_sync
async def name_validator(value: str) -> None: async def name_validator(value: str) -> None:
try: try:
await client.person_account_get(value) await klient.person_account_get(value)
except ValueError: except ValueError:
return return

View file

@ -13,7 +13,7 @@ from django.utils.translation import gettext_lazy as _
from kanidm.exceptions import NoMatchingEntries from kanidm.exceptions import NoMatchingEntries
from kanidm.models.person import Person from kanidm.models.person import Person
from shared.kanidm import client from shared.kanidm import klient
ADMIN_GROUP = "dgnum_admins@sso.dgnum.eu" ADMIN_GROUP = "dgnum_admins@sso.dgnum.eu"
@ -159,10 +159,10 @@ class User(AbstractUser):
@async_to_sync @async_to_sync
async def kanidm(self) -> Optional[KanidmProfile]: async def kanidm(self) -> Optional[KanidmProfile]:
try: try:
radius_data = (await client.get_radius_token(self.username)).data radius_data = (await klient.get_radius_token(self.username)).data
return KanidmProfile( 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"), radius_secret=radius_data and radius_data.get("secret"),
) )
except NoMatchingEntries: except NoMatchingEntries:

View file

@ -16,7 +16,7 @@ from django.views.generic.detail import SingleObjectMixin
from dgsi.forms import CreateKanidmAccountForm, CreateSelfAccountForm from dgsi.forms import CreateKanidmAccountForm, CreateSelfAccountForm
from dgsi.mixins import StaffRequiredMixin from dgsi.mixins import StaffRequiredMixin
from dgsi.models import Bylaws, Service, Statutes, User from dgsi.models import Bylaws, Service, Statutes, User
from shared.kanidm import client from shared.kanidm import klient
class Link(NamedTuple): class Link(NamedTuple):
@ -122,13 +122,13 @@ class CreateSelfAccountView(AccessMixin, SuccessMessageMixin, FormView):
u = User.from_request(self.request) u = User.from_request(self.request)
# Create the base account # 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 # 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 # 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}" f"/v1/person/{u.username}/_credential/_update_intent/{ttl}"
) )
@ -228,17 +228,17 @@ class CreateKanidmAccountView(StaffRequiredMixin, SuccessMessageMixin, FormView)
d = form.cleaned_data d = form.cleaned_data
# Create the base account # 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 # 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 necessary, add the user to the active members group
if d["active"]: 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 # 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}" f"/v1/person/{d['name']}/_credential/_update_intent/{ttl}"
) )

View file

@ -3,6 +3,6 @@ from loadcredential import Credentials
credentials = Credentials(env_prefix="DGSI_") credentials = Credentials(env_prefix="DGSI_")
client = KanidmClient( klient = KanidmClient(
uri=credentials["KANIDM_URI"], token=credentials["KANIDM_AUTH_TOKEN"] uri=credentials["KANIDM_URI"], token=credentials["KANIDM_AUTH_TOKEN"]
) )