Skip to content
Snippets Groups Projects
Verified Commit 055c0da1 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

feat: add management command and Makefile target to delete OIDC clients

Closes #219
parent a3592b7d
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,9 @@ create_oidc_client.dashboard:
create_oidc_client.tank:
$(POETRY_RUN_MANAGE) create_oidc_client tank confidential --client-id ${TANK_OIDC_CLIENT_ID} --client-secret ${TANK_OIDC_CLIENT_SECRET} -r "code" -u ${TANK_CALLBACK_BASE_URL}/tank/auth/oidc/callback
delete_oidc_clients:
$(POETRY_RUN_MANAGE) delete_oidc_clients dashboard tank
initialize: migrate collectstatic create_oidc_client.dashboard create_oidc_client.tank addpermissions
$(POETRY_RUN_MANAGE) createsuperuser --no-input
$(POETRY_RUN_MANAGE) creatersakey
......
from oidc_provider.models import Client
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = "Deletes OIDC clients"
def add_arguments(self, parser):
parser.add_argument(
"name",
help="The name(s) of the OIDC client(s) to delete",
nargs="*",
type=str,
)
def handle(self, *args, **options):
try:
count, _ = Client.objects.filter(name__in=options["name"]).delete()
except Exception:
self.stdout.write(self.style.ERROR("Failed to delete OIDC clients"))
else:
if count > 0:
self.stdout.write(self.style.SUCCESS(f"Deleted {str(count)} OIDC clients"))
else:
self.stdout.write(self.style.WARNING("No OIDC clients to delete"))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment