Skip to content

feat: add spire support to test apps - #1939

Merged
micpapal merged 6 commits into
mainfrom
feat/spire-support
Aug 4, 2026
Merged

feat: add spire support to test apps#1939
micpapal merged 6 commits into
mainfrom
feat/spire-support

Conversation

@micpapal

@micpapal micpapal commented Aug 4, 2026

Copy link
Copy Markdown
Member

Description

add spire authentication to test applications

Type of Change

  • Bugfix
  • New Feature
  • Breaking Change
  • Refactor
  • Documentation
  • Other (please describe)

Checklist

  • I have read the contributing guidelines
  • Existing issues have been referenced (where applicable)
  • I have verified this change is not present in other open pull requests
  • Functionality is documented
  • All code style checks pass
  • New code contribution is covered by automated tests
  • All new and existing tests pass

Summary by CodeRabbit

  • New Features
    • Added SPIRE/SPIFFE as an authentication option alongside shared-secret authentication.
    • Added command-line options for selecting authentication methods and configuring SPIRE connections.
    • Added usage examples for SPIRE/SPIFFE authentication.
  • Bug Fixes
    • Added endpoint-aware TLS handling for secure and non-secure control-plane URLs.
    • Added a timeout to participant invitation operations to prevent indefinite hangs.

Signed-off-by: Michele Papalini <micpapal@cisco.com>
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Receiver and sender test apps now support SPIRE/SPIFFE authentication as an alternative to shared secret authentication, selectable via a CLI argument. Control-plane/client TLS validation is now chosen based on the endpoint scheme (https vs http). Sender app's participant invite operation is wrapped with a 35-second timeout.

Changes

SPIRE Authentication Support

Layer / File(s) Summary
Receiver app SPIRE auth and TLS selection
crates/testing/src/bin/receiver_app.rs
Adds a conditional SpireConfig import, a CLI authentication-method selector with SPIRE socket/audience/target options, conditional TLS based on HTTPS scheme, and method-based provider/verifier construction with an error for unsupported methods.
Sender app SPIRE auth, TLS selection, and invite timeout
crates/testing/src/bin/sender_app.rs
Adds a conditional SpireConfig import, new CLI arguments (auth_method, spire_socket_path, spire_audiences, spire_target), conditional client TLS based on HTTPS scheme, method-based provider/verifier construction, updated documentation, and a 35-second timeout around the participant invite call.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant App as Receiver/Sender App
  participant Args as CLI Args
  participant SpireConfig
  participant AuthProvider
  participant ControlPlane

  App->>Args: parse auth_method
  alt auth_method == shared_secret
    Args->>AuthProvider: shared_secret_from_str
  else auth_method == spire
    Args->>SpireConfig: build socket_path, audience, target
    SpireConfig->>AuthProvider: AuthProvider::spire / AuthVerifier::spire
  else unsupported
    Args->>App: return error
  end
  App->>ControlPlane: connect with TLS (default if https, insecure if http)
Loading

Suggested reviewers: adamtagscherer

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the main change: adding SPIRE support to the test applications.
Description check ✅ Passed The description identifies the feature, classifies the change, and includes the required checklist, although several checklist items remain unchecked.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/spire-support

Comment @coderabbitai help to get the list of available commands.

@micpapal
micpapal marked this pull request as ready for review August 4, 2026 14:36
@micpapal
micpapal requested a review from a team as a code owner August 4, 2026 14:36
@micpapal
micpapal merged commit 8e7d8d4 into main Aug 4, 2026
19 of 20 checks passed
@micpapal
micpapal deleted the feat/spire-support branch August 4, 2026 14:59

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/testing/src/bin/receiver_app.rs`:
- Around line 121-127: Use case-insensitive HTTPS scheme detection when
selecting TLS configuration in the client configuration setup at
crates/testing/src/bin/receiver_app.rs lines 121-127 and
crates/testing/src/bin/sender_app.rs lines 180-186. Normalize the URI scheme
before checking for HTTPS so mixed-case https prefixes select
TlsClientConfig::default(), while non-HTTPS endpoints continue using
TlsClientConfig::insecure().

In `@crates/testing/src/bin/sender_app.rs`:
- Around line 304-313: Update the invite flow around
controller.invite_participant so the asynchronous controller-channel send and
its completion are both executed inside the 35-second tokio::time::timeout async
block. Preserve the existing “invite failed,” timeout, and completion-failed
context messages while ensuring timeout measurement starts before either await.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7507f3d0-473a-4f27-8a9a-bcd796dbdffa

📥 Commits

Reviewing files that changed from the base of the PR and between 10d5584 and e2297ab.

📒 Files selected for processing (2)
  • crates/testing/src/bin/receiver_app.rs
  • crates/testing/src/bin/sender_app.rs

Comment on lines +121 to +127
let client_config = ClientConfig::with_endpoint(&args.slim).with_tls_setting(
if args.slim.starts_with("https://") {
TlsClientConfig::default()
} else {
TlsClientConfig::insecure()
},
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

# Trace endpoint parsing and TLS configuration into the connection implementation.
ast-grep outline crates/config/src/client.rs --items all
ast-grep outline crates --items all --type function --match 'connect'
rg -n -C 8 --type rust \
  'async\s+fn\s+connect|fn\s+connect|Endpoint::from_shared|Uri::from_str|Url::parse|scheme_str|TlsClientConfig' \
  crates

Repository: agntcy/slim

Length of output: 50368


Security Misconfiguration (CWE-295): Improper Certificate Validation

Reachability: External

Use case-insensitive scheme matching when selecting TLS configuration.

Both sites use a case-sensitive starts_with("https://") check. A mixed-case HTTPS URI falls through to TlsClientConfig::insecure(), disabling certificate validation.

Apply normalized scheme logic in:

  • crates/testing/src/bin/receiver_app.rs#L121-L127
  • crates/testing/src/bin/sender_app.rs#L180-L186
📍 Affects 2 files
  • crates/testing/src/bin/receiver_app.rs#L121-L127 (this comment)
  • crates/testing/src/bin/sender_app.rs#L180-L186
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/testing/src/bin/receiver_app.rs` around lines 121 - 127, Use
case-insensitive HTTPS scheme detection when selecting TLS configuration in the
client configuration setup at crates/testing/src/bin/receiver_app.rs lines
121-127 and crates/testing/src/bin/sender_app.rs lines 180-186. Normalize the
URI scheme before checking for HTTPS so mixed-case https prefixes select
TlsClientConfig::default(), while non-HTTPS endpoints continue using
TlsClientConfig::insecure().

Comment on lines +304 to +313
tokio::time::timeout(
Duration::from_secs(35),
controller
.invite_participant(participant)
.await
.context("invite failed")?,
)
.await
.context("invite timed out after 35s")?
.context("invite completion failed")?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

# Inspect whether the initial invite future can wait on I/O or a channel.
ast-grep outline crates --items all --type function --match 'invite_participant'
rg -n -C 12 --type rust \
  'async\s+fn\s+invite_participant|fn\s+invite_participant|\binvite_participant\s*\(' \
  crates

Repository: agntcy/slim

Length of output: 50367


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- invite implementation ---'
sed -n '780,830p' crates/session/src/session_controller.rs

printf '%s\n' '--- completion handle definition and publish path ---'
rg -n -C 10 'type CompletionHandle|struct CompletionHandle|pub type CompletionHandle|async fn publish_message|fn publish_message' crates/session crates
printf '%s\n' '--- sender imports and target block ---'
sed -n '1,45p' crates/testing/src/bin/sender_app.rs
sed -n '296,318p' crates/testing/src/bin/sender_app.rs

printf '%s\n' '--- analogous timeout usage ---'
sed -n '1378,1398p' crates/slimctl/src/commands/bench.rs

Repository: agntcy/slim

Length of output: 12890


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- app-to-session publish path ---'
rg -n -C 18 'async fn on_message_from_app|fn on_message_from_app|on_message_from_app\s*\(' crates/session/src crates
printf '%s\n' '--- completion future implementation ---'
sed -n '1,180p' crates/session/src/completion_handle.rs
printf '%s\n' '--- relevant Cargo/toolchain metadata ---'
rg -n 'rust-version|edition' Cargo.toml crates/session/Cargo.toml crates/testing/Cargo.toml

Repository: agntcy/slim

Length of output: 33584


Wrap both invite awaits in the 35-second timeout. invite_participant awaits an asynchronous controller-channel send, so it can block before the current timeout starts. Place both awaits inside the timed async block.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/testing/src/bin/sender_app.rs` around lines 304 - 313, Update the
invite flow around controller.invite_participant so the asynchronous
controller-channel send and its completion are both executed inside the
35-second tokio::time::timeout async block. Preserve the existing “invite
failed,” timeout, and completion-failed context messages while ensuring timeout
measurement starts before either await.

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