Skip to content

Commit a4ac860

Browse files
authored
fix: deprecate the mTLS credential type (#1067)
1 parent 76dc8a1 commit a4ac860

File tree

3 files changed

+9
-140
lines changed

3 files changed

+9
-140
lines changed

src/aap_eda/core/management/commands/create_initial_data.py

Lines changed: 9 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
AUTH_TYPE_LABEL = "Event Stream Authentication Type"
3535
SIGNATURE_ENCODING_LABEL = "Signature Encoding"
3636
HTTP_HEADER_LABEL = "HTTP Header Key"
37+
DEPRECATED_CREDENTIAL_KINDS = ["mtls"]
3738
# FIXME(cutwater): Role descriptions were taken from the RBAC design document
3839
# and must be updated.
3940
ORG_ROLES = [
@@ -640,39 +641,6 @@
640641
],
641642
}
642643

643-
EVENT_STREAM_MTLS_INPUTS = {
644-
"fields": [
645-
{
646-
"id": "auth_type",
647-
"label": AUTH_TYPE_LABEL,
648-
"type": "string",
649-
"default": "mtls",
650-
"hidden": True,
651-
},
652-
{
653-
"id": "subject",
654-
"label": "Certificate Subject",
655-
"type": "string",
656-
"help_text": (
657-
"The Subject from Certificate compliant with RFC 2253."
658-
"This is optional and can be used to check the subject "
659-
"defined in the certificate."
660-
),
661-
},
662-
{
663-
"id": "http_header_key",
664-
"label": HTTP_HEADER_LABEL,
665-
"type": "string",
666-
"default": "Subject",
667-
"help_text": (
668-
"The NGINX Server passes the certificate subject using "
669-
"this HTTP header"
670-
),
671-
"hidden": True,
672-
},
673-
],
674-
"required": ["auth_type", "http_header_key"],
675-
}
676644

677645
EVENT_STREAM_GITLAB_INPUTS = {
678646
"fields": [
@@ -989,20 +957,6 @@
989957
"the signature."
990958
),
991959
},
992-
{
993-
"name": enums.EventStreamCredentialType.MTLS,
994-
"namespace": "event_stream",
995-
"kind": "mtls",
996-
"inputs": EVENT_STREAM_MTLS_INPUTS,
997-
"injectors": {},
998-
"managed": True,
999-
"description": (
1000-
"Credential for Event Streams that use mutual TLS. "
1001-
"The Certificate is installed in the Web Server and "
1002-
"we can optionally validate the Subject defined in the "
1003-
"Certificate."
1004-
),
1005-
},
1006960
{
1007961
"name": enums.CustomEventStreamCredentialType.GITLAB,
1008962
"namespace": "event_stream",
@@ -1088,8 +1042,16 @@ def handle(self, *args, **options):
10881042
self._copy_scm_credentials()
10891043
self._create_org_roles()
10901044
self._create_obj_roles()
1045+
self._remove_deprecated_credential_kinds()
10911046
enable_redis_prefix()
10921047

1048+
def _remove_deprecated_credential_kinds(self):
1049+
"""Remove old credential types which are deprecated."""
1050+
for credential_type in models.CredentialType.objects.filter(
1051+
kind__in=DEPRECATED_CREDENTIAL_KINDS
1052+
).all():
1053+
credential_type.delete()
1054+
10931055
def _preload_credential_types(self):
10941056
for credential_type in populate_credential_types(CREDENTIAL_TYPES):
10951057
self.stdout.write(

tests/integration/api/test_event_stream.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -169,21 +169,6 @@ def test_fetching_event_stream_credential(
169169
@pytest.mark.parametrize(
170170
("inputs", "cred_type", "settings_key", "error_msg"),
171171
[
172-
(
173-
{
174-
"auth_type": "mtls",
175-
"subject": "Subject",
176-
"http_header_key": "Subject",
177-
},
178-
enums.EventStreamCredentialType.MTLS.value,
179-
"EVENT_STREAM_MTLS_BASE_URL",
180-
(
181-
"EventStream of type mTLS Event Stream cannot be "
182-
"used because EVENT_STREAM_MTLS_BASE_URL is "
183-
"not configured. "
184-
"Please check with your site administrator."
185-
),
186-
),
187172
(
188173
{
189174
"auth_type": "basic",

tests/integration/api/test_event_stream_mtls.py

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)