Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions async-nats/src/auth.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
use crate::{options::CallbackArg1, AuthError};

/// Authentication configuration used when connecting to the NATS server.
///
/// This struct holds the various credentials that can be supplied to
/// authenticate a client connection. Depending on the server configuration,
/// only some of these fields will be relevant, and some combinations are
/// mutually exclusive (for example, using `jwt`/`signature_callback` together
/// is a different authentication mechanism than plain `username`/`password`
/// or a bare `token`).
#[derive(Default)]

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.

🦩 🟠 Public Auth struct fields lack any doc comments or examples

Added /// doc comments to the Auth struct definition and each of its public fields (jwt, nkey, signature, username, password, token) as well as the crate-private signature_callback field in async-nats/src/auth.rs, describing their purpose and noting the mutual relationships (jwt+signature/signature_callback, username+password, token as alternative). This is a documentation-only change with no functional modifications. Confidence is not higher because the exact mutual-exclusivity semantics and exact server-side behavior are inferred from field names and typical NATS auth patterns rather than verified against server documentation, so a maintainer familiar with the precise auth flow should review the wording for accuracy.

🤖 Prompt for AI agents
In async-nats/src/auth.rs around line 3, review and complete this code-review fix: Public Auth struct fields lack any doc comments or examples.
What the draft fix changed: Added `///` doc comments to the `Auth` struct definition and each of its public fields (`jwt`, `nkey`, `signature`, `username`, `password`, `token`) as well as the crate-private `signature_callback` field in `async-nats/src/auth.rs`, describing their purpose and noting the mutual relationships (jwt+signature/signature_callback, username+password, token as alternative). This is a documentation-only change with no functional modifications. Confidence is not higher because the exact mutual-exclusivity semantics and exact server-side behavior are inferred from field names and typical NATS auth patterns rather than verified against server documentation, so a maintainer familiar with the precise auth flow should review the wording for accuracy.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.

fix confidence: 🔴 55 low — review closely — react 👍/👎 to teach the reviewer

pub struct Auth {
/// A user JWT used for JWT-based authentication. When set, it is
/// typically paired with `signature_callback` (or `signature`), which
/// is used to sign the server-provided nonce with the corresponding
/// NKEY to prove ownership of the JWT.
pub jwt: Option<String>,
/// An NKEY (public key) used for NKEY-based authentication, where the
/// server issues a nonce that must be signed with the matching seed.
pub nkey: Option<String>,
/// Callback invoked with a server-provided nonce to produce a signature,
/// used in conjunction with `jwt` for JWT-based authentication. This is
/// crate-private and set internally when a signing callback is
/// configured on the connection options.
pub(crate) signature_callback: Option<CallbackArg1<String, Result<String, AuthError>>>,
/// A pre-computed signature bytes, used together with `jwt` for
/// JWT-based authentication when a `signature_callback` is not used.
pub signature: Option<Vec<u8>>,
/// Username for basic username/password authentication.
pub username: Option<String>,
/// Password for basic username/password authentication, used together
/// with `username`.
pub password: Option<String>,
/// A bare authentication token, used as an alternative to
/// username/password or JWT/NKEY based authentication.
pub token: Option<String>,
}

Expand Down
Loading