diff --git a/authentik/crypto/api.py b/authentik/crypto/api.py index 6f14fc115..539e3c93e 100644 --- a/authentik/crypto/api.py +++ b/authentik/crypto/api.py @@ -1,4 +1,6 @@ """Crypto API Views""" +from typing import Optional + from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.serialization import load_pem_private_key from cryptography.x509 import load_pem_x509_certificate @@ -31,6 +33,7 @@ class CertificateKeyPairSerializer(ModelSerializer): cert_expiry = DateTimeField(source="certificate.not_valid_after", read_only=True) cert_subject = SerializerMethodField() private_key_available = SerializerMethodField() + private_key_type = SerializerMethodField() certificate_download_url = SerializerMethodField() private_key_download_url = SerializerMethodField() @@ -43,6 +46,13 @@ class CertificateKeyPairSerializer(ModelSerializer): """Show if this keypair has a private key configured or not""" return instance.key_data != "" and instance.key_data is not None + def get_private_key_type(self, instance: CertificateKeyPair) -> Optional[str]: + """Get the private key's type, if set""" + key = instance.private_key + if key: + return key.__class__.__name__.replace("_", "").lower().replace("privatekey", "") + return None + def get_certificate_download_url(self, instance: CertificateKeyPair) -> str: """Get URL to download certificate""" return ( @@ -98,6 +108,7 @@ class CertificateKeyPairSerializer(ModelSerializer): "cert_expiry", "cert_subject", "private_key_available", + "private_key_type", "certificate_download_url", "private_key_download_url", "managed", diff --git a/schema.yml b/schema.yml index 78ac85f86..6c23ce225 100644 --- a/schema.yml +++ b/schema.yml @@ -20221,6 +20221,10 @@ components: private_key_available: type: boolean readOnly: true + private_key_type: + type: string + nullable: true + readOnly: true certificate_download_url: type: string readOnly: true @@ -20245,6 +20249,7 @@ components: - pk - private_key_available - private_key_download_url + - private_key_type CertificateKeyPairRequest: type: object description: CertificateKeyPair Serializer diff --git a/web/src/pages/providers/oauth2/OAuth2ProviderForm.ts b/web/src/pages/providers/oauth2/OAuth2ProviderForm.ts index cf42b3dcb..9af90b8fc 100644 --- a/web/src/pages/providers/oauth2/OAuth2ProviderForm.ts +++ b/web/src/pages/providers/oauth2/OAuth2ProviderForm.ts @@ -195,7 +195,7 @@ ${this.instance?.redirectUris} - ${key.name} + ${key.name} (${key.privateKeyType?.toUpperCase()}) `; }); }),