Skip to content

Pass in enabled mTLS spec when a cert is provided#86

Closed
david049 wants to merge 9 commits into
mainfrom
dliu/fixmtlsnscreation
Closed

Pass in enabled mTLS spec when a cert is provided#86
david049 wants to merge 9 commits into
mainfrom
dliu/fixmtlsnscreation

Conversation

@david049

@david049 david049 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

What was changed

Enable mtls auth when a cert is passed in

Why?

Checklist

  1. Closes

  2. How was this tested:

  1. Any docs updates needed?

Note

Medium Risk
Changes namespace auth spec sent to Temporal Cloud; incorrect defaults could leave mTLS disabled or enable it unexpectedly, but the change aligns behavior with supplying cert material.

Overview
mTLS is now explicitly turned on whenever the CLI or internal namespace client sends CA certificates or certificate filters, by setting MtlsAuthSpec.Enabled: true on create and on namespace updates that initialize or extend MtlsAuth.

CreateNamespace sets Enabled when --ca-certificate is provided and when certificate filters are set (including filters-only). The internal AddCACerts, DeleteCACerts (when a bundle remains), and cert-filter add/remove paths use the same default when they create a new MtlsAuth block.

Unit expectations and the namespace create integration test were updated to assert Enabled, accepted CA material, and filters; create e2e now provisions a test CA via --ca-certificate instead of relying only on API key auth for that scenario.

Reviewed by Cursor Bugbot for commit 72e041b. Bugbot is set up for automated code reviews on this repo. Configure here.

@david049 david049 requested a review from a team as a code owner June 22, 2026 18:38
// Ensure MtlsAuth is initialized before accessing its fields
if spec.MtlsAuth == nil {
spec.MtlsAuth = &namespacev1.MtlsAuthSpec{}
spec.MtlsAuth = &namespacev1.MtlsAuthSpec{Enabled: true}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabled unset on existing MtlsAuth

High Severity

In AddCACerts, MtlsAuth.Enabled is set to true only when spec.MtlsAuth is nil. When the namespace already has an MtlsAuth block (the usual add-cert path), only AcceptedClientCa is updated, so Enabled stays false and mTLS can remain off despite CA changes.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit adf5848. Configure here.

khisakuni
khisakuni previously approved these changes Jun 22, 2026
// Ensure MtlsAuth is initialized before accessing its fields
if spec.MtlsAuth == nil {
spec.MtlsAuth = &namespacev1.MtlsAuthSpec{}
spec.MtlsAuth = &namespacev1.MtlsAuthSpec{Enabled: true}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing mTLS stays disabled

High Severity

AddCACerts and AddCertFilters only set MtlsAuth Enabled when the spec pointer was nil. If the namespace already has a non-nil MtlsAuth with Enabled false (e.g. after older create paths that supplied CAs without enabling), adding CAs or filters updates those fields but leaves mTLS disabled, so the PR’s intent is not applied on update.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 93abd77. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there ever a case where we add certs/filters and we don't have it enabled?

// Update the spec with the new filter list
if spec.MtlsAuth == nil {
spec.MtlsAuth = &namespacev1.MtlsAuthSpec{}
spec.MtlsAuth = &namespacev1.MtlsAuthSpec{Enabled: true}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete filters enables empty mTLS

Low Severity

In DeleteCertFilters, when MtlsAuth was nil the code now creates MtlsAuthSpec{Enabled: true} and pushes an update with empty CertificateFilters. A delete on a namespace with no mTLS config can turn mTLS on without CA material, which this change introduces via Enabled: true on that init path.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 93abd77. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there ever a case where we have cert filters enabled, we delete it, and the namespace has enabled:false on mtls?

Comment thread temporalcloudcli/commands.namespace_test.go
// Ensure MtlsAuth is initialized
if spec.MtlsAuth == nil {
spec.MtlsAuth = &namespacev1.MtlsAuthSpec{}
spec.MtlsAuth = &namespacev1.MtlsAuthSpec{Enabled: true}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mTLS not enabled on add

Medium Severity

This PR turns on MtlsAuth.Enabled when creating a namespace with certs or filters, but AddCertFilters and AddCACerts only set Enabled: true when MtlsAuth was nil. If the namespace already has an MtlsAuth block with Enabled: false, adding filters or CAs updates the spec without enabling mTLS.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9612dd7. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 5 total unresolved issues (including 4 from previous reviews).

Fix All in Cursor

Reviewed by Cursor Bugbot for commit a1a1098. Configure here.

// Ensure MtlsAuth is initialized before accessing its fields
if spec.MtlsAuth == nil {
spec.MtlsAuth = &namespacev1.MtlsAuthSpec{}
spec.MtlsAuth = &namespacev1.MtlsAuthSpec{Enabled: true}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mTLS stays disabled adding certs

Medium Severity

In DeleteCertFilters, when spec.MtlsAuth is nil the code creates MtlsAuth with Enabled: true before assigning the filter list. With no existing filters that yields an update that turns mTLS on with no CAs and no filters.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a1a1098. Configure here.

@david049 david049 closed this Jun 25, 2026
@david049 david049 deleted the dliu/fixmtlsnscreation branch June 25, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants