auth.rs

Rust commands for logging in to, logging out of, checking, and cancelling the Claude Code command-line tool inside a desktop app.

In plain words
What is it for?
Use them to connect frontend buttons to Claude Code authentication, report whether the CLI is installed or logged in, and stop a stuck login attempt.
Why use it?
They let a packaged app run the login flow even when the operating system does not expose the bundled command-line tool through its normal command search path.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/netmindai-open/narranexus/auth.rs
Clone the repo
git clone --depth 1 https://github.com/NetMindAI-Open/NarraNexus
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,170 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01170
Opus 5 $0.00000 $0.00585
Sonnet 5 $0.00000 $0.00234
Haiku 4.5 $0.00000 $0.00117

Measured 3d ago against content hash 18c8ffaa3367, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

auth.rs scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.mindflow/mirror/tauri/src-tauri/src/commands/auth.rs.md · 99 lines

How it starts

The opening of the file, as written. The whole thing — 99 lines — stays where its author put it; the contents beside it link to each section on GitHub.

auth.rs — IPC commands for Claude Code OAuth login/logout/status

Four commands exposed to the frontend:

  • trigger_claude_login → spawns claude auth login, records the child PID into AppState::claude_login_pid, then awaits the OAuth flow
  • trigger_claude_logout → spawns claude auth logout, revokes local credentials
  • cancel_claude_login → SIGTERMs the recorded login PID; used by the frontend's 600s timeout (and any future explicit Cancel button) to abort a stuck login without holding the Child handle across awaits
  • get_claude_login_statusClaudeLoginStatus { cli_installed, logged_in }, non-blocking

Why exists

The DMG-packaged app ships its own bundled claude CLI under Contents/Resources/resources/nodejs/node_modules/.bin/claude, but a Finder-launched .app inherits the launchd minimal PATH (/usr/bin:/bin:/usr/sbin:/sbin) which never sees that bin dir. Without an in-app login flow, users had to drop to Terminal to run claude auth login — defeating the purpose of bundling the CLI.

These commands inject the bundled paths into PATH (same trick process_manager.rs uses for the Python sidecars) so the frontend can fire login/logout/status checks without ever leaving the app.

Design decisions

build_child_path() helper — DRYs the PATH-augmentation logic that all three commands need. Earlier inline copies drifted; the helper makes intent obvious and removes accidental divergence.

Login + Logout are blocking, status is notclaude auth login opens a browser and waits for the user to finish OAuth, so the Tauri command awaits .status(). Status is fire-and-parse so the frontend can poll cheaply.

Credentials shared with user-installed CLI — both write to ~/.claude/.credentials.json. There's no isolation, which is desired: logging in via the DMG's CLI also unlocks the user's terminal CLI, and vice versa.

Stdio drainers (drain_to_log)

Both login and logout pipe stdout+stderr from the spawned claude binary. A piped fd that nobody reads is a deadlock waiting to happen — once the kernel pipe buffer (~16 KB on macOS) fills, the child blocks on its next write(). This is the same failure mode that hit process_manager.rs Python sidecars before its log drainer was added (commit 5cf8c1d — "chat hangs at agent loop step 3.2").

Read the full file on GitHub · 99 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 99 lines · 0 tokens per session scan A 18c8ffaa3367

Subscribe to this mod's changes

auth.rs is a command published in the GitHub repository NetMindAI-Open/NarraNexus (84 stars, last pushed 9d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,170 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.