Skip to content

server test to verify auth callout in operator mode & default sentinel still preserves nonce challenge flow#8024

Open
borjaetxebarria wants to merge 2 commits intonats-io:mainfrom
borjaetxebarria:nkey_nonce_auth_callout_operator_mode
Open

server test to verify auth callout in operator mode & default sentinel still preserves nonce challenge flow#8024
borjaetxebarria wants to merge 2 commits intonats-io:mainfrom
borjaetxebarria:nkey_nonce_auth_callout_operator_mode

Conversation

@borjaetxebarria
Copy link
Copy Markdown

@borjaetxebarria borjaetxebarria commented Apr 10, 2026

AuthCallout in Operator mode + nkey challenge

Decentralized authentication (operator mode) uses nkeys + nonce challenge like static nkeys authentication, but ties them to a trust chain:
nkey → user JWT → account JWT → operator

Clients must provide:

  • Their nkey
  • Their user JWT

This could be done using a creds file or a jwt+seed

https://pkg.go.dev/github.com/nats-io/nats.go#UserCredentials
https://pkg.go.dev/github.com/nats-io/nats.go#UserJWTAndSeed

Those are convenience wrappers on top of:
https://pkg.go.dev/github.com/nats-io/nats.go#UserJWT

Auth Callout in Operator Mode - constraint: Sentinel JWT vs NKey

Clients must normally send a sentinel JWT (a bearer token, typically non-expiring) to select the appropriate auth callout flow.

However, per the client API:

https://pkg.go.dev/github.com/nats-io/nats.go#UserJWT

The UserJWT option and Nkey option are mutually exclusive.

This means we cannot both send a sentinel JWT, and use nkey-based nonce authentication.

The Loophole: default_sentinel

With the introduction of the default_sentinel option:

#6577

The client no longer needs to send the sentinel JWT explicitly. The server applies a default sentinel internally

So the client can use an nkey and still benefit from nonce challenge authentication

This effectively enables an authentication flow with auth callout that still leverages the nonce challenge.

Signed-off-by: Borja Etxebarria borja.bit@gmail.com

Signed-off-by: Borja Etxebarria <borja.bit@gmail.com>
@borjaetxebarria borjaetxebarria requested a review from a team as a code owner April 10, 2026 17:05
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 586265f9f5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread server/auth_callout_test.go Outdated
Comment thread server/auth_callout_test.go Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e8af2c9a7a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

require_NoError(t, err)
nkPub, err := nkUsr.PublicKey()
require_NoError(t, err)
nc = ac.Connect(nats.Token(nonceChallengeToken), nats.Nkey(nkPub, func(nonce []byte) ([]byte, error) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove explicit token to exercise default_sentinel path

This new nonce-challenge assertion does not actually cover the default_sentinel flow it describes, because the connection still sends an explicit token (nats.Token(nonceChallengeToken)). If server-side default-sentinel injection regresses for clients that omit token/JWT, this test would keep passing since it never exercises that code path. The scenario under test should connect with only the NKey option (no explicit token) and validate the callout still receives the expected sentinel and signed nonce.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Token, or user, or password can be included or not, as these are independent from the sentinel logic - default sentinel just requires that the client does not include a JWT.
In this case the token is just included internally by the test to trigger multiple sub-tests.

@borjaetxebarria
Copy link
Copy Markdown
Author

@codex re-review

@borjaetxebarria
Copy link
Copy Markdown
Author

@codex review

@borjaetxebarria borjaetxebarria changed the title Update auth_callout_test.go server test to verify auth callout in operator mode & default sentinel still preserves nonce challenge flow May 5, 2026
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@MauriceVanVeen
Copy link
Copy Markdown
Member

@claude, review.

@synadia-claude-reviewer

This comment was marked as resolved.

Copy link
Copy Markdown
Member

@MauriceVanVeen MauriceVanVeen left a comment

Choose a reason for hiding this comment

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

LGTM, but could the commits be squashed down into one?

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