Skip to content

Conversation

@chvck
Copy link
Collaborator

@chvck chvck commented Nov 19, 2025

Motivation

We need a way to do mtls rotation and also to support JWT auth. To achieve this we need to refactor how auth is done. This is technically a breaking change but we are not aware of any users other than gocb.

Changes

Remove username, password, and certificate.
Create Authenticator interface and certificate and basic authenticators. Expose a ReconfigureAuthenticator function on routing client.

@chvck chvck requested a review from Copilot November 19, 2025 15:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors authentication to support certificate rotation and JWT authentication by introducing an Authenticator interface. The changes replace direct username/password/certificate fields with a flexible authenticator pattern, enabling dynamic credential updates through the new ReconfigureAuthenticator method.

Key Changes:

  • Introduced Authenticator interface with BasicAuthenticator and CertificateAuthenticator implementations
  • Replaced separate username, password, and certificate fields with a single Authenticator field in options structs
  • Added ReconfigureAuthenticator method to RoutingClient for dynamic credential rotation

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
auth.go Defines the new Authenticator interface and implements BasicAuthenticator and CertificateAuthenticator with atomic credential storage
routingclient.go Updates DialOptions to use Authenticator and adds ReconfigureAuthenticator method for credential rotation
routingconn.go Refactors connection setup to use the Authenticator interface via type switch instead of separate credential fields
error.go Adds ErrAuthenticatorMismatch error for authenticator type conflicts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Motivation
----------
We need a way to do mtls rotation and also to support JWT auth.
To achieve this we need to refactor how auth is done.
This is technically a breaking change but we are not aware of any
users other than gocb.

Changes
-------
Remove username, password, and certificate.
Create Authenticator interface and certificate and basic authenticators.
Expose a ReconfigureAuthenticator function on routing client.
@chvck chvck force-pushed the GOCBC-1769_creds_rotation branch from 45e1b31 to e3c5c03 Compare November 19, 2025 16:02
@chvck chvck merged commit fa952f7 into master Nov 20, 2025
4 checks passed
@chvck chvck deleted the GOCBC-1769_creds_rotation branch November 20, 2025 11:18
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