Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
misc: rename certificate template to certificate policy: frontend, docs and BDD test
Carlos Monastyrskia20c05a94ec1
diff --git a/README.md b/README.mdindex 6a46a1f5b7..96a43822e7 100644--- a/README.md+++ b/README.md@@ -62,7 +62,7 @@ We're on a mission to make security tooling more accessible to everyone, not jusCA hierarchy directly within Infisical.- **[External CA](https://infisical.com/docs/documentation/platform/pki/ca/external-ca)**: Integrate with third-party certificate authorities such as Let’s Encrypt, DigiCert, Microsoft AD CS, and more to leverage existing PKI infrastructureor issue publicly trusted certificates.-- **[Certificate Lifecycle Management](https://infisical.com/docs/documentation/platform/pki/certificates/overview)**: Create certificate [profiles](https://infisical.com/docs/documentation/platform/pki/certificates/profiles) and [templates](https://infisical.com/docs/documentation/platform/pki/certificates/templates) to control how certificates are issued, including [enrollment methods](https://infisical.com/docs/documentation/platform/pki/enrollment-methods/overview) such as API, ACME, or EST. Manage the full lifecycle from issuance to renewal and [revocation](https://infisical.com/docs/documentation/platform/pki/certificates/certificates#guide-to-revoking-certificates) with CRL and inventory tracking.+- **[Certificate Lifecycle Management](https://infisical.com/docs/documentation/platform/pki/certificates/overview)**: Create certificate [profiles](https://infisical.com/docs/documentation/platform/pki/certificates/profiles) and [policies](https://infisical.com/docs/documentation/platform/pki/certificates/policies) to control how certificates are issued, including [enrollment methods](https://infisical.com/docs/documentation/platform/pki/enrollment-methods/overview) such as API, ACME, or EST. Manage the full lifecycle from issuance to renewal and [revocation](https://infisical.com/docs/documentation/platform/pki/certificates/certificates#guide-to-revoking-certificates) with CRL and inventory tracking.- **[Certificate Syncs](https://infisical.com/docs/documentation/platform/pki/certificate-syncs/overview)**: Sync certificates to external platforms like [AWS Certificate Manager](https://infisical.com/docs/documentation/platform/pki/certificate-syncs/aws-certificate-manager) and [Azure Key Vault](https://infisical.com/docs/documentation/platform/pki/certificate-syncs/azure-key-vault).- **[Alerting](https://infisical.com/docs/documentation/platform/pki/alerting)**: Configure alerting for expiring CA and end-entity certificates.diff --git a/backend/bdd/features/environment.py b/backend/bdd/features/environment.pyindex 8ed1410e01..e3724396de 100644--- a/backend/bdd/features/environment.py+++ b/backend/bdd/features/environment.py@@ -20,7 +20,7 @@ BASE_URL = os.environ.get("INFISICAL_API_URL", "http://localhost:8080")PEBBLE_URL = os.environ.get("PEBBLE_URL", "https://pebble:14000/dir")PROJECT_ID = os.environ.get("PROJECT_ID")CERT_CA_ID = os.environ.get("CERT_CA_ID")-CERT_TEMPLATE_ID = os.environ.get("CERT_TEMPLATE_ID")+CERT_POLICY_ID = os.environ.get("CERT_POLICY_ID")AUTH_TOKEN = os.environ.get("INFISICAL_TOKEN")BOOTSTRAP_INFISICAL = int(os.environ.get("BOOTSTRAP_INFISICAL", 0))TECHNITIUM_URL = os.environ.get("TECHNITIUM_URL", "http://localhost:5380")@@ -115,13 +115,13 @@ def bootstrap_infisical(context: Context):body = resp.json()ca = body- cert_template_slug = faker.slug()+ cert_policy_slug = faker.slug()resp = client.post(- "/api/v1/cert-manager/certificate-templates",+ "/api/v1/cert-manager/certificate-policies",headers=headers,json={"projectId": project["id"],- "name": cert_template_slug,+ "name": cert_policy_slug,"description": "","subject": [{"type": "common_name", "allowed": ["*"]}],"sans": [{"type": "dns_name", "allowed": ["*"]}],@@ -173,14 +173,14 @@ def bootstrap_infisical(context: Context):)resp.raise_for_status()body = resp.json()- cert_template = body["certificateTemplate"]+ cert_policy = body["certificatePolicy"]bootstrap_result = dict(org=org,user=user,project=project,ca=ca,- cert_template=cert_template,+ cert_policy=cert_policy,auth_token=auth_token,)bootstrap_result_file.write_text(json.dumps(bootstrap_result))@@ -200,14 +200,14 @@ def before_all(context: Context):vars = base_vars | {"PROJECT_ID": details["project"]["id"],"CERT_CA_ID": details["ca"]["id"],- "CERT_TEMPLATE_ID": details["cert_template"]["id"],+ "CERT_POLICY_ID": details["cert_policy"]["id"],"AUTH_TOKEN": details["auth_token"],}else:vars = base_vars | {"PROJECT_ID": PROJECT_ID,"CERT_CA_ID": CERT_CA_ID,- "CERT_TEMPLATE_ID": CERT_TEMPLATE_ID,+ "CERT_POLICY_ID": CERT_POLICY_ID,"AUTH_TOKEN": AUTH_TOKEN,}context._initial_vars = varsdiff --git a/backend/bdd/features/pki/acme/access-control.feature b/backend/bdd/features/pki/acme/access-control.featureindex 053127077a..de68970f9d 100644--- a/backend/bdd/features/pki/acme/access-control.feature+++ b/backend/bdd/features/pki/acme/access-control.feature@@ -104,7 +104,7 @@ Feature: Access Control"description": "","enrollmentType": "acme","caId": "{CERT_CA_ID}",- "certificateTemplateId": "{CERT_TEMPLATE_ID}",+ "certificatePolicyId": "{CERT_POLICY_ID}","acmeConfig": {}}"""@@ -185,7 +185,7 @@ Feature: Access Control"description": "","enrollmentType": "acme","caId": "{CERT_CA_ID}",- "certificateTemplateId": "{CERT_TEMPLATE_ID}",+ "certificatePolicyId": "{CERT_POLICY_ID}","acmeConfig": {}}"""diff --git a/backend/bdd/features/pki/acme/cert-profile.feature b/backend/bdd/features/pki/acme/cert-profile.featureindex 4c3b84ab96..d6b9679cfb 100644--- a/backend/bdd/features/pki/acme/cert-profile.feature+++ b/backend/bdd/features/pki/acme/cert-profile.feature@@ -11,7 +11,7 @@ Feature: ACME Cert Profile"description": "","enrollmentType": "acme","caId": "{CERT_CA_ID}",- "certificateTemplateId": "{CERT_TEMPLATE_ID}",+ "certificatePolicyId": "{CERT_POLICY_ID}","acmeConfig": {}}"""@@ -19,7 +19,7 @@ Feature: ACME Cert ProfileAnd the value response with jq ".certificateProfile.id" should be presentAnd the value response with jq ".certificateProfile.slug" should be equal to "{profile_slug}"And the value response with jq ".certificateProfile.caId" should be equal to "{CERT_CA_ID}"- And the value response with jq ".certificateProfile.certificateTemplateId" should be equal to "{CERT_TEMPLATE_ID}"+ And the value response with jq ".certificateProfile.certificatePolicyId" should be equal to "{CERT_POLICY_ID}"And the value response with jq ".certificateProfile.enrollmentType" should be equal to "acme"Scenario: Reveal EAB secret@@ -33,7 +33,7 @@ Feature: ACME Cert Profile"description": "","enrollmentType": "acme","caId": "{CERT_CA_ID}",- "certificateTemplateId": "{CERT_TEMPLATE_ID}",+ "certificatePolicyId": "{CERT_POLICY_ID}","acmeConfig": {}}"""diff --git a/backend/bdd/features/pki/acme/external-ca.feature b/backend/bdd/features/pki/acme/external-ca.featureindex 5a2cef0ccb..a200cb4f62 100644--- a/backend/bdd/features/pki/acme/external-ca.feature+++ b/backend/bdd/features/pki/acme/external-ca.feature@@ -19,7 +19,7 @@ Feature: External CA}"""Then I memorize ext_ca with jq ".id" as ext_ca_id- Given I create a certificate template with the following config as cert_template+ Given I create a certificate policy with the following config as cert_policy"""{"subject": [@@ -86,8 +86,8 @@ Feature: External CA}}"""- Then I memorize cert_template with jq ".certificateTemplate.id" as cert_template_id- Given I create an ACME profile with ca {ext_ca_id} and template {cert_template_id} as "acme_profile"+ Then I memorize cert_policy with jq ".certificatePolicy.id" as cert_policy_id+ Given I create an ACME profile with ca {ext_ca_id} and policy {cert_policy_id} as "acme_profile"When I have an ACME client connecting to "{BASE_URL}/api/v1/cert-manager/acme/profiles/{acme_profile.id}/directory"Then I register a new ACME account with email [email protected] and EAB key id "{acme_profile.eab_kid}" with secret "{acme_profile.eab_secret}" as acme_accountWhen I create certificate signing request as csr@@ -202,7 +202,7 @@ Feature: External CA}"""Then I memorize ext_ca with jq ".id" as ext_ca_id- Given I create a certificate template with the following config as cert_template+ Given I create a certificate policy with the following config as cert_policy"""{"subject": [@@ -269,8 +269,8 @@ Feature: External CA}}"""- Then I memorize cert_template with jq ".certificateTemplate.id" as cert_template_id- Given I create an ACME profile with ca {ext_ca_id} and template {cert_template_id} as "acme_profile"+ Then I memorize cert_policy with jq ".certificatePolicy.id" as cert_policy_id+ Given I create an ACME profile with ca {ext_ca_id} and policy {cert_policy_id} as "acme_profile"When I have an ACME client connecting to "{BASE_URL}/api/v1/cert-manager/acme/profiles/{acme_profile.id}/directory"Then I register a new ACME account with email [email protected] and EAB key id "{acme_profile.eab_kid}" with secret "{acme_profile.eab_secret}" as acme_accountWhen I create certificate signing request as csr@@ -370,7 +370,7 @@ Feature: External CA| {"COMMON_NAME": "localhost"} || {} |- Scenario Outline: Issue a certificate with bad CSR names disallowed by the template+ Scenario Outline: Issue a certificate with bad CSR names disallowed by the policyGiven I create a Cloudflare connection as cloudflareThen I memorize cloudflare with jq ".appConnection.id" as app_conn_idGiven I create a external ACME CA with the following config as ext_ca@@ -388,7 +388,7 @@ Feature: External CA}"""Then I memorize ext_ca with jq ".id" as ext_ca_id- Given I create a certificate template with the following config as cert_template+ Given I create a certificate policy with the following config as cert_policy"""{"subject": [@@ -455,8 +455,8 @@ Feature: External CA}}"""- Then I memorize cert_template with jq ".certificateTemplate.id" as cert_template_id- Given I create an ACME profile with ca {ext_ca_id} and template {cert_template_id} as "acme_profile"+ Then I memorize cert_policy with jq ".certificatePolicy.id" as cert_policy_id+ Given I create an ACME profile with ca {ext_ca_id} and policy {cert_policy_id} as "acme_profile"When I have an ACME client connecting to "{BASE_URL}/api/v1/cert-manager/acme/profiles/{acme_profile.id}/directory"Then I register a new ACME account with email [email protected] and EAB key id "{acme_profile.eab_kid}" with secret "{acme_profile.eab_secret}" as acme_accountWhen I create certificate signing request as csr@@ -544,7 +544,7 @@ Feature: External CA| {"COMMON_NAME": "example.com"} | ["infisical.com", "localhost"] | Invalid CSR: dns_name SAN value 'localhost' is not in allowed values list |- Scenario Outline: Issue a certificate with algorithms disallowed by the template+ Scenario Outline: Issue a certificate with algorithms disallowed by the policyGiven I create a Cloudflare connection as cloudflareThen I memorize cloudflare with jq ".appConnection.id" as app_conn_idGiven I create a external ACME CA with the following config as ext_ca@@ -562,7 +562,7 @@ Feature: External CA}"""Then I memorize ext_ca with jq ".id" as ext_ca_id- Given I create a certificate template with the following config as cert_template+ Given I create a certificate policy with the following config as cert_policy"""{"subject": [@@ -619,8 +619,8 @@ Feature: External CA}}"""- Then I memorize cert_template with jq ".certificateTemplate.id" as cert_template_id- Given I create an ACME profile with ca {ext_ca_id} and template {cert_template_id} as "acme_profile"+ Then I memorize cert_policy with jq ".certificatePolicy.id" as cert_policy_id+ Given I create an ACME profile with ca {ext_ca_id} and policy {cert_policy_id} as "acme_profile"When I have an ACME client connecting to "{BASE_URL}/api/v1/cert-manager/acme/profiles/{acme_profile.id}/directory"Then I register a new ACME account with email [email protected] and EAB key id "{acme_profile.eab_kid}" with secret "{acme_profile.eab_secret}" as acme_accountWhen I create certificate signing request as csr@@ -703,15 +703,15 @@ Feature: External CAExamples:| allowed_alg | allowed_signature | key_type | hash_type | err_detail |- | RSA-4096 | SHA512-RSA | RSA-2048 | SHA512 | Invalid CSR: Key algorithm 'RSA_2048' is not allowed by template policy |- | RSA-4096 | SHA512-RSA | RSA-3072 | SHA512 | Invalid CSR: Key algorithm 'RSA_3072' is not allowed by template policy |- | RSA-4096 | ECDSA-SHA512 | ECDSA-P256 | SHA512 | Invalid CSR: Key algorithm 'EC_prime256v1' is not allowed by template policy |- | RSA-4096 | ECDSA-SHA512 | ECDSA-P384 | SHA512 | Invalid CSR: Key algorithm 'EC_secp384r1' is not allowed by template policy |- | RSA-4096 | ECDSA-SHA512 | ECDSA-P521 | SHA512 | Invalid CSR: Key algorithm 'EC_secp521r1' is not allowed by template policy |- | RSA-2048 | SHA512-RSA | RSA-2048 | SHA384 | Invalid CSR: Signature algorithm 'RSA-SHA384' is not allowed by template policy |- | RSA-2048 | SHA512-RSA | RSA-2048 | SHA256 | Invalid CSR: Signature algorithm 'RSA-SHA256' is not allowed by template policy |- | ECDSA-P256 | SHA512-RSA | ECDSA-P256 | SHA256 | Invalid CSR: Signature algorithm 'ECDSA-SHA256' is not allowed by template policy |- | ECDSA-P384 | SHA512-RSA | ECDSA-P384 | SHA256 | Invalid CSR: Signature algorithm 'ECDSA-SHA256' is not allowed by template policy |- | ECDSA-P521 | SHA512-RSA | ECDSA-P521 | SHA256 | Invalid CSR: Signature algorithm 'ECDSA-SHA256' is not allowed by template policy |- | RSA-2048 | SHA512-RSA | RSA-2048 | SHA256 | Invalid CSR: Signature algorithm 'RSA-SHA256' is not allowed by template policy |- | RSA-2048 | SHA512-RSA | RSA-4096 | SHA256 | Invalid CSR: Signature algorithm 'RSA-SHA256' is not allowed by template policy, Key algorithm 'RSA_4096' is not allowed by template policy |+ | RSA-4096 | SHA512-RSA | RSA-2048 | SHA512 | Invalid CSR: Key algorithm 'RSA_2048' is not allowed by policy |+ | RSA-4096 | SHA512-RSA | RSA-3072 | SHA512 | Invalid CSR: Key algorithm 'RSA_3072' is not allowed by policy |+ | RSA-4096 | ECDSA-SHA512 | ECDSA-P256 | SHA512 | Invalid CSR: Key algorithm 'EC_prime256v1' is not allowed by policy |+ | RSA-4096 | ECDSA-SHA512 | ECDSA-P384 | SHA512 | Invalid CSR: Key algorithm 'EC_secp384r1' is not allowed by policy |+ | RSA-4096 | ECDSA-SHA512 | ECDSA-P521 | SHA512 | Invalid CSR: Key algorithm 'EC_secp521r1' is not allowed by policy |+ | RSA-2048 | SHA512-RSA | RSA-2048 | SHA384 | Invalid CSR: Signature algorithm 'RSA-SHA384' is not allowed by policy |+ | RSA-2048 | SHA512-RSA | RSA-2048 | SHA256 | Invalid CSR: Signature algorithm 'RSA-SHA256' is not allowed by policy |+ | ECDSA-P256 | SHA512-RSA | ECDSA-P256 | SHA256 | Invalid CSR: Signature algorithm 'ECDSA-SHA256' is not allowed by policy |+ | ECDSA-P384 | SHA512-RSA | ECDSA-P384 | SHA256 | Invalid CSR: Signature algorithm 'ECDSA-SHA256' is not allowed by policy |+ | ECDSA-P521 | SHA512-RSA | ECDSA-P521 | SHA256 | Invalid CSR: Signature algorithm 'ECDSA-SHA256' is not allowed by policy |+ | RSA-2048 | SHA512-RSA | RSA-2048 | SHA256 | Invalid CSR: Signature algorithm 'RSA-SHA256' is not allowed by policy |+ | RSA-2048 | SHA512-RSA | RSA-4096 | SHA256 | Invalid CSR: Signature algorithm 'RSA-SHA256' is not allowed by policy, Key algorithm 'RSA_4096' is not allowed by policy |diff --git a/backend/bdd/features/steps/pki_acme.py b/backend/bdd/features/steps/pki_acme.pyindex a847cbadba..78256ef597 100644--- a/backend/bdd/features/steps/pki_acme.py+++ b/backend/bdd/features/steps/pki_acme.py@@ -70,7 +70,7 @@ def step_impl(context: Context, profile_var: str):"description": "ACME Profile created by BDD test","enrollmentType": "acme","caId": context.vars["CERT_CA_ID"],- "certificateTemplateId": context.vars["CERT_TEMPLATE_ID"],+ "certificatePolicyId": context.vars["CERT_POLICY_ID"],"acmeConfig": {},},)@@ -208,17 +208,17 @@ def step_impl(context: Context, var_name: str):context.vars[var_name] = response-@given("I create a certificate template with the following config as {var_name}")+@given("I create a certificate policy with the following config as {var_name}")def step_impl(context: Context, var_name: str):jwt_token = context.vars["AUTH_TOKEN"]- template_slug = faker.slug()+ policy_slug = faker.slug()config = replace_vars(json.loads(context.text), context.vars)response = context.http_client.post(- "/api/v1/cert-manager/certificate-templates",+ "/api/v1/cert-manager/certificate-policies",headers=dict(authorization="Bearer {}".format(jwt_token)),json={"projectId": context.vars["PROJECT_ID"],- "name": template_slug,+ "name": policy_slug,"description": "",}| config,@@ -228,9 +228,9 @@ def step_impl(context: Context, var_name: str):@given(- 'I create an ACME profile with ca {ca_id} and template {template_id} as "{profile_var}"'+ 'I create an ACME profile with ca {ca_id} and policy {policy_id} as "{profile_var}"')-def step_impl(context: Context, ca_id: str, template_id: str, profile_var: str):+def step_impl(context: Context, ca_id: str, policy_id: str, profile_var: str):profile_slug = faker.slug()jwt_token = context.vars["AUTH_TOKEN"]response = context.http_client.post(@@ -242,7 +242,7 @@ def step_impl(context: Context, ca_id: str, template_id: str, profile_var: str):"description": "ACME Profile created by BDD test","enrollmentType": "acme","caId": replace_vars(ca_id, context.vars),- "certificateTemplateId": replace_vars(template_id, context.vars),+ "certificatePolicyId": replace_vars(policy_id, context.vars),"acmeConfig": {},},)@@ -280,7 +280,7 @@ def step_impl(context: Context, profile_var: str):"description": "ACME Profile created by BDD test","enrollmentType": "acme","caId": context.vars["CERT_CA_ID"],- "certificateTemplateId": context.vars["CERT_TEMPLATE_ID"],+ "certificatePolicyId": context.vars["CERT_POLICY_ID"],"acmeConfig": acme_config,},)@@ -322,7 +322,7 @@ def step_impl(context: Context, profile_var: str):"description": "ACME Profile created by BDD test","enrollmentType": "acme","caId": context.vars["CERT_CA_ID"],- "certificateTemplateId": context.vars["CERT_TEMPLATE_ID"],+ "certificatePolicyId": context.vars["CERT_POLICY_ID"],"acmeConfig": {},},)diff --git a/backend/src/db/migrations/20260112182952_rename-certificate-template-to-certificate-policy.ts b/backend/src/db/migrations/20260112182952_rename-certificate-template-to-certificate-policy.tsindex f563e35c90..fcdc714a76 100644--- a/backend/src/db/migrations/20260112182952_rename-certificate-template-to-certificate-policy.ts+++ b/backend/src/db/migrations/20260112182952_rename-certificate-template-to-certificate-policy.ts@@ -12,12 +12,6 @@ export async function up(knex: Knex): Promise<void> {t.renameColumn("certificateTemplateId", "certificatePolicyId");});}-- if (await knex.schema.hasColumn(TableName.Certificate, "certificateTemplateId")) {- await knex.schema.alterTable(TableName.Certificate, (t) => {- t.renameColumn("certificateTemplateId", "certificatePolicyId");- });- }}export async function down(knex: Knex): Promise<void> {@@ -30,10 +24,4 @@ export async function down(knex: Knex): Promise<void> {t.renameColumn("certificatePolicyId", "certificateTemplateId");});}-- if (await knex.schema.hasColumn(TableName.Certificate, "certificatePolicyId")) {- await knex.schema.alterTable(TableName.Certificate, (t) => {- t.renameColumn("certificatePolicyId", "certificateTemplateId");- });- }}diff --git a/backend/src/db/schemas/certificates.ts b/backend/src/db/schemas/certificates.tsindex 352fb3588e..8a3ae8f841 100644--- a/backend/src/db/schemas/certificates.ts+++ b/backend/src/db/schemas/certificates.ts@@ -22,7 +22,7 @@ export const CertificatesSchema = z.object({revocationReason: z.number().nullable().optional(),altNames: z.string().nullable().optional(),caCertId: z.string().uuid().nullable().optional(),- certificatePolicyId: z.string().uuid().nullable().optional(),+ certificateTemplateId: z.string().uuid().nullable().optional(),keyUsages: z.string().array().nullable().optional(),extendedKeyUsages: z.string().array().nullable().optional(),projectId: z.string(),diff --git a/backend/src/ee/services/permission/default-roles.ts b/backend/src/ee/services/permission/default-roles.tsindex fdeaadfd2a..cb6c82981e 100644--- a/backend/src/ee/services/permission/default-roles.ts+++ b/backend/src/ee/services/permission/default-roles.ts@@ -8,6 +8,7 @@ import {ProjectPermissionAuditLogsActions,ProjectPermissionCertificateActions,ProjectPermissionCertificateAuthorityActions,+ ProjectPermissionCertificatePolicyActions,ProjectPermissionCertificateProfileActions,ProjectPermissionCmekActions,ProjectPermissionCommitsActions,@@ -97,6 +98,16 @@ const buildAdminPermissionRules = () => {ProjectPermissionSub.CertificateTemplates);+ can(+ [+ ProjectPermissionCertificatePolicyActions.Read,+ ProjectPermissionCertificatePolicyActions.Create,+ ProjectPermissionCertificatePolicyActions.Edit,+ ProjectPermissionCertificatePolicyActions.Delete+ ],+ ProjectPermissionSub.CertificatePolicies+ );+can([ProjectPermissionActions.Read,@@ -503,6 +514,7 @@ const buildMemberPermissionRules = () => {// double check if all CRUD are needed for CA and Certificatescan([ProjectPermissionCertificateAuthorityActions.Read], ProjectPermissionSub.CertificateAuthorities);can([ProjectPermissionPkiTemplateActions.Read], ProjectPermissionSub.CertificateTemplates);+ can([ProjectPermissionCertificatePolicyActions.Read], ProjectPermissionSub.CertificatePolicies);can([@@ -650,6 +662,7 @@ const buildViewerPermissionRules = () => {can(ProjectPermissionCertificateAuthorityActions.Read, ProjectPermissionSub.CertificateAuthorities);can(ProjectPermissionCertificateActions.Read, ProjectPermissionSub.Certificates);can(ProjectPermissionPkiTemplateActions.Read, ProjectPermissionSub.CertificateTemplates);+ can(ProjectPermissionCertificatePolicyActions.Read, ProjectPermissionSub.CertificatePolicies);can(ProjectPermissionCmekActions.Read, ProjectPermissionSub.Cmek);can(ProjectPermissionActions.Read, ProjectPermissionSub.SshCertificates);can(ProjectPermissionActions.Read, ProjectPermissionSub.SshCertificateTemplates);diff --git a/backend/src/ee/services/permission/project-permission.ts b/backend/src/ee/services/permission/project-permission.tsindex ca944345e9..a2db3c724a 100644--- a/backend/src/ee/services/permission/project-permission.ts+++ b/backend/src/ee/services/permission/project-permission.ts@@ -117,6 +117,13 @@ export enum ProjectPermissionPkiTemplateActions {ListCerts = "list-certs"}+export enum ProjectPermissionCertificatePolicyActions {+ Read = "read",+ Create = "create",+ Edit = "edit",+ Delete = "delete"+}+export enum ProjectPermissionPkiSubscriberActions {Read = "read",Create = "create",@@ -294,6 +301,7 @@ export enum ProjectPermissionSub {PamAccounts = "pam-accounts",PamSessions = "pam-sessions",CertificateProfiles = "certificate-profiles",+ CertificatePolicies = "certificate-policies",ApprovalRequests = "approval-requests",ApprovalRequestGrants = "approval-request-grants",McpEndpoints = "mcp-endpoints",@@ -383,7 +391,7 @@ export type CertificateProfileSubjectFields = {slug: string;};-export type CertificateTemplateV2SubjectFields = {+export type CertificatePolicySubjectFields = {name: string;};@@ -528,6 +536,13 @@ export type ProjectPermissionSet =| (ForcedSubject<ProjectPermissionSub.CertificateProfiles> & CertificateProfileSubjectFields))]+ | [+ ProjectPermissionCertificatePolicyActions,+ (+ | ProjectPermissionSub.CertificatePolicies+ | (ForcedSubject<ProjectPermissionSub.CertificatePolicies> & CertificatePolicySubjectFields)+ )+ ]| [ProjectPermissionApprovalRequestActions, ProjectPermissionSub.ApprovalRequests]| [ProjectPermissionApprovalRequestGrantActions, ProjectPermissionSub.ApprovalRequestGrants];@@ -793,6 +808,22 @@ const PkiTemplateConditionSchema = z}).partial();+const CertificatePolicyConditionSchema = z+ .object({+ name: z.union([+ z.string(),+ z+ .object({+ [PermissionConditionOperators.$EQ]: PermissionConditionSchema[PermissionConditionOperators.$EQ],+ [PermissionConditionOperators.$NEQ]: PermissionConditionSchema[PermissionConditionOperators.$NEQ],+ [PermissionConditionOperators.$GLOB]: PermissionConditionSchema[PermissionConditionOperators.$GLOB],+ [PermissionConditionOperators.$IN]: PermissionConditionSchema[PermissionConditionOperators.$IN]+ })+ .partial()+ ])+ })+ .partial();+const AppConnectionConditionSchema = z.object({connectionId: z.union([@@ -1332,6 +1363,16 @@ export const ProjectPermissionV2Schema = z.discriminatedUnion("subject", ["When specified, only matching conditions will be allowed to access given resource.").optional()}),+ z.object({+ subject: z.literal(ProjectPermissionSub.CertificatePolicies).describe("The entity this permission pertains to."),+ inverted: z.boolean().optional().describe("Whether rule allows or forbids."),+ action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionCertificatePolicyActions).describe(+ "Describe what action an entity can take."+ ),+ conditions: CertificatePolicyConditionSchema.describe(+ "When specified, only matching conditions will be allowed to access given resource."+ ).optional()+ }),z.object({subject: z.literal(ProjectPermissionSub.CertificateAuthorities).describe("The entity this permission pertains to."),inverted: z.boolean().optional().describe("Whether rule allows or forbids."),diff --git a/backend/src/server/routes/v1/deprecated-certificate-template-router.ts b/backend/src/server/routes/v1/deprecated-certificate-template-router.tsindex 6737b30c02..cfb775b073 100644--- a/backend/src/server/routes/v1/deprecated-certificate-template-router.ts+++ b/backend/src/server/routes/v1/deprecated-certificate-template-router.ts@@ -46,18 +46,6 @@ export const registerDeprecatedCertificateTemplateRouter = async (server: FastifactorOrgId: req.permission.orgId});- await server.services.auditLog.createAuditLog({- ...req.auditLogInfo,- projectId: certificateTemplate.projectId,- event: {- type: EventType.GET_CERTIFICATE_TEMPLATE,- metadata: {- certificateTemplateId: certificateTemplate.id,- name: certificateTemplate.name- }- }- });-return certificateTemplate;}});@@ -110,24 +98,6 @@ export const registerDeprecatedCertificateTemplateRouter = async (server: Fastif...req.body});- await server.services.auditLog.createAuditLog({- ...req.auditLogInfo,- projectId: certificateTemplate.projectId,- event: {- type: EventType.CREATE_CERTIFICATE_TEMPLATE,- metadata: {- certificateTemplateId: certificateTemplate.id,- caId: certificateTemplate.caId,- pkiCollectionId: certificateTemplate.pkiCollectionId as string,- name: certificateTemplate.name,- commonName: certificateTemplate.commonName,- subjectAlternativeName: certificateTemplate.subjectAlternativeName,- ttl: certificateTemplate.ttl,- projectId: certificateTemplate.projectId- }- }- });-return certificateTemplate;}});@@ -179,23 +149,6 @@ export const registerDeprecatedCertificateTemplateRouter = async (server: FastifactorOrgId: req.permission.orgId});- await server.services.auditLog.createAuditLog({- ...req.auditLogInfo,- projectId: certificateTemplate.projectId,- event: {- type: EventType.UPDATE_CERTIFICATE_TEMPLATE,- metadata: {- certificateTemplateId: certificateTemplate.id,- name: certificateTemplate.name,- caId: certificateTemplate.caId,- pkiCollectionId: certificateTemplate.pkiCollectionId as string,- commonName: certificateTemplate.commonName,- subjectAlternativeName: certificateTemplate.subjectAlternativeName,- ttl: certificateTemplate.ttl- }- }- });-return certificateTemplate;}});@@ -226,18 +179,6 @@ export const registerDeprecatedCertificateTemplateRouter = async (server: FastifactorOrgId: req.permission.orgId});- await server.services.auditLog.createAuditLog({- ...req.auditLogInfo,- projectId: certificateTemplate.projectId,- event: {- type: EventType.DELETE_CERTIFICATE_TEMPLATE,- metadata: {- certificateTemplateId: certificateTemplate.id,- name: certificateTemplate.name- }- }- });-return certificateTemplate;}});diff --git a/backend/src/services/certificate-policy/certificate-policy-service.ts b/backend/src/services/certificate-policy/certificate-policy-service.tsindex 2c52516cba..7d89435798 100644--- a/backend/src/services/certificate-policy/certificate-policy-service.ts+++ b/backend/src/services/certificate-policy/certificate-policy-service.ts@@ -5,7 +5,7 @@ import RE2 from "re2";import { ActionProjectType } from "@app/db/schemas";import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";import {- ProjectPermissionPkiTemplateActions,+ ProjectPermissionCertificatePolicyActions,ProjectPermissionSub} from "@app/ee/services/permission/project-permission";import { getProcessedPermissionRules } from "@app/lib/casl/permission-filter-utils";@@ -634,8 +634,8 @@ export const certificatePolicyServiceFactory = ({});ForbiddenError.from(permission).throwUnlessCan(- ProjectPermissionPkiTemplateActions.Create,- subject(ProjectPermissionSub.CertificateTemplates, {+ ProjectPermissionCertificatePolicyActions.Create,+ subject(ProjectPermissionSub.CertificatePolicies, {name: data.name}));@@ -713,8 +713,8 @@ export const certificatePolicyServiceFactory = ({});ForbiddenError.from(permission).throwUnlessCan(- ProjectPermissionPkiTemplateActions.Edit,- subject(ProjectPermissionSub.CertificateTemplates, {+ ProjectPermissionCertificatePolicyActions.Edit,+ subject(ProjectPermissionSub.CertificatePolicies, {name: existingTemplate.name}));@@ -788,8 +788,8 @@ export const certificatePolicyServiceFactory = ({});ForbiddenError.from(permission).throwUnlessCan(- ProjectPermissionPkiTemplateActions.Read,- subject(ProjectPermissionSub.CertificateTemplates, {+ ProjectPermissionCertificatePolicyActions.Read,+ subject(ProjectPermissionSub.CertificatePolicies, {name: template.name}));@@ -828,8 +828,8 @@ export const certificatePolicyServiceFactory = ({}ForbiddenError.from(permission).throwUnlessCan(- ProjectPermissionPkiTemplateActions.Read,- subject(ProjectPermissionSub.CertificateTemplates, {+ ProjectPermissionCertificatePolicyActions.Read,+ subject(ProjectPermissionSub.CertificatePolicies, {name: template.name}));@@ -868,14 +868,14 @@ export const certificatePolicyServiceFactory = ({});ForbiddenError.from(permission).throwUnlessCan(- ProjectPermissionPkiTemplateActions.Read,- ProjectPermissionSub.CertificateTemplates+ ProjectPermissionCertificatePolicyActions.Read,+ ProjectPermissionSub.CertificatePolicies);const processedRules = getProcessedPermissionRules(permission,- ProjectPermissionPkiTemplateActions.Read,- ProjectPermissionSub.CertificateTemplates+ ProjectPermissionCertificatePolicyActions.Read,+ ProjectPermissionSub.CertificatePolicies);const policies = await certificatePolicyDAL.findByProjectId(projectId, { offset, limit, search }, processedRules);@@ -915,8 +915,8 @@ export const certificatePolicyServiceFactory = ({});ForbiddenError.from(permission).throwUnlessCan(- ProjectPermissionPkiTemplateActions.Delete,- subject(ProjectPermissionSub.CertificateTemplates, {+ ProjectPermissionCertificatePolicyActions.Delete,+ subject(ProjectPermissionSub.CertificatePolicies, {name: template.name}));diff --git a/docs/api-reference/endpoints/certificate-policies/create.mdx b/docs/api-reference/endpoints/certificate-policies/create.mdxnew file mode 100644index 0000000000..655b3f4aee--- /dev/null+++ b/docs/api-reference/endpoints/certificate-policies/create.mdx@@ -0,0 +1,5 @@+---+title: "Create"+openapi: "POST /api/v1/cert-manager/certificate-policies"+---+diff --git a/docs/api-reference/endpoints/certificate-policies/delete.mdx b/docs/api-reference/endpoints/certificate-policies/delete.mdxnew file mode 100644index 0000000000..a4c747c7c1--- /dev/null+++ b/docs/api-reference/endpoints/certificate-policies/delete.mdx@@ -0,0 +1,5 @@+---+title: "Delete"+openapi: "DELETE /api/v1/cert-manager/certificate-policies/{id}"+---+diff --git a/docs/api-reference/endpoints/certificate-policies/get-by-id.mdx b/docs/api-reference/endpoints/certificate-policies/get-by-id.mdxnew file mode 100644index 0000000000..4a143aac62--- /dev/null+++ b/docs/api-reference/endpoints/certificate-policies/get-by-id.mdx@@ -0,0 +1,5 @@+---+title: "Get by ID"+openapi: "GET /api/v1/cert-manager/certificate-policies/{id}"+---+diff --git a/docs/api-reference/endpoints/certificate-policies/list.mdx b/docs/api-reference/endpoints/certificate-policies/list.mdxnew file mode 100644index 0000000000..9c8dfc5789--- /dev/null+++ b/docs/api-reference/endpoints/certificate-policies/list.mdx@@ -0,0 +1,5 @@+---+title: "List"+openapi: "GET /api/v1/cert-manager/certificate-policies"+---+diff --git a/docs/api-reference/endpoints/certificate-policies/update.mdx b/docs/api-reference/endpoints/certificate-policies/update.mdxnew file mode 100644index 0000000000..1bb0d335f8--- /dev/null+++ b/docs/api-reference/endpoints/certificate-policies/update.mdx@@ -0,0 +1,5 @@+---+title: "Update"+openapi: "PATCH /api/v1/cert-manager/certificate-policies/{id}"+---+diff --git a/docs/docs.json b/docs/docs.jsonindex d009dfc90b..ece16aa04e 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -698,7 +698,7 @@"pages": ["documentation/platform/pki/certificates/overview","documentation/platform/pki/certificates/profiles",- "documentation/platform/pki/certificates/templates",+ "documentation/platform/pki/certificates/policies","documentation/platform/pki/certificates/certificates"]},@@ -2614,13 +2614,13 @@]},{- "group": "Certificate Templates",+ "group": "Certificate Policies","pages": [- "api-reference/endpoints/certificate-templates/list",- "api-reference/endpoints/certificate-templates/create",- "api-reference/endpoints/certificate-templates/update",- "api-reference/endpoints/certificate-templates/get-by-id",- "api-reference/endpoints/certificate-templates/delete"+ "api-reference/endpoints/certificate-policies/list",+ "api-reference/endpoints/certificate-policies/create",+ "api-reference/endpoints/certificate-policies/update",+ "api-reference/endpoints/certificate-policies/get-by-id",+ "api-reference/endpoints/certificate-policies/delete"]},{diff --git a/docs/documentation/platform/pki/certificates/certificates.mdx b/docs/documentation/platform/pki/certificates/certificates.mdxindex 1f2a5b7f2b..86dfd9fed6 100644--- a/docs/documentation/platform/pki/certificates/certificates.mdx+++ b/docs/documentation/platform/pki/certificates/certificates.mdx@@ -19,7 +19,7 @@ where you can manage various aspects of its lifecycle including deployment to cl## Guide to Issuing Certificates-To [issue a certificate](/documentation/platform/pki/concepts/certificate-lifecycle#enrollment-request-%2F-issuance), you must first create a [certificate profile](/documentation/platform/pki/certificates/profiles) and a [certificate template](/documentation/platform/pki/certificates/templates) to go along with it.+To [issue a certificate](/documentation/platform/pki/concepts/certificate-lifecycle#enrollment-request-%2F-issuance), you must first create a [certificate profile](/documentation/platform/pki/certificates/profiles) and a [certificate policy](/documentation/platform/pki/certificates/policies) to go along with it.- Self-Signed Certificates: To issue a [self-signed certificate](https://en.wikipedia.org/wiki/Self-signed_certificate), you must configure the certificate profile to use the `Self-Signed` issuer type. You can then use the [API enrollment method](/documentation/platform/pki/enrollment-methods/api) to request a self-signed certificate against it.- CA-Issued Certificates: To issue a certificate from a certificate authority, you must configure the certificate profile to use the `Certificate Authority` issuer type and select the [issuing CA](/documentation/platform/pki/ca/overview) to use. You can then use one of the [enrollment methods](/documentation/platform/pki/enrollment-methods/overview) to request a certificate against it.diff --git a/docs/documentation/platform/pki/certificates/overview.mdx b/docs/documentation/platform/pki/certificates/overview.mdxindex ea559a0dff..b645dcaa02 100644--- a/docs/documentation/platform/pki/certificates/overview.mdx+++ b/docs/documentation/platform/pki/certificates/overview.mdx@@ -3,13 +3,13 @@ title: "Overview"sidebarTitle: "Overview"----To issue a certificate with Infisical, you create a certificate profile and a certificate template to go along with it. You then issue a certificate against+To issue a certificate with Infisical, you create a certificate profile and a certificate policy to go along with it. You then issue a certificate againsta specific profile depending on the enrollment method associated with it.There are three components to understand:-- [Certificate Profile](/documentation/platform/pki/certificates/profiles): A configuration set specifying how certificates should be issued under that profile including the [issuing CA](/documentation/platform/pki/ca/overview), a certificate template, and the [enrollment method](/documentation/platform/pki/enrollment-methods/overview) (such as ACME, EST, API, etc.) used to enroll certificates.+- [Certificate Profile](/documentation/platform/pki/certificates/profiles): A configuration set specifying how certificates should be issued under that profile including the [issuing CA](/documentation/platform/pki/ca/overview), a certificate policy, and the [enrollment method](/documentation/platform/pki/enrollment-methods/overview) (such as ACME, EST, API, etc.) used to enroll certificates.-- [Certificate Template](/documentation/platform/pki/certificates/templates): A policy structure specifying the permitted attributes for requested certificates including subject naming conventions, SAN fields, key usages, and extended key usages.+- [Certificate Policy](/documentation/platform/pki/certificates/policies): A policy structure specifying the permitted attributes for requested certificates including subject naming conventions, SAN fields, key usages, and extended key usages.- [Certificate](/documentation/platform/pki/certificates/certificates): The actual X.509 certificate issued for a profile. Once issued, a certificate kept track of in the certificate inventory.diff --git a/docs/documentation/platform/pki/certificates/templates.mdx b/docs/documentation/platform/pki/certificates/policies.mdxsimilarity index 53%rename from docs/documentation/platform/pki/certificates/templates.mdxrename to docs/documentation/platform/pki/certificates/policies.mdxindex b8d976961d..aaada199fe 100644--- a/docs/documentation/platform/pki/certificates/templates.mdx+++ b/docs/documentation/platform/pki/certificates/policies.mdx@@ -1,30 +1,30 @@----title: "Certificate Templates"-sidebarTitle: "Templates"+title: "Certificate Policies"+sidebarTitle: "Policies"---## Concept-A certificate template is a policy structure specifying permitted attributes for requested certificates. This includes constraints around subject naming conventions, SAN fields, key usages, and extended key usages.+A certificate policy is a policy structure specifying permitted attributes for requested certificates. This includes constraints around subject naming conventions, SAN fields, key usages, and extended key usages.-Each certificate requested against a [certificate profile](/documentation/platform/pki/certificates/profiles) is validated against the template bound to that profile. If the request fails any criteria included in the template, the certificate is not issued. This helps administrators enforce uniformity and security standards across all issued certificates.+Each certificate requested against a [certificate profile](/documentation/platform/pki/certificates/profiles) is validated against the policy bound to that profile. If the request fails any criteria included in the policy, the certificate is not issued. This helps administrators enforce uniformity and security standards across all issued certificates.-## Guide to Creating a Certificate Template+## Guide to Creating a Certificate Policy-To create a certificate template, head to your Certificate Management Project > Certificates > Certificate Templates and press **Create Template**.+To create a certificate policy, head to your Certificate Management Project > Certificate Manager > Certificate Policies and press **Create Policy**.-+-+Here's some guidance on each field:-- Template Name: A slug-friendly name for the template such as `tls-server`.-- Description: An optional description for the template.+- Policy Name: A slug-friendly name for the policy such as `tls-server`.+- Description: An optional description for the policy.- Subject Attributes: A list of common names that can be included in the certificate subject. Each row accepts a fixed value or pattern such as `example.com` or `*.example.com` and whether it is allowed or denied.- Subject Alternative Names (SANs): A list of SANs that can appear in the certificate. Each row accepts a SAN type (e.g. DNS, IP, Email, URI), a fixed value or pattern such as `example.com` or `*.example.com`, and an allow or deny flag.-- Allowed Signature Algorithms: The set of signature algorithms permitted to sign certificates under this template such as `SHA256-RSA`, `SHA512-RSA`, etc.+- Allowed Signature Algorithms: The set of signature algorithms permitted to sign certificates under this policy such as `SHA256-RSA`, `SHA512-RSA`, etc.- Allowed Key Algorithms: The set of public key algorithms permitted for certificate requests such as `RSA-2048`, `RSA-4096`, etc.- Key Usages: The cryptographic purposes of the certificate such as Digital Signature, Key Encipherment, etc.- Extended Key Usages: The higher-level intended uses of the certificate such as Server Authentication, Client Authentication, etc.-- Certificate Validity: The maximum lifetime of certificates that can be requested for certificates validated against this template. You can specify both a duration and unit (days, months, or years).+- Certificate Validity: The maximum lifetime of certificates that can be requested for certificates validated against this policy. You can specify both a duration and unit (days, months, or years).diff --git a/docs/documentation/platform/pki/certificates/profiles.mdx b/docs/documentation/platform/pki/certificates/profiles.mdxindex 1121437cf6..0ea3ff1e95 100644--- a/docs/documentation/platform/pki/certificates/profiles.mdx+++ b/docs/documentation/platform/pki/certificates/profiles.mdx@@ -5,7 +5,7 @@ sidebarTitle: "Profiles"## Concept-A certificate profile is a configuration set specifying how leaf certificates should be issued for a group of end-entities including the [issuing CA](/documentation/platform/pki/ca/overview), a [certificate template](/documentation/platform/pki/certificates/templates), and the [enrollment method](/documentation/platform/pki/enrollment-methods/overview) (e.g. ACME, EST, API, etc.) used to enroll certificates.+A certificate profile is a configuration set specifying how leaf certificates should be issued for a group of end-entities including the [issuing CA](/documentation/platform/pki/ca/overview), a [certificate policy](/documentation/platform/pki/certificates/policies), and the [enrollment method](/documentation/platform/pki/enrollment-methods/overview) (e.g. ACME, EST, API, etc.) used to enroll certificates.You typically request certificates against a certificate profile through its associated enrollment method. Each method defines its own interaction flow which you can read more about in its respective documentation.@@ -23,7 +23,7 @@ Here's some guidance on each field:- Description: An optional description for the profile.- Issuer Type: The type of issuer that should be used to issue certificates for the profile; this can be either `Certificate Authority` or `Self-Signed`. If `Self-Signed` is selected, then the profile will only support the API enrollment method and be used to issue self-signed certificates over REST API.- Issuing CA: The [issuing CA](/documentation/platform/pki/ca/overview) that should be used to issue certificates for the profile when the **Issuer Type** is set to `Certificate Authority`.-- Certificate Template: The [certificate template](/documentation/platform/pki/certificates/templates) that should be used to validate certificate requests for the profile.+- Certificate Policy: The [certificate policy](/documentation/platform/pki/certificates/policies) that should be used to validate certificate requests for the profile.- Enrollment Method: The enrollment method that should be used to enroll certificates for the profile such as ACME, EST, API, etc.Depending on which enrollment method you choose, you may be presented with additional enrollment-specific configuration fields.diff --git a/docs/documentation/platform/pki/concepts/certificate-components.mdx b/docs/documentation/platform/pki/concepts/certificate-components.mdxindex cfda3813c1..d1ca35ff13 100644--- a/docs/documentation/platform/pki/concepts/certificate-components.mdx+++ b/docs/documentation/platform/pki/concepts/certificate-components.mdx@@ -10,9 +10,9 @@ The following resources define how certificates are issued, shaped, and governed- [Certificate Authority (CA)](/documentation/platform/pki/ca/overview): The trusted entity that issues X.509 certificates. This can be an [Internal CA](/documentation/platform/pki/ca/private-ca) or an [External CA](/documentation/platform/pki/ca/external-ca) in Infisical.The former represents a fully managed CA hierarchy within Infisical, while the latter represents an external CA (e.g. [DigiCert](/documentation/platform/pki/ca/digicert), [Let's Encrypt](/documentation/platform/pki/ca/lets-encrypt), [Microsoft AD CS](/documentation/platform/pki/ca/azure-adcs), etc.) that can be integrated with Infisical.-- [Certificate Template](/documentation/platform/pki/certificates/templates): A policy structure specifying permitted attributes for requested certificates. This includes constraints around subject naming conventions, SAN fields, key usages, and extended key usages.+- [Certificate Policy](/documentation/platform/pki/certificates/policies): A policy structure specifying permitted attributes for requested certificates. This includes constraints around subject naming conventions, SAN fields, key usages, and extended key usages.-- [Certificate Profile](/documentation/platform/pki/certificates/profiles): A configuration set specifying how leaf certificates should be issued for a group of end-entities including the issuing CA, a certificate template, and the enrollment method (e.g. [ACME](/documentation/platform/pki/enrollment-methods/acme), [EST](/documentation/platform/pki/enrollment-methods/est), [API](/documentation/platform/pki/enrollment-methods/api), etc.) used to enroll certificates.+- [Certificate Profile](/documentation/platform/pki/certificates/profiles): A configuration set specifying how leaf certificates should be issued for a group of end-entities including the issuing CA, a certificate policy, and the enrollment method (e.g. [ACME](/documentation/platform/pki/enrollment-methods/acme), [EST](/documentation/platform/pki/enrollment-methods/est), [API](/documentation/platform/pki/enrollment-methods/api), etc.) used to enroll certificates.- [Certificate](/documentation/platform/pki/certificates/certificates): The actual X.509 certificate issued for a profile. Once created, it is tracked in Infisical’s certificate inventory for management, renewal, and lifecycle operations.@@ -20,11 +20,11 @@ The following resources define how certificates are issued, shaped, and governedAccess control defines who (or what) can manage certificate resources and who can issue certificates within a project. Without clear boundaries, [certificate authorities](/documentation/platform/pki/ca/overview) and issuance workflows can be misconfigured or misused.-To manage access to certificates, you assign role-based permissions at the project level. These permissions determine which certificate authorities, certificate templates, certificate profiles, and other related resources a user or machine identity can act on. For example,+To manage access to certificates, you assign role-based permissions at the project level. These permissions determine which certificate authorities, certificate policies, certificate profiles, and other related resources a user or machine identity can act on. For example,you may want to:- Have specific teams(s) manage your internal CA hierarchy or external CA integration configuration and have separate team(s) configure certificate profiles for requested certificates.-- Limit which teams can manage policies defined on certificate templates.+- Limit which teams can manage certificate policies.- Have specific end-entities (e.g. servers, devices, users) request certificates from specific certificate profiles.This model follows the [principle of least privilege](https://en.wikipedia.org/wiki/Principle_of_least_privilege) so that each user or machine identity can manage or issue only the certificate resources it is responsible for and nothing more.diff --git a/docs/documentation/platform/pki/enrollment-methods/api.mdx b/docs/documentation/platform/pki/enrollment-methods/api.mdxindex c7dff2a271..72762cdb4b 100644--- a/docs/documentation/platform/pki/enrollment-methods/api.mdx+++ b/docs/documentation/platform/pki/enrollment-methods/api.mdx@@ -67,7 +67,7 @@ Here, select the certificate profile from step 1 that will be used to issue the--data-raw '{"projectId": "<project-id>","caId": "<ca-id>",- "certificateTemplateId": "<certificate-template-id>",+ "certificatePolicyId": "<certificate-policy-id>","slug": "my-api-profile","description": "Certificate profile for API enrollment","enrollmentType": "API",@@ -86,7 +86,7 @@ Here, select the certificate profile from step 1 that will be used to issue the"id": "550e8400-e29b-41d4-a716-446655440000","projectId": "65f0a4b0-c123-4567-8901-23456789abcd","caId": "550e8400-e29b-41d4-a716-446655440000",- "certificateTemplateId": "660f1234-e29b-41d4-a716-446655440001",+ "certificatePolicyId": "660f1234-e29b-41d4-a716-446655440001","slug": "my-api-profile","description": "Certificate profile for API enrollment","enrollmentType": "API",diff --git a/docs/documentation/platform/pki/guides/request-cert-acme.mdx b/docs/documentation/platform/pki/guides/request-cert-acme.mdxindex f0b545ba23..8c6f09e057 100644--- a/docs/documentation/platform/pki/guides/request-cert-acme.mdx+++ b/docs/documentation/platform/pki/guides/request-cert-acme.mdx@@ -77,11 +77,11 @@ In the following steps, we explore an end-to-end workflow for obtaining a certifNext, follow the guide [here](/documentation/platform/pki/certificates/profiles#guide-to-creating-a-certificate-profile) to create a [certificate profile](/documentation/platform/pki/certificates/profiles)that will be referenced when requesting a certificate.- The certificate profile specifies which certificate template and issuing CA should be used to validate an incoming certificate request and issue a certificate;+ The certificate profile specifies which certificate policy and issuing CA should be used to validate an incoming certificate request and issue a certificate;it also specifies the [enrollment method](/documentation/platform/pki/enrollment-methods/overview) for how certificates can be requested against this profileto begin with.-- You should specify the certificate template from Step 2, the issuing CA from Step 1, and the **ACME** option in the **Enrollment Method** dropdown when creating the certificate profile.++ You should specify the certificate policy from Step 2, the issuing CA from Step 1, and the **ACME** option in the **Enrollment Method** dropdown when creating the certificate profile.</Step><Step title="Request a certificate">diff --git a/docs/documentation/platform/pki/guides/request-cert-agent.mdx b/docs/documentation/platform/pki/guides/request-cert-agent.mdxindex 698ea25471..cf47f52817 100644--- a/docs/documentation/platform/pki/guides/request-cert-agent.mdx+++ b/docs/documentation/platform/pki/guides/request-cert-agent.mdx@@ -67,11 +67,11 @@ In the following steps, we explore an end-to-end workflow for requesting and conNext, follow the guide [here](/documentation/platform/pki/certificates/profiles#guide-to-creating-a-certificate-profile) to create a [certificate profile](/documentation/platform/pki/certificates/profiles)that will be referenced when requesting a certificate.- The certificate profile specifies which certificate template and issuing CA should be used to validate an incoming certificate request and issue a certificate;+ The certificate profile specifies which certificate policy and issuing CA should be used to validate an incoming certificate request and issue a certificate;it also specifies the [enrollment method](/documentation/platform/pki/enrollment-methods/overview) for how certificates can be requested against this profileto begin with.- You should specify the certificate template from Step 2, the issuing CA from Step 1, and the **API** option in the **Enrollment Method** dropdown when creating the certificate profile.+ You should specify the certificate policy from Step 2, the issuing CA from Step 1, and the **API** option in the **Enrollment Method** dropdown when creating the certificate profile.<Note>Note that if you're looking to issue self-signed certificates, you should select the **Self-Signed** option in the **Issuer Type** dropdown when creating the certificate profile.diff --git a/docs/documentation/platform/pki/guides/request-cert-api.mdx b/docs/documentation/platform/pki/guides/request-cert-api.mdxindex e44771d73d..2fce584e93 100644--- a/docs/documentation/platform/pki/guides/request-cert-api.mdx+++ b/docs/documentation/platform/pki/guides/request-cert-api.mdx@@ -45,11 +45,11 @@ In the following steps, we explore an end-to-end workflow for requesting a certiNext, follow the guide [here](/documentation/platform/pki/certificates/profiles#guide-to-creating-a-certificate-profile) to create a [certificate profile](/documentation/platform/pki/certificates/profiles)that will be referenced when requesting a certificate.- The certificate profile specifies which certificate template and issuing CA should be used to validate an incoming certificate request and issue a certificate;+ The certificate profile specifies which certificate policy and issuing CA should be used to validate an incoming certificate request and issue a certificate;it also specifies the [enrollment method](/documentation/platform/pki/enrollment-methods/overview) for how certificates can be requested against this profileto begin with.- You should specify the certificate template from Step 2, the issuing CA from Step 1, and the **API** option in the **Enrollment Method** dropdown when creating the certificate profile.+ You should specify the certificate policy from Step 2, the issuing CA from Step 1, and the **API** option in the **Enrollment Method** dropdown when creating the certificate profile.<Note>Note that if you're looking to issue self-signed certificates, you should select the **Self-Signed** option in the **Issuer Type** dropdown when creating the certificate profile.diff --git a/docs/documentation/platform/pki/integration-guides/gloo-mesh.mdx b/docs/documentation/platform/pki/integration-guides/gloo-mesh.mdxindex d83e062fa9..9717e6531e 100644--- a/docs/documentation/platform/pki/integration-guides/gloo-mesh.mdx+++ b/docs/documentation/platform/pki/integration-guides/gloo-mesh.mdx@@ -22,7 +22,7 @@ With this approach, you get the following benefits:The certificate provisioning workflow begins with setting up your PKI hierarchy in Infisical, where you create root and subordinate certificate authorities.When you deploy a `Certificate` CRD in your workload cluster, `cert-manager` uses the [ACME enrollment method](/documentation/platform/pki/enrollment-methods/acme) configured on a [certificate profile](/documentation/platform/pki/certificates/profiles) to authenticate using EAB credentials and request an intermediate CA certificate.-Infisical verifies the request against your certificate templates and returns the signed certificate.+Infisical verifies the request against your certificate policies and returns the signed certificate.From there, Istio's control plane will automatically use this intermediate CA to sign leaf certificates for workloads in the service mesh, enabling secure mTLS communication across your entire Gloo Mesh infrastructure.Follow the [Kubernetes cert-manager guide](/documentation/platform/pki/k8s-cert-manager) for detailed instructions on how to set up the Infisical and cert-manager for your Istio intermediate CA certificates in Gloo Mesh clusters.diff --git a/docs/images/platform/pki/certificate/cert-policy-modal.png b/docs/images/platform/pki/certificate/cert-policy-modal.pngnew file mode 100644index 0000000000..70c018b054Binary files /dev/null and b/docs/images/platform/pki/certificate/cert-policy-modal.png differdiff --git a/docs/images/platform/pki/certificate/cert-policy.png b/docs/images/platform/pki/certificate/cert-policy.pngnew file mode 100644index 0000000000..9bdf360714Binary files /dev/null and b/docs/images/platform/pki/certificate/cert-policy.png differdiff --git a/docs/internals/permissions/project-permissions.mdx b/docs/internals/permissions/project-permissions.mdxindex 57ba24a75c..0882bddc34 100644--- a/docs/internals/permissions/project-permissions.mdx+++ b/docs/internals/permissions/project-permissions.mdx@@ -304,14 +304,14 @@ Supports conditions and permission inversion| `delete` | Remove certificate profiles || `issue-cert` | Issue new certificates |-#### Subject: `certificate-templates`+#### Subject: `certificate-policies`| Action | Description || -------- | -------------------------------- |-| `read` | View certificate templates |-| `create` | Create new certificate templates |-| `edit` | Modify template configurations |-| `delete` | Remove certificate templates |+| `read` | View certificate policies |+| `create` | Create new certificate policies |+| `edit` | Modify policy configurations |+| `delete` | Remove certificate policies |#### Subject: `pki-alerts`diff --git a/docs/snippets/documentation/platform/pki/guides/request-cert-setup.mdx b/docs/snippets/documentation/platform/pki/guides/request-cert-setup.mdxindex c703fd63d2..b782cac305 100644--- a/docs/snippets/documentation/platform/pki/guides/request-cert-setup.mdx+++ b/docs/snippets/documentation/platform/pki/guides/request-cert-setup.mdx@@ -15,13 +15,13 @@</Note></Step>-<Step title="Create a certificate template">- Next, follow the guide [here](/documentation/platform/pki/certificates/templates#guide-to-creating-a-certificate-template) to create a [certificate template](/documentation/platform/pki/certificates/templates).+<Step title="Create a certificate policy">+ Next, follow the guide [here](/documentation/platform/pki/certificates/policies#guide-to-creating-a-certificate-policy) to create a [certificate policy](/documentation/platform/pki/certificates/policies).- The certificate template will constrain what attributes may or may not be allowed in the request to issue a certificate.+ The certificate policy will constrain what attributes may or may not be allowed in the request to issue a certificate.For example, you can specify that the requested common name must adhere to a specific format like `*.acme.com` andthat the maximum TTL cannot exceed 1 year.- If you're looking to issue TLS server certificates, you should select the **TLS Server Certificate** option under the **Template Preset** dropdown.+ If you're looking to issue TLS server certificates, you should select the **TLS Server Certificate** option under the **Policy Preset** dropdown.</Step>diff --git a/frontend/src/context/ProjectPermissionContext/index.tsx b/frontend/src/context/ProjectPermissionContext/index.tsxindex eda8685193..c6afe8c625 100644--- a/frontend/src/context/ProjectPermissionContext/index.tsx+++ b/frontend/src/context/ProjectPermissionContext/index.tsx@@ -5,6 +5,7 @@ export {ProjectPermissionAuditLogsActions,ProjectPermissionCertificateActions,ProjectPermissionCertificateAuthorityActions,+ ProjectPermissionCertificatePolicyActions,ProjectPermissionCertificateProfileActions,ProjectPermissionCmekActions,ProjectPermissionDynamicSecretActions,diff --git a/frontend/src/context/ProjectPermissionContext/types.ts b/frontend/src/context/ProjectPermissionContext/types.tsindex 109889721f..675beb6547 100644--- a/frontend/src/context/ProjectPermissionContext/types.ts+++ b/frontend/src/context/ProjectPermissionContext/types.ts@@ -132,6 +132,13 @@ export enum ProjectPermissionPkiTemplateActions {ListCerts = "list-certs"}+export enum ProjectPermissionCertificatePolicyActions {+ Read = "read",+ Create = "create",+ Edit = "edit",+ Delete = "delete"+}+export enum ProjectPermissionCertificateAuthorityActions {Read = "read",Create = "create",@@ -267,6 +274,7 @@ export type ConditionalProjectPermissionSubject =| ProjectPermissionSub.CertificateAuthorities| ProjectPermissionSub.Certificates| ProjectPermissionSub.CertificateProfiles+ | ProjectPermissionSub.CertificatePolicies| ProjectPermissionSub.SecretFolders| ProjectPermissionSub.SecretImports| ProjectPermissionSub.SecretRotation@@ -344,6 +352,7 @@ export enum ProjectPermissionSub {PkiCollections = "pki-collections",PkiSubscribers = "pki-subscribers",CertificateProfiles = "certificate-profiles",+ CertificatePolicies = "certificate-policies",Kms = "kms",Cmek = "cmek",SecretSyncs = "secret-syncs",@@ -439,6 +448,10 @@ export type PkiTemplateSubjectFields = {// (dangtony98): consider adding [commonName] as a subject field in the future};+export type CertificatePolicySubjectFields = {+ name: string;+};+export type PamAccountSubjectFields = {resourceName: string;accountName: string;@@ -562,6 +575,13 @@ export type ProjectPermissionSet =CertificateProfileSubjectFields))]+ | [+ ProjectPermissionCertificatePolicyActions,+ (+ | ProjectPermissionSub.CertificatePolicies+ | (ForcedSubject<ProjectPermissionSub.CertificatePolicies> & CertificatePolicySubjectFields)+ )+ ]| [ProjectPermissionActions, ProjectPermissionSub.PkiAlerts]| [ProjectPermissionActions, ProjectPermissionSub.PkiCollections]| [ProjectPermissionActions.Delete, ProjectPermissionSub.Project]diff --git a/frontend/src/context/index.tsx b/frontend/src/context/index.tsxindex 99e621298a..108aba7841 100644--- a/frontend/src/context/index.tsx+++ b/frontend/src/context/index.tsx@@ -16,6 +16,7 @@ export {ProjectPermissionAuditLogsActions,ProjectPermissionCertificateActions,ProjectPermissionCertificateAuthorityActions,+ ProjectPermissionCertificatePolicyActions,ProjectPermissionCertificateProfileActions,ProjectPermissionCmekActions,ProjectPermissionDynamicSecretActions,diff --git a/frontend/src/hooks/api/certificatePolicies/index.tsx b/frontend/src/hooks/api/certificatePolicies/index.tsxnew file mode 100644index 0000000000..f9ab2f719b--- /dev/null+++ b/frontend/src/hooks/api/certificatePolicies/index.tsx@@ -0,0 +1,19 @@+export {+ useCreateCertificatePolicy,+ useDeleteCertificatePolicy,+ useUpdateCertificatePolicy+} from "./mutations";+export {+ certificatePolicyKeys,+ useGetCertificatePolicyById,+ useListCertificatePolicies+} from "./queries";+export type {+ TCertificatePolicy,+ TCertificatePolicyRule,+ TCreateCertificatePolicyDTO,+ TDeleteCertificatePolicyDTO,+ TGetCertificatePolicyByIdDTO,+ TListCertificatePoliciesDTO,+ TUpdateCertificatePolicyDTO+} from "./types";diff --git a/frontend/src/hooks/api/certificatePolicies/mutations.tsx b/frontend/src/hooks/api/certificatePolicies/mutations.tsxnew file mode 100644index 0000000000..5772733303--- /dev/null+++ b/frontend/src/hooks/api/certificatePolicies/mutations.tsx@@ -0,0 +1,68 @@+import { useMutation, useQueryClient } from "@tanstack/react-query";++import { apiRequest } from "@app/config/request";++import { certificatePolicyKeys } from "./queries";+import {+ TCertificatePolicy,+ TCreateCertificatePolicyDTO,+ TDeleteCertificatePolicyDTO,+ TUpdateCertificatePolicyDTO+} from "./types";++export const useCreateCertificatePolicy = () => {+ const queryClient = useQueryClient();+ return useMutation<TCertificatePolicy, object, TCreateCertificatePolicyDTO>({+ mutationFn: async (data) => {+ const { data: response } = await apiRequest.post<{+ certificatePolicy: TCertificatePolicy;+ }>("/api/v1/cert-manager/certificate-policies", data);+ return response.certificatePolicy;+ },+ onSuccess: (_, { projectId }) => {+ queryClient.invalidateQueries({+ queryKey: certificatePolicyKeys.listPolicies({ projectId })+ });+ }+ });+};++export const useUpdateCertificatePolicy = () => {+ const queryClient = useQueryClient();+ return useMutation<TCertificatePolicy, object, TUpdateCertificatePolicyDTO>({+ mutationFn: async ({ policyId, ...data }) => {+ const { data: response } = await apiRequest.patch<{+ certificatePolicy: TCertificatePolicy;+ }>(`/api/v1/cert-manager/certificate-policies/${policyId}`, data);+ return response.certificatePolicy;+ },+ onSuccess: (policy, { policyId }) => {+ queryClient.invalidateQueries({+ queryKey: certificatePolicyKeys.listPolicies({ projectId: policy.projectId })+ });+ queryClient.invalidateQueries({+ queryKey: certificatePolicyKeys.getPolicyById(policyId)+ });+ }+ });+};++export const useDeleteCertificatePolicy = () => {+ const queryClient = useQueryClient();+ return useMutation<TCertificatePolicy, object, TDeleteCertificatePolicyDTO>({+ mutationFn: async ({ policyId }) => {+ const { data: response } = await apiRequest.delete<{+ certificatePolicy: TCertificatePolicy;+ }>(`/api/v1/cert-manager/certificate-policies/${policyId}`);+ return response.certificatePolicy;+ },+ onSuccess: (policy, { policyId }) => {+ queryClient.invalidateQueries({+ queryKey: certificatePolicyKeys.listPolicies({ projectId: policy.projectId })+ });+ queryClient.removeQueries({+ queryKey: certificatePolicyKeys.getPolicyById(policyId)+ });+ }+ });+};diff --git a/frontend/src/hooks/api/certificatePolicies/queries.tsx b/frontend/src/hooks/api/certificatePolicies/queries.tsxnew file mode 100644index 0000000000..54e59a3c59--- /dev/null+++ b/frontend/src/hooks/api/certificatePolicies/queries.tsx@@ -0,0 +1,55 @@+import { useQuery } from "@tanstack/react-query";++import { apiRequest } from "@app/config/request";++import {+ TCertificatePolicy,+ TGetCertificatePolicyByIdDTO,+ TListCertificatePoliciesDTO+} from "./types";++export const certificatePolicyKeys = {+ listPolicies: ({ projectId, ...el }: { limit?: number; offset?: number; projectId: string }) => [+ "list-certificate-policies",+ projectId,+ el+ ],+ getPolicyById: (id: string) => ["certificate-policy", id]+};++export const useListCertificatePolicies = ({+ projectId,+ limit = 20,+ offset = 0+}: TListCertificatePoliciesDTO) => {+ return useQuery({+ queryKey: certificatePolicyKeys.listPolicies({ projectId, limit, offset }),+ queryFn: async () => {+ const { data } = await apiRequest.get<{+ certificatePolicies: TCertificatePolicy[];+ totalCount: number;+ }>("/api/v1/cert-manager/certificate-policies", {+ params: {+ projectId,+ limit,+ offset+ }+ });+ return data;+ },+ enabled: Boolean(projectId)+ });+};++export const useGetCertificatePolicyById = ({ policyId }: TGetCertificatePolicyByIdDTO) => {+ return useQuery({+ queryKey: certificatePolicyKeys.getPolicyById(policyId),+ queryFn: async () => {+ const { data } = await apiRequest.get<{+ certificatePolicy: TCertificatePolicy;+ }>(`/api/v1/cert-manager/certificate-policies/${policyId}`);+ return data.certificatePolicy;+ },+ enabled: Boolean(policyId)+ });+};diff --git a/frontend/src/hooks/api/certificatePolicies/types.ts b/frontend/src/hooks/api/certificatePolicies/types.tsnew file mode 100644index 0000000000..676827bc9e--- /dev/null+++ b/frontend/src/hooks/api/certificatePolicies/types.ts@@ -0,0 +1,86 @@+export type TCertificatePolicyRule = {+ subject?: Array<{+ type: "common_name" | "organization" | "country";+ allowed?: string[];+ required?: string[];+ denied?: string[];+ }>;+ sans?: Array<{+ type: "dns_name" | "ip_address" | "email" | "uri";+ allowed?: string[];+ required?: string[];+ denied?: string[];+ }>;+ keyUsages?: {+ allowed?: string[];+ required?: string[];+ denied?: string[];+ };+ extendedKeyUsages?: {+ allowed?: string[];+ required?: string[];+ denied?: string[];+ };+ algorithms?: {+ signature?: Array<+ "SHA256-RSA" | "SHA384-RSA" | "SHA512-RSA" | "SHA256-ECDSA" | "SHA384-ECDSA" | "SHA512-ECDSA"+ >;+ keyAlgorithm?: Array<"RSA-2048" | "RSA-3072" | "RSA-4096" | "ECDSA-P256" | "ECDSA-P384">;+ };+ validity?: {+ max?: string;+ };+};++export type TCertificatePolicy = {+ id: string;+ projectId: string;+ name: string;+ description?: string;+ subject?: TCertificatePolicyRule["subject"];+ sans?: TCertificatePolicyRule["sans"];+ keyUsages?: TCertificatePolicyRule["keyUsages"];+ extendedKeyUsages?: TCertificatePolicyRule["extendedKeyUsages"];+ algorithms?: TCertificatePolicyRule["algorithms"];+ validity?: TCertificatePolicyRule["validity"];+ createdAt: string;+ updatedAt: string;+};++export type TCreateCertificatePolicyDTO = {+ projectId: string;+ name: string;+ description?: string;+ subject?: TCertificatePolicyRule["subject"];+ sans?: TCertificatePolicyRule["sans"];+ keyUsages?: TCertificatePolicyRule["keyUsages"];+ extendedKeyUsages?: TCertificatePolicyRule["extendedKeyUsages"];+ algorithms?: TCertificatePolicyRule["algorithms"];+ validity?: TCertificatePolicyRule["validity"];+};++export type TUpdateCertificatePolicyDTO = {+ policyId: string;+ name?: string;+ description?: string;+ subject?: TCertificatePolicyRule["subject"];+ sans?: TCertificatePolicyRule["sans"];+ keyUsages?: TCertificatePolicyRule["keyUsages"];+ extendedKeyUsages?: TCertificatePolicyRule["extendedKeyUsages"];+ algorithms?: TCertificatePolicyRule["algorithms"];+ validity?: TCertificatePolicyRule["validity"];+};++export type TDeleteCertificatePolicyDTO = {+ policyId: string;+};++export type TListCertificatePoliciesDTO = {+ projectId: string;+ limit?: number;+ offset?: number;+};++export type TGetCertificatePolicyByIdDTO = {+ policyId: string;+};diff --git a/frontend/src/hooks/api/certificateProfiles/types.ts b/frontend/src/hooks/api/certificateProfiles/types.tsindex e79c384d31..704467ad73 100644--- a/frontend/src/hooks/api/certificateProfiles/types.ts+++ b/frontend/src/hooks/api/certificateProfiles/types.ts@@ -13,7 +13,7 @@ export type TCertificateProfile = {id: string;projectId: string;caId: string | null;- certificateTemplateId: string;+ certificatePolicyId: string;slug: string;description?: string;enrollmentType: EnrollmentType;@@ -42,7 +42,7 @@ export type TCertificateProfileWithDetails = TCertificateProfile & {isExternal?: boolean;externalType?: string | null;};- certificateTemplate?: {+ certificatePolicy?: {id: string;projectId: string;name: string;@@ -69,7 +69,7 @@ export type TCertificateProfileWithDetails = TCertificateProfile & {export type TCreateCertificateProfileDTO = {projectId: string;caId?: string;- certificateTemplateId: string;+ certificatePolicyId: string;slug: string;description?: string;enrollmentType: EnrollmentType;diff --git a/frontend/src/hooks/api/certificateTemplates/index.tsx b/frontend/src/hooks/api/certificateTemplates/index.tsxindex a48248a6bd..288bc7d038 100644--- a/frontend/src/hooks/api/certificateTemplates/index.tsx+++ b/frontend/src/hooks/api/certificateTemplates/index.tsx@@ -8,4 +8,9 @@ export {useUpdateCertTemplateV2,useUpdateEstConfig} from "./mutations";-export { useGetCertTemplate, useGetEstConfig, useListCertificateTemplates } from "./queries";+export {+ certTemplateKeys,+ useGetCertTemplate,+ useGetEstConfig,+ useListCertificateTemplates+} from "./queries";diff --git a/frontend/src/hooks/api/certificateTemplates/mutations.tsx b/frontend/src/hooks/api/certificateTemplates/mutations.tsxindex 0acebae521..a402ad4209 100644--- a/frontend/src/hooks/api/certificateTemplates/mutations.tsx+++ b/frontend/src/hooks/api/certificateTemplates/mutations.tsx@@ -7,17 +7,13 @@ import { projectKeys } from "../projects";import { certTemplateKeys } from "./queries";import {TCertificateTemplate,- TCertificateTemplateV2WithPolicies,TCreateCertificateTemplateDTO,TCreateCertificateTemplateV2DTO,- TCreateCertificateTemplateV2WithPoliciesDTO,TCreateEstConfigDTO,TDeleteCertificateTemplateDTO,TDeleteCertificateTemplateV2DTO,- TDeleteCertificateTemplateV2WithPoliciesDTO,TUpdateCertificateTemplateDTO,TUpdateCertificateTemplateV2DTO,- TUpdateCertificateTemplateV2WithPoliciesDTO,TUpdateEstConfigDTO} from "./types";@@ -187,72 +183,3 @@ export const useUpdateEstConfig = () => {}});};--export const useCreateCertificateTemplateV2WithPolicies = () => {- const queryClient = useQueryClient();- return useMutation<- TCertificateTemplateV2WithPolicies,- object,- TCreateCertificateTemplateV2WithPoliciesDTO- >({- mutationFn: async (data) => {- const { data: response } = await apiRequest.post<{- certificateTemplate: TCertificateTemplateV2WithPolicies;- }>("/api/v1/cert-manager/certificate-templates", data);- return response.certificateTemplate;- },- onSuccess: (_, { projectId }) => {- queryClient.invalidateQueries({- queryKey: certTemplateKeys.listTemplatesV2({ projectId })- });- }- });-};--export const useUpdateCertificateTemplateV2WithPolicies = () => {- const queryClient = useQueryClient();- return useMutation<- TCertificateTemplateV2WithPolicies,- object,- TUpdateCertificateTemplateV2WithPoliciesDTO- >({- mutationFn: async ({ templateId, ...data }) => {- const { data: response } = await apiRequest.patch<{- certificateTemplate: TCertificateTemplateV2WithPolicies;- }>(`/api/v1/cert-manager/certificate-templates/${templateId}`, data);- return response.certificateTemplate;- },- onSuccess: (template, { templateId }) => {- queryClient.invalidateQueries({- queryKey: certTemplateKeys.listTemplatesV2({ projectId: template.projectId })- });- queryClient.invalidateQueries({- queryKey: certTemplateKeys.getTemplateV2ById(templateId)- });- }- });-};--export const useDeleteCertificateTemplateV2WithPolicies = () => {- const queryClient = useQueryClient();- return useMutation<- TCertificateTemplateV2WithPolicies,- object,- TDeleteCertificateTemplateV2WithPoliciesDTO- >({- mutationFn: async ({ templateId }) => {- const { data: response } = await apiRequest.delete<{- certificateTemplate: TCertificateTemplateV2WithPolicies;- }>(`/api/v1/cert-manager/certificate-templates/${templateId}`);- return response.certificateTemplate;- },- onSuccess: (template, { templateId }) => {- queryClient.invalidateQueries({- queryKey: certTemplateKeys.listTemplatesV2({ projectId: template.projectId })- });- queryClient.removeQueries({- queryKey: certTemplateKeys.getTemplateV2ById(templateId)- });- }- });-};diff --git a/frontend/src/hooks/api/certificateTemplates/queries.tsx b/frontend/src/hooks/api/certificateTemplates/queries.tsxindex 78c1ebd812..531a00bb51 100644--- a/frontend/src/hooks/api/certificateTemplates/queries.tsx+++ b/frontend/src/hooks/api/certificateTemplates/queries.tsx@@ -5,11 +5,8 @@ import { apiRequest } from "@app/config/request";import {TCertificateTemplate,TCertificateTemplateV2,- TCertificateTemplateV2WithPolicies,TEstConfig,- TGetCertificateTemplateV2ByIdDTO,- TListCertificateTemplatesDTO,- TListCertificateTemplatesV2DTO+ TListCertificateTemplatesDTO} from "./types";export const certTemplateKeys = {@@ -19,16 +16,7 @@ export const certTemplateKeys = {projectId,el],- getEstConfig: (id: string) => [{ id }, "cert-template-est-config"],- listTemplatesV2: ({- projectId,- ...el- }: {- limit?: number;- offset?: number;- projectId: string;- }) => ["list-templates-v2", projectId, el],- getTemplateV2ById: (id: string) => ["cert-template-v2", id]+ getEstConfig: (id: string) => [{ id }, "cert-template-est-config"]};// TODO: DEPRECATE@@ -83,42 +71,3 @@ export const useGetEstConfig = (certificateTemplateId: string) => {enabled: Boolean(certificateTemplateId)});};--export const useListCertificateTemplatesV2 = ({- projectId,- limit = 20,- offset = 0-}: TListCertificateTemplatesV2DTO) => {- return useQuery({- queryKey: certTemplateKeys.listTemplatesV2({ projectId, limit, offset }),- queryFn: async () => {- const { data } = await apiRequest.get<{- certificateTemplates: TCertificateTemplateV2WithPolicies[];- totalCount: number;- }>("/api/v1/cert-manager/certificate-templates", {- params: {- projectId,- limit,- offset- }- });- return data;- },- enabled: Boolean(projectId)- });-};--export const useGetCertificateTemplateV2ById = ({- templateId-}: TGetCertificateTemplateV2ByIdDTO) => {- return useQuery({- queryKey: certTemplateKeys.getTemplateV2ById(templateId),- queryFn: async () => {- const { data } = await apiRequest.get<{- certificateTemplate: TCertificateTemplateV2WithPolicies;- }>(`/api/v1/cert-manager/certificate-templates/${templateId}`);- return data.certificateTemplate;- },- enabled: Boolean(templateId)- });-};diff --git a/frontend/src/hooks/api/certificateTemplates/types.ts b/frontend/src/hooks/api/certificateTemplates/types.tsindex a6653cbec3..448f388256 100644--- a/frontend/src/hooks/api/certificateTemplates/types.ts+++ b/frontend/src/hooks/api/certificateTemplates/types.ts@@ -121,90 +121,3 @@ export type TListCertificateTemplatesDTO = {offset?: number;projectId: string;};--export type TCertificateTemplateV2Policy = {- subject?: Array<{- type: "common_name" | "organization" | "country";- allowed?: string[];- required?: string[];- denied?: string[];- }>;- sans?: Array<{- type: "dns_name" | "ip_address" | "email" | "uri";- allowed?: string[];- required?: string[];- denied?: string[];- }>;- keyUsages?: {- allowed?: string[];- required?: string[];- denied?: string[];- };- extendedKeyUsages?: {- allowed?: string[];- required?: string[];- denied?: string[];- };- algorithms?: {- signature?: Array<- "SHA256-RSA" | "SHA384-RSA" | "SHA512-RSA" | "SHA256-ECDSA" | "SHA384-ECDSA" | "SHA512-ECDSA"- >;- keyAlgorithm?: Array<"RSA-2048" | "RSA-3072" | "RSA-4096" | "ECDSA-P256" | "ECDSA-P384">;- };- validity?: {- max?: string;- };-};--export type TCertificateTemplateV2WithPolicies = {- id: string;- projectId: string;- name: string;- description?: string;- subject?: TCertificateTemplateV2Policy["subject"];- sans?: TCertificateTemplateV2Policy["sans"];- keyUsages?: TCertificateTemplateV2Policy["keyUsages"];- extendedKeyUsages?: TCertificateTemplateV2Policy["extendedKeyUsages"];- algorithms?: TCertificateTemplateV2Policy["algorithms"];- validity?: TCertificateTemplateV2Policy["validity"];- createdAt: string;- updatedAt: string;-};--export type TCreateCertificateTemplateV2WithPoliciesDTO = {- projectId: string;- name: string;- description?: string;- subject?: TCertificateTemplateV2Policy["subject"];- sans?: TCertificateTemplateV2Policy["sans"];- keyUsages?: TCertificateTemplateV2Policy["keyUsages"];- extendedKeyUsages?: TCertificateTemplateV2Policy["extendedKeyUsages"];- algorithms?: TCertificateTemplateV2Policy["algorithms"];- validity?: TCertificateTemplateV2Policy["validity"];-};--export type TUpdateCertificateTemplateV2WithPoliciesDTO = {- templateId: string;- name?: string;- description?: string;- subject?: TCertificateTemplateV2Policy["subject"];- sans?: TCertificateTemplateV2Policy["sans"];- keyUsages?: TCertificateTemplateV2Policy["keyUsages"];- extendedKeyUsages?: TCertificateTemplateV2Policy["extendedKeyUsages"];- algorithms?: TCertificateTemplateV2Policy["algorithms"];- validity?: TCertificateTemplateV2Policy["validity"];-};--export type TDeleteCertificateTemplateV2WithPoliciesDTO = {- templateId: string;-};--export type TListCertificateTemplatesV2DTO = {- projectId: string;- limit?: number;- offset?: number;-};--export type TGetCertificateTemplateV2ByIdDTO = {- templateId: string;-};diff --git a/frontend/src/hooks/api/index.tsx b/frontend/src/hooks/api/index.tsxindex 8cb311c11a..a88afe0e51 100644--- a/frontend/src/hooks/api/index.tsx+++ b/frontend/src/hooks/api/index.tsx@@ -14,6 +14,7 @@ export * from "./auth";export * from "./bots";export * from "./ca";export * from "./certificates";+export * from "./certificatePolicies";export * from "./certificateTemplates";export * from "./dynamicSecret";export * from "./dynamicSecretLease";diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsxindex fff9416817..bf8f48a06d 100644--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx@@ -23,9 +23,9 @@ import { useGetCert } from "@app/hooks/api";import { EnrollmentType, useListCertificateProfiles } from "@app/hooks/api/certificateProfiles";import { CertExtendedKeyUsage, CertKeyUsage } from "@app/hooks/api/certificates/enums";import { useUnifiedCertificateIssuance } from "@app/hooks/api/certificates/mutations";-import { useGetCertificateTemplateV2ById } from "@app/hooks/api/certificateTemplates/queries";+import { useGetCertificatePolicyById } from "@app/hooks/api/certificatePolicies";import { UsePopUpState } from "@app/hooks/usePopUp";-import { CertSubjectAlternativeNameType } from "@app/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/certificate-constants";+import { CertSubjectAlternativeNameType } from "@app/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/certificate-constants";import { AlgorithmSelectors } from "./AlgorithmSelectors";import { CertificateContent } from "./CertificateContent";@@ -161,15 +161,15 @@ export const CertificateIssuanceModal = ({ popUp, handlePopUpToggle, profileId }[profilesData?.certificateProfiles, actualSelectedProfileId]);- const { data: templateData } = useGetCertificateTemplateV2ById({- templateId: actualSelectedProfile?.certificateTemplateId || ""+ const { data: policyData } = useGetCertificatePolicyById({+ policyId: actualSelectedProfile?.certificatePolicyId || ""});useEffect(() => {- if (templateData !== undefined) {- setShouldShowSubjectSection((templateData?.subject?.length || 0) > 0);+ if (policyData !== undefined) {+ setShouldShowSubjectSection((policyData?.subject?.length || 0) > 0);}- }, [templateData]);+ }, [policyData]);const {constraints,@@ -179,7 +179,7 @@ export const CertificateIssuanceModal = ({ popUp, handlePopUpToggle, profileId }availableKeyAlgorithms,resetConstraints} = useCertificateTemplate(- templateData,+ policyData,actualSelectedProfile,popUp?.issueCertificate?.isOpen || false,setValue,diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/SubjectAltNamesField.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/SubjectAltNamesField.tsxindex 4614539e08..da6427b283 100644--- a/frontend/src/pages/cert-manager/CertificatesPage/components/SubjectAltNamesField.tsx+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/SubjectAltNamesField.tsx@@ -3,7 +3,7 @@ import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { Button, FormControl, IconButton, Input, Select, SelectItem } from "@app/components/v2";-import { CertSubjectAlternativeNameType } from "@app/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/certificate-constants";+import { CertSubjectAlternativeNameType } from "@app/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/certificate-constants";import { getSanPlaceholder, getSanTypeLabels, SubjectAltName } from "./certificateUtils";diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/certificateUtils.ts b/frontend/src/pages/cert-manager/CertificatesPage/components/certificateUtils.tsindex 7f16b87e0a..35fd9408fe 100644--- a/frontend/src/pages/cert-manager/CertificatesPage/components/certificateUtils.ts+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/certificateUtils.ts@@ -1,4 +1,4 @@-import { CertSubjectAlternativeNameType } from "@app/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/certificate-constants";+import { CertSubjectAlternativeNameType } from "@app/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/certificate-constants";export const getSanPlaceholder = (sanType: CertSubjectAlternativeNameType): string => {switch (sanType) {diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/useCertificateTemplate.ts b/frontend/src/pages/cert-manager/CertificatesPage/components/useCertificateTemplate.tsindex 5499a2762c..4e0ddb6eb9 100644--- a/frontend/src/pages/cert-manager/CertificatesPage/components/useCertificateTemplate.ts+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/useCertificateTemplate.ts@@ -7,9 +7,9 @@ import {} from "@app/hooks/api/certificates/constants";import {CertSubjectAlternativeNameType,- mapTemplateKeyAlgorithmToApi,- mapTemplateSignatureAlgorithmToApi-} from "@app/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/certificate-constants";+ mapPolicyKeyAlgorithmToApi,+ mapPolicySignatureAlgorithmToApi+} from "@app/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/certificate-constants";const convertTemplateTtlToCertificateTtl = (templateTtl: string): string => {const match = templateTtl.match(/^(\d+)([dmyh])$/);@@ -79,7 +79,7 @@ export const useCertificateTemplate = (const availableSignatureAlgorithms = useMemo(() => {return constraints.allowedSignatureAlgorithms.map((templateAlgorithm) => {- const apiAlgorithm = mapTemplateSignatureAlgorithmToApi(templateAlgorithm);+ const apiAlgorithm = mapPolicySignatureAlgorithmToApi(templateAlgorithm);return {value: apiAlgorithm,label: apiAlgorithm@@ -89,7 +89,7 @@ export const useCertificateTemplate = (const availableKeyAlgorithms = useMemo(() => {return constraints.allowedKeyAlgorithms.map((templateAlgorithm) => {- const apiAlgorithm = mapTemplateKeyAlgorithmToApi(templateAlgorithm);+ const apiAlgorithm = mapPolicyKeyAlgorithmToApi(templateAlgorithm);return {value: apiAlgorithm,label: apiAlgorithmdiff --git a/frontend/src/pages/cert-manager/PoliciesPage/PoliciesPage.tsx b/frontend/src/pages/cert-manager/PoliciesPage/PoliciesPage.tsxindex 2529b69ca9..0b97d6b8c9 100644--- a/frontend/src/pages/cert-manager/PoliciesPage/PoliciesPage.tsx+++ b/frontend/src/pages/cert-manager/PoliciesPage/PoliciesPage.tsx@@ -7,20 +7,20 @@ import { ContentLoader, PageHeader, Tab, TabList, TabPanel, Tabs } from "@app/coimport { useProject, useProjectPermission } from "@app/context";import {ProjectPermissionCertificateActions,+ ProjectPermissionCertificatePolicyActions,ProjectPermissionCertificateProfileActions,- ProjectPermissionPkiTemplateActions,ProjectPermissionSub} from "@app/context/ProjectPermissionContext/types";import { ProjectType } from "@app/hooks/api/projects/types";+import { CertificatePoliciesTab } from "./components/CertificatePoliciesTab";import { CertificateProfilesTab } from "./components/CertificateProfilesTab";import { CertificateRequestsTab } from "./components/CertificateRequestsTab";import { CertificatesTab } from "./components/CertificatesTab";-import { CertificateTemplatesV2Tab } from "./components/CertificateTemplatesV2Tab";enum TabSections {CertificateProfiles = "profiles",- CertificateTemplatesV2 = "templates-v2",+ CertificatePolicies = "policies",Certificates = "certificates",CertificateRequests = "certificate-requests",PkiCollections = "pki-collections"@@ -42,9 +42,9 @@ export const PoliciesPage = () => {ProjectPermissionCertificateProfileActions.Read,ProjectPermissionSub.CertificateProfiles);- const canReadCertificateTemplates = permission.can(- ProjectPermissionPkiTemplateActions.Read,- ProjectPermissionSub.CertificateTemplates+ const canReadCertificatePolicies = permission.can(+ ProjectPermissionCertificatePolicyActions.Read,+ ProjectPermissionSub.CertificatePolicies);const canReadCertificates = permission.can(ProjectPermissionCertificateActions.Read,@@ -82,8 +82,8 @@ export const PoliciesPage = () => {<Tab variant="project" value={TabSections.CertificateProfiles}>Certificate Profiles</Tab>- <Tab variant="project" value={TabSections.CertificateTemplatesV2}>- Certificate Templates+ <Tab variant="project" value={TabSections.CertificatePolicies}>+ Certificate Policies</Tab></TabList>@@ -109,12 +109,8 @@ export const PoliciesPage = () => {{canReadCertificateProfiles ? <CertificateProfilesTab /> : <PermissionDeniedBanner />}</TabPanel>- <TabPanel value={TabSections.CertificateTemplatesV2}>- {canReadCertificateTemplates ? (- <CertificateTemplatesV2Tab />- ) : (- <PermissionDeniedBanner />- )}+ <TabPanel value={TabSections.CertificatePolicies}>+ {canReadCertificatePolicies ? <CertificatePoliciesTab /> : <PermissionDeniedBanner />}</TabPanel></Tabs></div>diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/CertificateTemplatesV2Tab.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CertificatePoliciesTab.tsxsimilarity index 57%rename from frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/CertificateTemplatesV2Tab.tsxrename to frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CertificatePoliciesTab.tsxindex ebc957c1fa..0bc97c225f 100644--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/CertificateTemplatesV2Tab.tsx+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CertificatePoliciesTab.tsx@@ -7,48 +7,47 @@ import { ProjectPermissionCan } from "@app/components/permissions";import { Button, DeleteActionModal } from "@app/components/v2";import { DocumentationLinkBadge } from "@app/components/v3";import {- ProjectPermissionPkiTemplateActions,+ ProjectPermissionCertificatePolicyActions,ProjectPermissionSub} from "@app/context/ProjectPermissionContext/types";-import { useDeleteCertificateTemplateV2WithPolicies } from "@app/hooks/api/certificateTemplates/mutations";-import { type TCertificateTemplateV2WithPolicies } from "@app/hooks/api/certificateTemplates/types";+import { useDeleteCertificatePolicy } from "@app/hooks/api/certificatePolicies";+import { type TCertificatePolicy } from "@app/hooks/api/certificatePolicies";-import { CreateTemplateModal } from "./CreateTemplateModal";-import { TemplateList } from "./TemplateList";+import { CreatePolicyModal } from "./CreatePolicyModal";+import { PolicyList } from "./PolicyList";-export const CertificateTemplatesV2Tab = () => {+export const CertificatePoliciesTab = () => {const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);const [isEditModalOpen, setIsEditModalOpen] = useState(false);const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);- const [selectedTemplate, setSelectedTemplate] =- useState<TCertificateTemplateV2WithPolicies | null>(null);+ const [selectedPolicy, setSelectedPolicy] = useState<TCertificatePolicy | null>(null);- const deleteTemplateV2 = useDeleteCertificateTemplateV2WithPolicies();+ const deletePolicy = useDeleteCertificatePolicy();- const handleCreateTemplate = () => {+ const handleCreatePolicy = () => {setIsCreateModalOpen(true);};- const handleEditTemplate = (template: TCertificateTemplateV2WithPolicies) => {- setSelectedTemplate(template);+ const handleEditPolicy = (policy: TCertificatePolicy) => {+ setSelectedPolicy(policy);setIsEditModalOpen(true);};- const handleDeleteTemplate = (template: TCertificateTemplateV2WithPolicies) => {- setSelectedTemplate(template);+ const handleDeletePolicy = (policy: TCertificatePolicy) => {+ setSelectedPolicy(policy);setIsDeleteModalOpen(true);};const handleDeleteConfirm = async () => {- if (!selectedTemplate) return;+ if (!selectedPolicy) return;- await deleteTemplateV2.mutateAsync({- templateId: selectedTemplate.id+ await deletePolicy.mutateAsync({+ policyId: selectedPolicy.id});setIsDeleteModalOpen(false);- setSelectedTemplate(null);+ setSelectedPolicy(null);createNotification({- text: `Certificate template "${selectedTemplate.name}" deleted successfully`,+ text: `Certificate policy "${selectedPolicy.name}" deleted successfully`,type: "success"});};@@ -58,8 +57,8 @@ export const CertificateTemplatesV2Tab = () => {<div className="mb-4 flex items-center justify-between"><div><div className="flex items-center gap-x-2">- <h2 className="text-xl font-semibold text-mineshaft-100">Certificate Templates</h2>- <DocumentationLinkBadge href="https://infisical.com/docs/documentation/platform/pki/certificates/templates" />+ <h2 className="text-xl font-semibold text-mineshaft-100">Certificate Policies</h2>+ <DocumentationLinkBadge href="https://infisical.com/docs/documentation/platform/pki/certificates/policies" /></div><p className="text-sm text-bunker-300">Define certificate policies, validation rules, and attribute constraints for certificate@@ -68,8 +67,8 @@ export const CertificateTemplatesV2Tab = () => {</div><ProjectPermissionCan- I={ProjectPermissionPkiTemplateActions.Create}- a={ProjectPermissionSub.CertificateTemplates}+ I={ProjectPermissionCertificatePolicyActions.Create}+ a={ProjectPermissionSub.CertificatePolicies}>{(isAllowed) => (<Button@@ -77,43 +76,43 @@ export const CertificateTemplatesV2Tab = () => {colorSchema="primary"type="button"leftIcon={<FontAwesomeIcon icon={faPlus} />}- onClick={handleCreateTemplate}+ onClick={handleCreatePolicy}>- Create Template+ Create Policy</Button>)}</ProjectPermissionCan></div>- <TemplateList onEditTemplate={handleEditTemplate} onDeleteTemplate={handleDeleteTemplate} />+ <PolicyList onEditPolicy={handleEditPolicy} onDeletePolicy={handleDeletePolicy} />- <CreateTemplateModal+ <CreatePolicyModalisOpen={isCreateModalOpen}onClose={() => {setIsCreateModalOpen(false);}}/>- {selectedTemplate && (+ {selectedPolicy && (<>- <CreateTemplateModal+ <CreatePolicyModalisOpen={isEditModalOpen}onClose={() => {setIsEditModalOpen(false);- setSelectedTemplate(null);+ setSelectedPolicy(null);}}- template={selectedTemplate}+ policy={selectedPolicy}mode="edit"/><DeleteActionModalisOpen={isDeleteModalOpen}- title={`Delete Certificate Template ${selectedTemplate.name}?`}+ title={`Delete Certificate Policy ${selectedPolicy.name}?`}onChange={(isOpen) => {setIsDeleteModalOpen(isOpen);- if (!isOpen) setSelectedTemplate(null);+ if (!isOpen) setSelectedPolicy(null);}}- deleteKey={selectedTemplate.name}+ deleteKey={selectedPolicy.name}onDeleteApproved={handleDeleteConfirm}/></>diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/CreateTemplateModal.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CreatePolicyModal.tsxsimilarity index 85%rename from frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/CreateTemplateModal.tsxrename to frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CreatePolicyModal.tsxindex 1da9e8ebe2..f6dfe0288d 100644--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/CreateTemplateModal.tsx+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CreatePolicyModal.tsx@@ -24,13 +24,11 @@ import {} from "@app/components/v2";import { useProject } from "@app/context";import {- useCreateCertificateTemplateV2WithPolicies,- useUpdateCertificateTemplateV2WithPolicies-} from "@app/hooks/api/certificateTemplates/mutations";-import {- TCertificateTemplateV2Policy,- TCertificateTemplateV2WithPolicies-} from "@app/hooks/api/certificateTemplates/types";+ TCertificatePolicy,+ TCertificatePolicyRule,+ useCreateCertificatePolicy,+ useUpdateCertificatePolicy+} from "@app/hooks/api/certificatePolicies";import {CertDurationUnit,@@ -40,29 +38,29 @@ import {CertSubjectAlternativeNameType,CertSubjectAttributeInclude,CertSubjectAttributeType,+ POLICY_PRESET_IDS,+ type PolicyPresetId,SAN_INCLUDE_OPTIONS,SAN_TYPE_OPTIONS,SUBJECT_ATTRIBUTE_INCLUDE_OPTIONS,- SUBJECT_ATTRIBUTE_TYPE_OPTIONS,- TEMPLATE_PRESET_IDS,- type TemplatePresetId+ SUBJECT_ATTRIBUTE_TYPE_OPTIONS} from "./shared/certificate-constants";-import { CERTIFICATE_TEMPLATE_PRESETS } from "./shared/template-presets";-import { KeyUsagesSection, TemplateFormData, templateSchema } from "./shared";+import { CERTIFICATE_POLICY_PRESETS } from "./shared/policy-presets";+import { KeyUsagesSection, PolicyFormData, policySchema } from "./shared";-export type FormData = TemplateFormData;+export type FormData = PolicyFormData;-type AttributeTransform = NonNullable<TCertificateTemplateV2Policy["subject"]>[0];-type SanTransform = NonNullable<TCertificateTemplateV2Policy["sans"]>[0];-type KeyUsagesTransform = TCertificateTemplateV2Policy["keyUsages"];-type ExtendedKeyUsagesTransform = TCertificateTemplateV2Policy["extendedKeyUsages"];-type AlgorithmsTransform = TCertificateTemplateV2Policy["algorithms"];-type ValidityTransform = TCertificateTemplateV2Policy["validity"];+type AttributeTransform = NonNullable<TCertificatePolicyRule["subject"]>[0];+type SanTransform = NonNullable<TCertificatePolicyRule["sans"]>[0];+type KeyUsagesTransform = TCertificatePolicyRule["keyUsages"];+type ExtendedKeyUsagesTransform = TCertificatePolicyRule["extendedKeyUsages"];+type AlgorithmsTransform = TCertificatePolicyRule["algorithms"];+type ValidityTransform = TCertificatePolicyRule["validity"];interface Props {isOpen: boolean;onClose: () => void;- template?: TCertificateTemplateV2WithPolicies;+ policy?: TCertificatePolicy;mode?: "create" | "edit";}@@ -107,17 +105,17 @@ const KEY_ALGORITHMS = ["ECDSA-P521"] as const;-export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create" }: Props) => {+export const CreatePolicyModal = ({ isOpen, onClose, policy, mode = "create" }: Props) => {const { currentProject } = useProject();- const createTemplate = useCreateCertificateTemplateV2WithPolicies();- const updateTemplate = useUpdateCertificateTemplateV2WithPolicies();+ const createPolicy = useCreateCertificatePolicy();+ const updatePolicy = useUpdateCertificatePolicy();- const isEdit = mode === "edit" && template;+ const isEdit = mode === "edit" && policy;- const convertApiToUiFormat = (templateData: TCertificateTemplateV2WithPolicies): FormData => {+ const convertApiToUiFormat = (policyData: TCertificatePolicy): FormData => {const attributes: FormData["attributes"] = [];- if (templateData.subject && Array.isArray(templateData.subject)) {- templateData.subject.forEach((subj) => {+ if (policyData.subject && Array.isArray(policyData.subject)) {+ policyData.subject.forEach((subj) => {if (subj.allowed && Array.isArray(subj.allowed)) {subj.allowed.forEach((allowedValue) => {attributes.push({@@ -140,8 +138,8 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"}const subjectAlternativeNames: FormData["subjectAlternativeNames"] = [];- if (templateData.sans && Array.isArray(templateData.sans)) {- templateData.sans.forEach((san) => {+ if (policyData.sans && Array.isArray(policyData.sans)) {+ policyData.sans.forEach((san) => {if (san.required && Array.isArray(san.required)) {san.required.forEach((requiredValue) => {subjectAlternativeNames.push({@@ -173,19 +171,18 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"}const keyUsages = {- requiredUsages: (templateData.keyUsages?.required || []) as CertKeyUsageType[],- optionalUsages: (templateData.keyUsages?.allowed || []) as CertKeyUsageType[]+ requiredUsages: (policyData.keyUsages?.required || []) as CertKeyUsageType[],+ optionalUsages: (policyData.keyUsages?.allowed || []) as CertKeyUsageType[]};const extendedKeyUsages = {- requiredUsages: (templateData.extendedKeyUsages?.required ||- []) as CertExtendedKeyUsageType[],- optionalUsages: (templateData.extendedKeyUsages?.allowed || []) as CertExtendedKeyUsageType[]+ requiredUsages: (policyData.extendedKeyUsages?.required || []) as CertExtendedKeyUsageType[],+ optionalUsages: (policyData.extendedKeyUsages?.allowed || []) as CertExtendedKeyUsageType[]};- const validity = templateData.validity?.max+ const validity = policyData.validity?.max? (() => {- const maxValue = templateData.validity.max;+ const maxValue = policyData.validity.max;if (maxValue.length < 2) return undefined;const lastChar = maxValue.slice(-1);@@ -214,19 +211,19 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create": { maxDuration: { value: 365, unit: CertDurationUnit.DAYS } };const signatureAlgorithm = {- allowedAlgorithms: templateData.algorithms?.signature || [],+ allowedAlgorithms: policyData.algorithms?.signature || [],defaultAlgorithm: ""};const keyAlgorithm = {- allowedKeyTypes: templateData.algorithms?.keyAlgorithm || [],+ allowedKeyTypes: policyData.algorithms?.keyAlgorithm || [],defaultKeyType: ""};return {- preset: TEMPLATE_PRESET_IDS.CUSTOM,- name: templateData.name || "",- description: templateData.description || "",+ preset: POLICY_PRESET_IDS.CUSTOM,+ name: policyData.name || "",+ description: policyData.description || "",attributes,subjectAlternativeNames,keyUsages,@@ -237,9 +234,9 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"};};- const getDefaultValues = (): FormData & { preset: TemplatePresetId } => {+ const getDefaultValues = (): FormData & { preset: PolicyPresetId } => {return {- preset: TEMPLATE_PRESET_IDS.CUSTOM,+ preset: POLICY_PRESET_IDS.CUSTOM,name: "",description: "",attributes: [],@@ -259,9 +256,9 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"};const { control, handleSubmit, reset, watch, setValue, formState, trigger } = useForm<- FormData & { preset: TemplatePresetId }+ FormData & { preset: PolicyPresetId }>({- resolver: zodResolver(templateSchema),+ resolver: zodResolver(policySchema),defaultValues: getDefaultValues(),mode: "onChange",reValidateMode: "onChange",@@ -269,13 +266,13 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"});useEffect(() => {- if (isEdit && template) {- const convertedData = convertApiToUiFormat(template);- reset({ ...convertedData, preset: TEMPLATE_PRESET_IDS.CUSTOM });+ if (isEdit && policy) {+ const convertedData = convertApiToUiFormat(policy);+ reset({ ...convertedData, preset: POLICY_PRESET_IDS.CUSTOM });} else if (!isEdit) {reset(getDefaultValues());}- }, [isEdit, template, reset]);+ }, [isEdit, policy, reset]);const watchedAttributes = watch("attributes") || [];const watchedSans = watch("subjectAlternativeNames") || [];@@ -284,17 +281,17 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"requiredUsages: [],optionalUsages: []};- const watchedPreset = watch("preset") || TEMPLATE_PRESET_IDS.CUSTOM;+ const watchedPreset = watch("preset") || POLICY_PRESET_IDS.CUSTOM;- const handlePresetChange = async (presetId: TemplatePresetId) => {+ const handlePresetChange = async (presetId: PolicyPresetId) => {setValue("preset", presetId);- if (presetId === TEMPLATE_PRESET_IDS.CUSTOM) {+ if (presetId === POLICY_PRESET_IDS.CUSTOM) {await trigger();return;}- const selectedPreset = CERTIFICATE_TEMPLATE_PRESETS.find((p) => p.id === presetId);+ const selectedPreset = CERTIFICATE_POLICY_PRESETS.find((p) => p.id === presetId);if (selectedPreset) {if (selectedPreset.formData.keyUsages) {setValue("keyUsages", selectedPreset.formData.keyUsages);@@ -485,24 +482,24 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"if (isEdit) {const updateData = {- templateId: template.id,+ policyId: policy.id,...transformedData};- await updateTemplate.mutateAsync(updateData);+ await updatePolicy.mutateAsync(updateData);} else {if (!currentProject?.id) {- throw new Error("Project ID is required for creating a template");+ throw new Error("Project ID is required for creating a policy");}const createData = {projectId: currentProject.id,...transformedData};- await createTemplate.mutateAsync(createData);+ await createPolicy.mutateAsync(createData);}createNotification({- text: `Certificate template ${isEdit ? "updated" : "created"} successfully`,+ text: `Certificate policy ${isEdit ? "updated" : "created"} successfully`,type: "success"});@@ -518,8 +515,8 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"};setValue("attributes", [...watchedAttributes, newAttribute]);- if (watchedPreset !== TEMPLATE_PRESET_IDS.CUSTOM) {- setValue("preset", TEMPLATE_PRESET_IDS.CUSTOM);+ if (watchedPreset !== POLICY_PRESET_IDS.CUSTOM) {+ setValue("preset", POLICY_PRESET_IDS.CUSTOM);}};@@ -527,8 +524,8 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"const newAttributes = watchedAttributes.filter((_, i) => i !== index);setValue("attributes", newAttributes);- if (watchedPreset !== TEMPLATE_PRESET_IDS.CUSTOM) {- setValue("preset", TEMPLATE_PRESET_IDS.CUSTOM);+ if (watchedPreset !== POLICY_PRESET_IDS.CUSTOM) {+ setValue("preset", POLICY_PRESET_IDS.CUSTOM);}};@@ -540,8 +537,8 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"};setValue("subjectAlternativeNames", [...watchedSans, newSan]);- if (watchedPreset !== TEMPLATE_PRESET_IDS.CUSTOM) {- setValue("preset", TEMPLATE_PRESET_IDS.CUSTOM);+ if (watchedPreset !== POLICY_PRESET_IDS.CUSTOM) {+ setValue("preset", POLICY_PRESET_IDS.CUSTOM);}};@@ -549,8 +546,8 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"const newSans = watchedSans.filter((_, i) => i !== index);setValue("subjectAlternativeNames", newSans);- if (watchedPreset !== TEMPLATE_PRESET_IDS.CUSTOM) {- setValue("preset", TEMPLATE_PRESET_IDS.CUSTOM);+ if (watchedPreset !== POLICY_PRESET_IDS.CUSTOM) {+ setValue("preset", POLICY_PRESET_IDS.CUSTOM);}};@@ -563,8 +560,8 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"optionalUsages: usages.optionalUsages});- if (watchedPreset !== TEMPLATE_PRESET_IDS.CUSTOM) {- setValue("preset", TEMPLATE_PRESET_IDS.CUSTOM);+ if (watchedPreset !== POLICY_PRESET_IDS.CUSTOM) {+ setValue("preset", POLICY_PRESET_IDS.CUSTOM);}};@@ -577,8 +574,8 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"optionalUsages: usages.optionalUsages});- if (watchedPreset !== TEMPLATE_PRESET_IDS.CUSTOM) {- setValue("preset", TEMPLATE_PRESET_IDS.CUSTOM);+ if (watchedPreset !== POLICY_PRESET_IDS.CUSTOM) {+ setValue("preset", POLICY_PRESET_IDS.CUSTOM);}};@@ -594,10 +591,10 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"><ModalContentclassName="max-w-4xl"- title={isEdit ? "Edit Certificate Template" : "Create Certificate Template"}+ title={isEdit ? "Edit Certificate Policy" : "Create Certificate Policy"}subTitle={isEdit- ? `Update configuration for ${template?.name}`+ ? `Update configuration for ${policy?.name}`: "Define comprehensive certificate policies, validation rules, and constraints"}>@@ -609,12 +606,12 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"name="name"render={({ field, fieldState: { error } }) => (<FormControl- label="Template Name"+ label="Policy Name"isRequiredisError={Boolean(error)}errorText={error?.message}>- <Input {...field} placeholder="Enter template name" className="w-full" />+ <Input {...field} placeholder="Enter policy name" className="w-full" /></FormControl>)}/>@@ -628,7 +625,7 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"isError={Boolean(error)}errorText={error?.message}>- <TextArea {...field} placeholder="Enter template description" rows={3} />+ <TextArea {...field} placeholder="Enter policy description" rows={3} /></FormControl>)}/>@@ -638,7 +635,7 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"name="preset"render={({ field, fieldState: { error } }) => (<FormControl- label="Template Preset"+ label="Policy Preset"isError={Boolean(error)}errorText={error?.message}>@@ -649,8 +646,8 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"position="popper"dropdownContainerClassName="max-w-none">- <SelectItem value={TEMPLATE_PRESET_IDS.CUSTOM}>Custom</SelectItem>- {CERTIFICATE_TEMPLATE_PRESETS.map((preset) => (+ <SelectItem value={POLICY_PRESET_IDS.CUSTOM}>Custom</SelectItem>+ {CERTIFICATE_POLICY_PRESETS.map((preset) => (<SelectItem key={preset.id} value={preset.id}>{preset.name}</SelectItem>@@ -700,8 +697,8 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"};setValue("attributes", newAttributes);- if (watchedPreset !== TEMPLATE_PRESET_IDS.CUSTOM) {- setValue("preset", TEMPLATE_PRESET_IDS.CUSTOM);+ if (watchedPreset !== POLICY_PRESET_IDS.CUSTOM) {+ setValue("preset", POLICY_PRESET_IDS.CUSTOM);}}}className="w-48"@@ -724,8 +721,8 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"};setValue("attributes", newAttributes);- if (watchedPreset !== TEMPLATE_PRESET_IDS.CUSTOM) {- setValue("preset", TEMPLATE_PRESET_IDS.CUSTOM);+ if (watchedPreset !== POLICY_PRESET_IDS.CUSTOM) {+ setValue("preset", POLICY_PRESET_IDS.CUSTOM);}}}className="w-32"@@ -748,8 +745,8 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"};setValue("attributes", newAttributes);- if (watchedPreset !== TEMPLATE_PRESET_IDS.CUSTOM) {- setValue("preset", TEMPLATE_PRESET_IDS.CUSTOM);+ if (watchedPreset !== POLICY_PRESET_IDS.CUSTOM) {+ setValue("preset", POLICY_PRESET_IDS.CUSTOM);}}}className={`flex-1 ${@@ -818,8 +815,8 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"};setValue("subjectAlternativeNames", newSans);- if (watchedPreset !== TEMPLATE_PRESET_IDS.CUSTOM) {- setValue("preset", TEMPLATE_PRESET_IDS.CUSTOM);+ if (watchedPreset !== POLICY_PRESET_IDS.CUSTOM) {+ setValue("preset", POLICY_PRESET_IDS.CUSTOM);}}}className="w-36"@@ -841,8 +838,8 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"};setValue("subjectAlternativeNames", newSans);- if (watchedPreset !== TEMPLATE_PRESET_IDS.CUSTOM) {- setValue("preset", TEMPLATE_PRESET_IDS.CUSTOM);+ if (watchedPreset !== POLICY_PRESET_IDS.CUSTOM) {+ setValue("preset", POLICY_PRESET_IDS.CUSTOM);}}}className="w-32"@@ -865,8 +862,8 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"};setValue("subjectAlternativeNames", newSans);- if (watchedPreset !== TEMPLATE_PRESET_IDS.CUSTOM) {- setValue("preset", TEMPLATE_PRESET_IDS.CUSTOM);+ if (watchedPreset !== POLICY_PRESET_IDS.CUSTOM) {+ setValue("preset", POLICY_PRESET_IDS.CUSTOM);}}}className={`flex-1 ${@@ -1062,9 +1059,9 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"<Buttontype="submit"colorSchema="primary"- isLoading={isEdit ? updateTemplate.isPending : createTemplate.isPending}+ isLoading={isEdit ? updatePolicy.isPending : createPolicy.isPending}isDisabled={- !formState.isValid || (isEdit ? updateTemplate.isPending : createTemplate.isPending)+ !formState.isValid || (isEdit ? updatePolicy.isPending : createPolicy.isPending)}>{isEdit ? "Save Changes" : "Create"}@@ -1072,7 +1069,7 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"<Buttonvariant="outline_bg"onClick={onClose}- disabled={isEdit ? updateTemplate.isPending : createTemplate.isPending}+ disabled={isEdit ? updatePolicy.isPending : createPolicy.isPending}>Cancel</Button>diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/TemplateList.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/PolicyList.tsxsimilarity index 71%rename from frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/TemplateList.tsxrename to frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/PolicyList.tsxindex a2aa5f78c9..0e24464aaf 100644--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/TemplateList.tsx+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/PolicyList.tsx@@ -30,37 +30,36 @@ import {} from "@app/components/v2";import { useProject } from "@app/context";import {- ProjectPermissionPkiTemplateActions,+ ProjectPermissionCertificatePolicyActions,ProjectPermissionSub} from "@app/context/ProjectPermissionContext/types";import { useToggle } from "@app/hooks";-import { useListCertificateTemplatesV2 } from "@app/hooks/api/certificateTemplates/queries";-import { TCertificateTemplateV2WithPolicies } from "@app/hooks/api/certificateTemplates/types";+import { TCertificatePolicy, useListCertificatePolicies } from "@app/hooks/api/certificatePolicies";interface Props {- onEditTemplate: (template: TCertificateTemplateV2WithPolicies) => void;- onDeleteTemplate: (template: TCertificateTemplateV2WithPolicies) => void;+ onEditPolicy: (policy: TCertificatePolicy) => void;+ onDeletePolicy: (policy: TCertificatePolicy) => void;}-export const TemplateList = ({ onEditTemplate, onDeleteTemplate }: Props) => {+export const PolicyList = ({ onEditPolicy, onDeletePolicy }: Props) => {const { currentProject } = useProject();const [isIdCopied, setIsIdCopied] = useToggle(false);- const { data, isLoading } = useListCertificateTemplatesV2({+ const { data, isLoading } = useListCertificatePolicies({projectId: currentProject?.id || "",limit: 100,offset: 0});- const templates = data?.certificateTemplates || [];+ const policies = data?.certificatePolicies || [];const handleCopyId = useCallback(- (templateId: string) => {+ (policyId: string) => {setIsIdCopied.on();- navigator.clipboard.writeText(templateId);+ navigator.clipboard.writeText(policyId);createNotification({- text: "Template ID copied to clipboard",+ text: "Policy ID copied to clipboard",type: "info"});@@ -77,7 +76,7 @@ export const TemplateList = ({ onEditTemplate, onDeleteTemplate }: Props) => {return new Date(dateString).toLocaleDateString();};- const hasTemplates = !isLoading && templates && templates.length > 0;+ const hasPolicies = !isLoading && policies && policies.length > 0;return (<TableContainer>@@ -90,32 +89,32 @@ export const TemplateList = ({ onEditTemplate, onDeleteTemplate }: Props) => {</Tr></THead><TBody>- {isLoading && <TableSkeleton columns={3} innerKey="certificate-templates" />}- {!isLoading && (!templates || templates.length === 0) && (+ {isLoading && <TableSkeleton columns={3} innerKey="certificate-policies" />}+ {!isLoading && (!policies || policies.length === 0) && (<Tr><Td colSpan={3}>- <EmptyState title="No Certificate Templates" />+ <EmptyState title="No Certificate Policies" /></Td></Tr>)}- {hasTemplates &&- templates.map((template) => (+ {hasPolicies &&+ policies.map((policy) => (<Tr- key={template.id}+ key={policy.id}className="h-10 transition-colors duration-100 hover:bg-mineshaft-700"><Td><div className="flex items-center gap-2">- <div className="text-mineshaft-300">{template.name}</div>- {template.description && (- <Tooltip content={template.description}>+ <div className="text-mineshaft-300">{policy.name}</div>+ {policy.description && (+ <Tooltip content={policy.description}><FontAwesomeIcon icon={faCircleInfo} className="text-mineshaft-400" /></Tooltip>)}</div></Td><Td>- <span className="text-sm text-bunker-300">{formatDate(template.createdAt)}</span>+ <span className="text-sm text-bunker-300">{formatDate(policy.createdAt)}</span></Td><Td className="text-right"><DropdownMenu>@@ -130,16 +129,16 @@ export const TemplateList = ({ onEditTemplate, onDeleteTemplate }: Props) => {<DropdownMenuItemonClick={(e) => {e.stopPropagation();- handleCopyId(template.id);+ handleCopyId(policy.id);}}icon={<FontAwesomeIcon icon={isIdCopied ? faCheck : faCopy} />}>- Copy Template ID+ Copy Policy ID</DropdownMenuItem><ProjectPermissionCan- I={ProjectPermissionPkiTemplateActions.Edit}- a={subject(ProjectPermissionSub.CertificateTemplates, {- name: template.name+ I={ProjectPermissionCertificatePolicyActions.Edit}+ a={subject(ProjectPermissionSub.CertificatePolicies, {+ name: policy.name})}>{(isAllowed) =>@@ -147,19 +146,19 @@ export const TemplateList = ({ onEditTemplate, onDeleteTemplate }: Props) => {<DropdownMenuItemonClick={(e) => {e.stopPropagation();- onEditTemplate(template);+ onEditPolicy(policy);}}icon={<FontAwesomeIcon icon={faEdit} />}>- Edit Template+ Edit Policy</DropdownMenuItem>)}</ProjectPermissionCan><ProjectPermissionCan- I={ProjectPermissionPkiTemplateActions.Delete}- a={subject(ProjectPermissionSub.CertificateTemplates, {- name: template.name+ I={ProjectPermissionCertificatePolicyActions.Delete}+ a={subject(ProjectPermissionSub.CertificatePolicies, {+ name: policy.name})}>{(isAllowed) =>@@ -167,11 +166,11 @@ export const TemplateList = ({ onEditTemplate, onDeleteTemplate }: Props) => {<DropdownMenuItemonClick={(e) => {e.stopPropagation();- onDeleteTemplate(template);+ onDeletePolicy(policy);}}icon={<FontAwesomeIcon icon={faTrash} />}>- Delete Template+ Delete Policy</DropdownMenuItem>)}diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/index.ts b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/index.tsnew file mode 100644index 0000000000..4434ab9433--- /dev/null+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/index.ts@@ -0,0 +1,3 @@+export { CertificatePoliciesTab } from "./CertificatePoliciesTab";+export { CreatePolicyModal } from "./CreatePolicyModal";+export { PolicyList } from "./PolicyList";diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/certificate-constants.ts b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/certificate-constants.tssimilarity index 94%rename from frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/certificate-constants.tsrename to frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/certificate-constants.tsindex 47fdcd5a2a..d9a23f31d0 100644--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/certificate-constants.ts+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/certificate-constants.ts@@ -191,7 +191,6 @@ export enum CertSignatureAlgorithm {export const SIGNATURE_ALGORITHM_OPTIONS = Object.values(CertSignatureAlgorithm);export const KEY_ALGORITHM_OPTIONS = Object.values(CertKeyAlgorithm);-// Display name mappings for UIexport const getSignatureAlgorithmDisplayName = (algorithm: CertSignatureAlgorithm): string => {switch (algorithm) {case CertSignatureAlgorithm.RSA_SHA256:@@ -228,7 +227,7 @@ export const getKeyAlgorithmDisplayName = (algorithm: CertKeyAlgorithm): string}};-export const mapTemplateSignatureAlgorithmToApi = (templateFormat: string): string => {+export const mapPolicySignatureAlgorithmToApi = (policyFormat: string): string => {const mapping: Record<string, string> = {"SHA256-RSA": "RSA-SHA256","SHA384-RSA": "RSA-SHA384",@@ -237,10 +236,10 @@ export const mapTemplateSignatureAlgorithmToApi = (templateFormat: string): stri"SHA384-ECDSA": "ECDSA-SHA384","SHA512-ECDSA": "ECDSA-SHA512"};- return mapping[templateFormat] || templateFormat;+ return mapping[policyFormat] || policyFormat;};-export const mapTemplateKeyAlgorithmToApi = (templateFormat: string): string => {+export const mapPolicyKeyAlgorithmToApi = (policyFormat: string): string => {const mapping: Record<string, string> = {"RSA-2048": "RSA_2048","RSA-3072": "RSA_3072",@@ -248,10 +247,10 @@ export const mapTemplateKeyAlgorithmToApi = (templateFormat: string): string =>"ECDSA-P256": "EC_prime256v1","ECDSA-P384": "EC_secp384r1"};- return mapping[templateFormat] || templateFormat;+ return mapping[policyFormat] || policyFormat;};-export const TEMPLATE_PRESET_IDS = {+export const POLICY_PRESET_IDS = {CUSTOM: "custom",TLS_SERVER: "tls-server",TLS_CLIENT: "tls-client",@@ -262,7 +261,7 @@ export const TEMPLATE_PRESET_IDS = {DUAL_PURPOSE_SERVER: "dual-purpose-server"} as const;-export type TemplatePresetId = (typeof TEMPLATE_PRESET_IDS)[keyof typeof TEMPLATE_PRESET_IDS];+export type PolicyPresetId = (typeof POLICY_PRESET_IDS)[keyof typeof POLICY_PRESET_IDS];export const ALGORITHM_FAMILIES = {ECDSA: {diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/components.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/components.tsxsimilarity index 100%rename from frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/components.tsxrename to frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/components.tsxdiff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/index.ts b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/index.tssimilarity index 100%rename from frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/index.tsrename to frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/index.tsdiff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/template-presets.ts b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/policy-presets.tssimilarity index 95%rename from frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/template-presets.tsrename to frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/policy-presets.tsindex 9edad21ea9..e7ee5223aa 100644--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/template-presets.ts+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/policy-presets.ts@@ -7,22 +7,22 @@ import {CertSubjectAlternativeNameType,CertSubjectAttributeInclude,CertSubjectAttributeType,- TEMPLATE_PRESET_IDS,- type TemplatePresetId+ POLICY_PRESET_IDS,+ type PolicyPresetId} from "./certificate-constants";-import { TemplateFormData } from ".";+import { PolicyFormData } from ".";-export interface CertificateTemplatePreset {- readonly id: TemplatePresetId;+export interface CertificatePolicyPreset {+ readonly id: PolicyPresetId;readonly name: string;readonly description: string;readonly useCase: string;- readonly formData: Omit<TemplateFormData, "preset">;+ readonly formData: Omit<PolicyFormData, "preset">;}-export const CERTIFICATE_TEMPLATE_PRESETS: CertificateTemplatePreset[] = [+export const CERTIFICATE_POLICY_PRESETS: CertificatePolicyPreset[] = [{- id: TEMPLATE_PRESET_IDS.TLS_SERVER,+ id: POLICY_PRESET_IDS.TLS_SERVER,name: "TLS Server Certificate",description: "Standard TLS/SSL server certificate for HTTPS services and API endpoints.",useCase: "Web servers, API endpoints, HTTPS services",@@ -71,7 +71,7 @@ export const CERTIFICATE_TEMPLATE_PRESETS: CertificateTemplatePreset[] = [}},{- id: TEMPLATE_PRESET_IDS.TLS_CLIENT,+ id: POLICY_PRESET_IDS.TLS_CLIENT,name: "TLS Client Certificate",description: "Client certificate for mutual TLS authentication and API access.",useCase: "Client authentication, mTLS, API authentication",@@ -120,7 +120,7 @@ export const CERTIFICATE_TEMPLATE_PRESETS: CertificateTemplatePreset[] = [}},{- id: TEMPLATE_PRESET_IDS.CODE_SIGNING,+ id: POLICY_PRESET_IDS.CODE_SIGNING,name: "Code Signing Certificate",description:"Certificate for signing software, executables, and packages. Requires hardware security modules.",@@ -169,7 +169,7 @@ export const CERTIFICATE_TEMPLATE_PRESETS: CertificateTemplatePreset[] = [}},{- id: TEMPLATE_PRESET_IDS.DEVICE,+ id: POLICY_PRESET_IDS.DEVICE,name: "Device Certificate",description:"Certificate for IoT devices and embedded systems authentication. IEEE 802.1AR compliant.",@@ -220,7 +220,7 @@ export const CERTIFICATE_TEMPLATE_PRESETS: CertificateTemplatePreset[] = [}},{- id: TEMPLATE_PRESET_IDS.USER,+ id: POLICY_PRESET_IDS.USER,name: "User Certificate",description:"Personal certificate for user authentication and email signing. FIPS 201 PIV compliant.",@@ -276,7 +276,7 @@ export const CERTIFICATE_TEMPLATE_PRESETS: CertificateTemplatePreset[] = [}},{- id: TEMPLATE_PRESET_IDS.EMAIL_PROTECTION,+ id: POLICY_PRESET_IDS.EMAIL_PROTECTION,name: "Email Protection Certificate",description: "S/MIME certificate for email encryption and digital signing. RFC 8550 compliant.",useCase: "Email encryption, digital signing, secure messaging",@@ -325,7 +325,7 @@ export const CERTIFICATE_TEMPLATE_PRESETS: CertificateTemplatePreset[] = [}},{- id: TEMPLATE_PRESET_IDS.DUAL_PURPOSE_SERVER,+ id: POLICY_PRESET_IDS.DUAL_PURPOSE_SERVER,name: "Dual-Purpose Server Certificate",description:"Certificate for services requiring both server and client authentication capabilities",diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/schemas.ts b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/schemas.tssimilarity index 82%rename from frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/schemas.tsrename to frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/schemas.tsindex 137ca262c6..f74c6082d4 100644--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/schemas.ts+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/schemas.ts@@ -8,7 +8,7 @@ import {CertSubjectAlternativeNameType,CertSubjectAttributeInclude,CertSubjectAttributeType,- TEMPLATE_PRESET_IDS+ POLICY_PRESET_IDS} from "./certificate-constants";export const uiAttributeSchema = z.object({@@ -54,27 +54,27 @@ export const uiKeyAlgorithmSchema = z.object({export const uiPresetSchema = z.enum([- TEMPLATE_PRESET_IDS.CUSTOM,- TEMPLATE_PRESET_IDS.TLS_SERVER,- TEMPLATE_PRESET_IDS.TLS_CLIENT,- TEMPLATE_PRESET_IDS.CODE_SIGNING,- TEMPLATE_PRESET_IDS.DEVICE,- TEMPLATE_PRESET_IDS.USER,- TEMPLATE_PRESET_IDS.EMAIL_PROTECTION,- TEMPLATE_PRESET_IDS.DUAL_PURPOSE_SERVER+ POLICY_PRESET_IDS.CUSTOM,+ POLICY_PRESET_IDS.TLS_SERVER,+ POLICY_PRESET_IDS.TLS_CLIENT,+ POLICY_PRESET_IDS.CODE_SIGNING,+ POLICY_PRESET_IDS.DEVICE,+ POLICY_PRESET_IDS.USER,+ POLICY_PRESET_IDS.EMAIL_PROTECTION,+ POLICY_PRESET_IDS.DUAL_PURPOSE_SERVER])- .default(TEMPLATE_PRESET_IDS.CUSTOM);+ .default(POLICY_PRESET_IDS.CUSTOM);-export const templateSchema = z.object({+export const policySchema = z.object({preset: uiPresetSchema,name: z.string().trim()- .min(1, "Template name is required")- .max(255, "Template name must be less than 255 characters")+ .min(1, "Policy name is required")+ .max(255, "Policy name must be less than 255 characters").regex(/^[a-zA-Z0-9-_]+$/,- "Template name must contain only letters, numbers, hyphens, and underscores"+ "Policy name must contain only letters, numbers, hyphens, and underscores"),description: z.string()@@ -90,7 +90,7 @@ export const templateSchema = z.object({keyAlgorithm: uiKeyAlgorithmSchema});-export type TemplateFormData = z.infer<typeof templateSchema>;+export type PolicyFormData = z.infer<typeof policySchema>;export const apiSubjectSchema = z.object({@@ -114,15 +114,15 @@ export const apiSanSchema = zmessage: "At least one allowed, required, or denied value must be provided"});-export const apiTemplateSchema = z.object({+export const apiPolicySchema = z.object({name: z.string().trim()- .min(1, "Template name is required")- .max(255, "Template name must be less than 255 characters")+ .min(1, "Policy name is required")+ .max(255, "Policy name must be less than 255 characters").regex(/^[a-zA-Z0-9-_]+$/,- "Template name must contain only letters, numbers, hyphens, and underscores"+ "Policy name must contain only letters, numbers, hyphens, and underscores"),description: z.string()@@ -162,4 +162,4 @@ export const apiTemplateSchema = z.object({.optional()});-export type ApiTemplateFormData = z.infer<typeof apiTemplateSchema>;+export type ApiPolicyFormData = z.infer<typeof apiPolicySchema>;diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/utils.ts b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/utils.tssimilarity index 100%rename from frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/utils.tsrename to frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/utils.tsdiff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsxindex 39dbcc4587..be5ca5959d 100644--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx@@ -31,7 +31,7 @@ import {useCreateCertificateProfile,useUpdateCertificateProfile} from "@app/hooks/api/certificateProfiles";-import { useListCertificateTemplatesV2 } from "@app/hooks/api/certificateTemplates/queries";+import { useListCertificatePolicies } from "@app/hooks/api/certificatePolicies";const createSchema = z.object({@@ -52,7 +52,7 @@ const createSchema = zenrollmentType: z.nativeEnum(EnrollmentType),issuerType: z.nativeEnum(IssuerType),certificateAuthorityId: z.string().nullable().optional(),- certificateTemplateId: z.string().min(1, "Certificate Template is required"),+ certificatePolicyId: z.string().min(1, "Certificate Policy is required"),estConfig: z.object({disableBootstrapCaValidation: z.boolean().optional(),@@ -208,7 +208,7 @@ const editSchema = zenrollmentType: z.nativeEnum(EnrollmentType),issuerType: z.nativeEnum(IssuerType),certificateAuthorityId: z.string().nullable().optional(),- certificateTemplateId: z.string().optional(),+ certificatePolicyId: z.string().optional(),estConfig: z.object({disableBootstrapCaValidation: z.boolean().optional(),@@ -346,7 +346,7 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }const { currentProject } = useProject();const { data: allCaData } = useListCasByProjectId(currentProject?.id || "");- const { data: templateData } = useListCertificateTemplatesV2({+ const { data: policyData } = useListCertificatePolicies({projectId: currentProject?.id || "",limit: 100,offset: 0@@ -361,7 +361,7 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }...ca,groupType: ca.type === "internal" ? "internal" : "external"}));- const certificateTemplates = templateData?.certificateTemplates || [];+ const certificatePolicies = policyData?.certificatePolicies || [];const getGroupHeaderLabel = (groupType: "internal" | "external") => {switch (groupType) {@@ -383,7 +383,7 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }enrollmentType: profile.enrollmentType,issuerType: profile.issuerType,certificateAuthorityId: profile.caId || undefined,- certificateTemplateId: profile.certificateTemplateId,+ certificatePolicyId: profile.certificatePolicyId,estConfig:profile.enrollmentType === EnrollmentType.EST? {@@ -424,7 +424,7 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }enrollmentType: EnrollmentType.API,issuerType: IssuerType.CA,certificateAuthorityId: "",- certificateTemplateId: "",+ certificatePolicyId: "",apiConfig: {autoRenew: false,renewBeforeDays: 30@@ -461,7 +461,7 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }enrollmentType: profile.enrollmentType,issuerType: profile.issuerType,certificateAuthorityId: profile.caId || undefined,- certificateTemplateId: profile.certificateTemplateId,+ certificatePolicyId: profile.certificatePolicyId,estConfig:profile.enrollmentType === "est"? {@@ -569,7 +569,7 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }data.issuerType === IssuerType.SELF_SIGNED? undefined: data.certificateAuthorityId || undefined,- certificateTemplateId: data.certificateTemplateId+ certificatePolicyId: data.certificatePolicyId};if (data.enrollmentType === EnrollmentType.EST && data.estConfig) {@@ -770,10 +770,10 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }<Controllercontrol={control}- name="certificateTemplateId"+ name="certificatePolicyId"render={({ field: { onChange, ...field }, fieldState: { error } }) => (<FormControl- label="Certificate Template"+ label="Certificate Policy"isRequiredisError={Boolean(error)}errorText={error?.message}@@ -804,14 +804,14 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }}onChange(value);}}- placeholder="Select a certificate template"+ placeholder="Select a certificate policy"className="w-full"position="popper"isDisabled={Boolean(isEdit)}>- {certificateTemplates.map((template) => (- <SelectItem key={template.id} value={template.id}>- {template.name}+ {certificatePolicies.map((policy) => (+ <SelectItem key={policy.id} value={policy.id}>+ {policy.name}</SelectItem>))}</Select>diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/ProfileRow.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/ProfileRow.tsxindex 5834feea35..f1ca503f95 100644--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/ProfileRow.tsx+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/ProfileRow.tsx@@ -32,7 +32,7 @@ import {import { usePopUp, useToggle } from "@app/hooks";import { useGetInternalCaById } from "@app/hooks/api/ca/queries";import { IssuerType, TCertificateProfile } from "@app/hooks/api/certificateProfiles";-import { useGetCertificateTemplateV2ById } from "@app/hooks/api/certificateTemplates/queries";+import { useGetCertificatePolicyById } from "@app/hooks/api/certificatePolicies";import { CertificateIssuanceModal } from "@app/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal";interface Props {@@ -66,8 +66,8 @@ export const ProfileRow = ({setTimeout(() => setIsIdCopied.off(), 2000);}, [setIsIdCopied]);- const { data: templateData } = useGetCertificateTemplateV2ById({- templateId: profile.certificateTemplateId+ const { data: policyData } = useGetCertificatePolicyById({+ policyId: profile.certificatePolicyId});const getEnrollmentTypeBadge = (enrollmentType: string) => {@@ -111,7 +111,7 @@ export const ProfileRow = ({</Td><Td><span className="text-sm text-mineshaft-300">- {templateData?.name || profile.certificateTemplateId}+ {policyData?.name || profile.certificatePolicyId}</span></Td><Td className="text-right">diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/index.ts b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/index.tsdeleted file mode 100644index 9b609747f0..0000000000--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export { CertificateTemplatesV2Tab } from "./CertificateTemplatesV2Tab";-export { CreateTemplateModal } from "./CreateTemplateModal";-export { TemplateList } from "./TemplateList";diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/index.ts b/frontend/src/pages/cert-manager/PoliciesPage/components/index.tsindex a9b24b1dbb..046919a3e2 100644--- a/frontend/src/pages/cert-manager/PoliciesPage/components/index.ts+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/index.ts@@ -1,4 +1,4 @@+export { CertificatePoliciesTab } from "./CertificatePoliciesTab";export { CertificateProfilesTab } from "./CertificateProfilesTab";export { CertificatesTab } from "./CertificatesTab";-export { CertificateTemplatesV2Tab } from "./CertificateTemplatesV2Tab";export { PkiCollectionsTab } from "./PkiCollectionsTab";diff --git a/frontend/src/pages/project/RoleDetailsBySlugPage/components/CertificatePolicyPermissionConditions.tsx b/frontend/src/pages/project/RoleDetailsBySlugPage/components/CertificatePolicyPermissionConditions.tsxnew file mode 100644index 0000000000..f44dfc70c8--- /dev/null+++ b/frontend/src/pages/project/RoleDetailsBySlugPage/components/CertificatePolicyPermissionConditions.tsx@@ -0,0 +1,19 @@+import { ProjectPermissionSub } from "@app/context/ProjectPermissionContext/types";++import { ConditionsFields } from "./ConditionsFields";++type Props = {+ position?: number;+ isDisabled?: boolean;+};++export const CertificatePolicyPermissionConditions = ({ position = 0, isDisabled }: Props) => {+ return (+ <ConditionsFields+ isDisabled={isDisabled}+ subject={ProjectPermissionSub.CertificatePolicies}+ position={position}+ selectOptions={[{ value: "name", label: "Name" }]}+ />+ );+};diff --git a/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx b/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsxindex 7e2a1254e0..1c2597fe97 100644--- a/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx+++ b/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx@@ -8,6 +8,7 @@ import {ProjectPermissionActions,ProjectPermissionCertificateActions,ProjectPermissionCertificateAuthorityActions,+ ProjectPermissionCertificatePolicyActions,ProjectPermissionCertificateProfileActions,ProjectPermissionCmekActions,ProjectPermissionSub@@ -243,6 +244,13 @@ const CertificateProfilePolicyActionSchema = z.object({[ProjectPermissionCertificateProfileActions.RotateAcmeEabSecret]: z.boolean().optional()});+const CertificatePolicyPolicyActionSchema = z.object({+ [ProjectPermissionCertificatePolicyActions.Read]: z.boolean().optional(),+ [ProjectPermissionCertificatePolicyActions.Create]: z.boolean().optional(),+ [ProjectPermissionCertificatePolicyActions.Edit]: z.boolean().optional(),+ [ProjectPermissionCertificatePolicyActions.Delete]: z.boolean().optional()+});+const SecretEventsPolicyActionSchema = z.object({[ProjectPermissionSecretEventActions.SubscribeCreated]: z.boolean().optional(),[ProjectPermissionSecretEventActions.SubscribeUpdated]: z.boolean().optional(),@@ -457,6 +465,12 @@ export const projectRoleFormSchema = z.object({}).array().default([]),+ [ProjectPermissionSub.CertificatePolicies]: CertificatePolicyPolicyActionSchema.extend({+ inverted: z.boolean().optional(),+ conditions: ConditionSchema+ })+ .array()+ .default([]),[ProjectPermissionSub.SshCertificateAuthorities]: GeneralPolicyActionSchema.array().default([]),@@ -527,6 +541,7 @@ type TConditionalFields =| ProjectPermissionSub.CertificateAuthorities| ProjectPermissionSub.Certificates| ProjectPermissionSub.CertificateProfiles+ | ProjectPermissionSub.CertificatePolicies| ProjectPermissionSub.SshHosts| ProjectPermissionSub.SecretRotation| ProjectPermissionSub.Identity@@ -551,6 +566,7 @@ export const isConditionalSubjects = (subject === ProjectPermissionSub.CertificateAuthorities ||subject === ProjectPermissionSub.Certificates ||subject === ProjectPermissionSub.CertificateProfiles ||+ subject === ProjectPermissionSub.CertificatePolicies ||subject === ProjectPermissionSub.SecretSyncs ||subject === ProjectPermissionSub.PkiSyncs ||subject === ProjectPermissionSub.SecretEvents ||@@ -1303,6 +1319,29 @@ export const rolePermission2Form = (permissions: TProjectPermission[] = []) => {return;}+ if (subject === ProjectPermissionSub.CertificatePolicies) {+ if (!formVal[subject]) formVal[subject] = [];++ formVal[subject]!.push({+ [ProjectPermissionCertificatePolicyActions.Edit]: action.includes(+ ProjectPermissionCertificatePolicyActions.Edit+ ),+ [ProjectPermissionCertificatePolicyActions.Delete]: action.includes(+ ProjectPermissionCertificatePolicyActions.Delete+ ),+ [ProjectPermissionCertificatePolicyActions.Create]: action.includes(+ ProjectPermissionCertificatePolicyActions.Create+ ),+ [ProjectPermissionCertificatePolicyActions.Read]: action.includes(+ ProjectPermissionCertificatePolicyActions.Read+ ),+ conditions: conditions ? convertCaslConditionToFormOperator(conditions) : [],+ inverted+ });++ return;+ }+if (subject === ProjectPermissionSub.PamAccounts) {if (!formVal[subject]) formVal[subject] = [];@@ -1764,6 +1803,15 @@ export const PROJECT_PERMISSION_OBJECT: TProjectPermissionObject = {{ label: "Request Certificates", value: ProjectPermissionCertificateProfileActions.IssueCert }]},+ [ProjectPermissionSub.CertificatePolicies]: {+ title: "Certificate Policies",+ actions: [+ { label: "Read", value: ProjectPermissionCertificatePolicyActions.Read },+ { label: "Create", value: ProjectPermissionCertificatePolicyActions.Create },+ { label: "Modify", value: ProjectPermissionCertificatePolicyActions.Edit },+ { label: "Remove", value: ProjectPermissionCertificatePolicyActions.Delete }+ ]+ },[ProjectPermissionSub.SshCertificateAuthorities]: {title: "SSH Certificate Authorities",actions: [@@ -2148,8 +2196,9 @@ const CertificateManagerPermissionSubjects = (enabled = false) => ({[ProjectPermissionSub.PkiSubscribers]: enabled,[ProjectPermissionSub.PkiSyncs]: enabled,[ProjectPermissionSub.CertificateAuthorities]: enabled,- [ProjectPermissionSub.CertificateTemplates]: enabled,+ [ProjectPermissionSub.CertificateTemplates]: false, // Hidden from UI, accessible via API only[ProjectPermissionSub.CertificateProfiles]: enabled,+ [ProjectPermissionSub.CertificatePolicies]: enabled,[ProjectPermissionSub.Certificates]: enabled});diff --git a/frontend/src/pages/project/RoleDetailsBySlugPage/components/RolePermissionsSection.tsx b/frontend/src/pages/project/RoleDetailsBySlugPage/components/RolePermissionsSection.tsxindex 039b44de51..d43c65027e 100644--- a/frontend/src/pages/project/RoleDetailsBySlugPage/components/RolePermissionsSection.tsx+++ b/frontend/src/pages/project/RoleDetailsBySlugPage/components/RolePermissionsSection.tsx@@ -23,6 +23,7 @@ import { AddPoliciesButton } from "./AddPoliciesButton";import { AppConnectionPermissionConditions } from "./AppConnectionPermissionConditions";import { CertificateAuthorityPermissionConditions } from "./CertificateAuthorityPermissionConditions";import { CertificatePermissionConditions } from "./CertificatePermissionConditions";+import { CertificatePolicyPermissionConditions } from "./CertificatePolicyPermissionConditions";import { CertificateProfilePermissionConditions } from "./CertificateProfilePermissionConditions";import { DynamicSecretPermissionConditions } from "./DynamicSecretPermissionConditions";import { GeneralPermissionConditions } from "./GeneralPermissionConditions";@@ -111,6 +112,10 @@ export const renderConditionalComponents = (return <CertificateProfilePermissionConditions isDisabled={isDisabled} />;}+ if (subject === ProjectPermissionSub.CertificatePolicies) {+ return <CertificatePolicyPermissionConditions isDisabled={isDisabled} />;+ }+return <GeneralPermissionConditions isDisabled={isDisabled} type={subject} />;}