Skip to content

NCO-60: Add mTLS (client certificate) authorization#54

Merged
davidkelly merged 8 commits intomasterfrom
dk/60
Apr 8, 2026
Merged

NCO-60: Add mTLS (client certificate) authorization#54
davidkelly merged 8 commits intomasterfrom
dk/60

Conversation

@davidkelly
Copy link
Copy Markdown
Collaborator

  • Add CertificateCredential with FromPkcs12 and FromPem factory methods
  • Skip Authorization header for mTLS — authentication via TLS handshake
  • Rebuild HTTP handler on certificate rotation with deferred disposal
    (1-minute grace period for in-flight request draining)
  • Scope handler rebuilds to CertificateCredential changes only
  • Add functional tests using cbdinocluster client certs, including
    credential swap test with a second user
  • Add unit tests for handler lifecycle behavior
  • Update README and getting-started docs

Redesign ICredential as a single-property interface (AuthorizationHeader) and add
JwtCredential for Bearer token auth alongside the existing Credential record. Both
credential types pre-compute their auth header at construction.

Add Func<ICredential> provider pattern through AuthenticationHandler to enable
credential hot-swap without rebuilding the HTTP pipeline. Cluster.UpdateCredential()
performs a thread-safe volatile swap with a same-type guard.

Preserve backward compatibility:
* Add Credential-typed forwarding overloads on Cluster.Create() for binary compat
  with existing compiled applications
* Override PrintMembers on credential records to prevent leaking passwords, tokens,
  and auth headers into ToString() output

Add unit tests for credentials, AuthenticationHandler, and UpdateCredential.
* Add CertificateCredential with FromPkcs12 and FromPem factory methods
* Skip Authorization header for mTLS — authentication via TLS handshake
* Rebuild HTTP handler on certificate rotation with deferred disposal
  (1-minute grace period for in-flight request draining)
* Scope handler rebuilds to CertificateCredential changes only
* Add functional tests using cbdinocluster client certs, including
  credential swap test with a second user
* Add unit tests for handler lifecycle behavior
* Update README and getting-started docs
@davidkelly
Copy link
Copy Markdown
Collaborator Author

NOTE: this is based on dk/59 branch - which is #53

@davidkelly davidkelly marked this pull request as ready for review April 4, 2026 21:44
/// Excludes sensitive certificate details from the record's ToString output.
/// Only Subject and Thumbprint are included.
/// </summary>
private bool PrintMembers(StringBuilder builder)
Copy link
Copy Markdown
Collaborator

@emilienbev emilienbev Apr 7, 2026

Choose a reason for hiding this comment

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

Did you mean this to be protected?

Suggested change
private bool PrintMembers(StringBuilder builder)
protected bool PrintMembers(StringBuilder builder)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Since the class is sealed, private seems fine. Nobody can derive a class from it, so no need for any subclass access to it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fair enough 👍

@davidkelly davidkelly merged commit 1c88561 into master Apr 8, 2026
3 checks passed
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.

2 participants