Skip to content

feat(auth) Add CLI auth session support#63

Merged
pthurlow merged 2 commits into
mainfrom
feat/jwt-auth
Apr 27, 2026
Merged

feat(auth) Add CLI auth session support#63
pthurlow merged 2 commits into
mainfrom
feat/jwt-auth

Conversation

@pthurlow
Copy link
Copy Markdown
Collaborator

No description provided.

@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 27, 2026

Codecov Report

❌ Patch coverage is 90.82484% with 99 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/util.rs 68.85% 38 Missing ⚠️
src/auth.rs 83.17% 35 Missing ⚠️
src/api.rs 70.00% 15 Missing ⚠️
src/embedding.rs 0.00% 8 Missing ⚠️
src/jwt.rs 99.69% 2 Missing ⚠️
src/skill.rs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Comment thread src/jwt.rs
Comment on lines +115 to +119
Session {
access_token: resp.access_token,
access_expires_at: now_unix() + resp.expires_in,
refresh_token,
refresh_expires_at: now_unix() + refresh_ttl,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

super nit: now_unix() is called twice, so access_expires_at and refresh_expires_at can be computed at slightly different wall-clock instants. Capture it once at the top of the function:

Suggested change
Session {
access_token: resp.access_token,
access_expires_at: now_unix() + resp.expires_in,
refresh_token,
refresh_expires_at: now_unix() + refresh_ttl,
let now = now_unix();
Session {
access_token: resp.access_token,
access_expires_at: now + resp.expires_in,
refresh_token,
refresh_expires_at: now + refresh_ttl,
source: source.to_string(),
}

(not blocking)

Comment thread src/util.rs
Comment on lines +79 to +82
pub fn mask_credential(s: &str) -> String {
if s.len() > 4 {
format!("{}...", &s[..4])
} else {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

super nit: &s[..4] is byte-indexed and will panic if the first 4 bytes straddle a multi-byte UTF-8 character. Tokens are always ASCII in practice, but the idiomatic Rust form is safer:

Suggested change
pub fn mask_credential(s: &str) -> String {
if s.len() > 4 {
format!("{}...", &s[..4])
} else {
format!("{}...", s.chars().take(4).collect::<String>())

(not blocking)

@pthurlow pthurlow merged commit 8546919 into main Apr 27, 2026
9 of 10 checks passed
@pthurlow pthurlow deleted the feat/jwt-auth branch April 27, 2026 23:33
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.

1 participant