feat: generate token if needed#6
Conversation
|
Warning Review limit reached
More reviews will be available in 21 minutes and 58 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR adds Private Ephemeral Rollup (PER) TEE authentication support. A new core auth module implements challenge/response authentication, URL helpers manage session tokens, and both bencher and assist applications conditionally authenticate at startup using vault-signed callbacks. ChangesPrivate Ephemeral Rollup TEE Authentication
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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 `@assist/src/close.rs`:
- Around line 25-32: You load the vault with crate::common::load_vault(&config)
and then call Closer::new(&config).await which loads the vault again; change
Closer::new to accept the already-loaded vault (e.g., add a parameter like
vault: &Vault or Vault) and update its callers so you pass the vault you created
here instead of letting Closer::new reload it; adjust the Closer::new signature
and implementation to use the provided vault and remove the redundant load there
(refer to load_vault, vault variable, core::auth::authenticate_tee, and
Closer::new to locate the spots to change).
In `@core/src/auth.rs`:
- Around line 40-48: The reqwest client is created without a timeout which can
hang the auth challenge request; change the creation of client (the variable
named client used to request ChallengeResponse from
"{base_url}/auth/challenge?pubkey={pubkey}") to use
reqwest::Client::builder().timeout(Duration::from_secs(N)).build()? (pick a
sensible N like 10 or 30) and add the necessary std::time::Duration import;
ensure the build() result is handled (propagate or return the error) so the code
still awaits and parses the ChallengeResponse as before.
- Around line 70-75: The current logic parses the response JSON unconditionally
which causes JSON deserialization errors to mask real HTTP errors; update the
code around the response handling (the local variable response and the
LoginResponse parsing) to first check response.status().is_success(), and only
call response.json().await to deserialize into LoginResponse when succeeded is
true; if not succeeded, call response.text().await to capture the server body
(falling back to a generic message if empty) and return an Err with that text
(e.g., "TEE authentication failed: <body>"); ensure any JSON parse errors on
successful responses are still propagated as before.
In `@core/src/types.rs`:
- Around line 132-140: with_token currently injects token raw into the query
which can break parsing; percent-encode the token before building
path_and_query. Add percent-encoding = "2" to Cargo.toml, import
percent_encoding (e.g. percent_encode_str or utf8_percent_encode with an
appropriate encode set) in types.rs, call it on token and use the encoded string
in both branches where path_and_query is built inside with_token, and leave the
final full -> hyper::Uri parse and Url wrapper unchanged.
🪄 Autofix (Beta)
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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 379a5da0-6c53-4448-812a-f70c70a52b14
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (8)
assist/src/close.rsbencher/src/main.rsconfig.example.tomlcore/Cargo.tomlcore/src/auth.rscore/src/config.rscore/src/lib.rscore/src/types.rs
TEE validators need an auth token to accept some requests. This PR adds the auth as part of the flow to avoid having to do it manually and put the token in the config
Summary by CodeRabbit
teeconfiguration option, automatic authentication occurs during startup and session tokens are transparently managed for secure API communication.