Repository navigation
Conversation
Add `nemo-relay auth login|token|logout`. `login` runs the OAuth 2.0 device authorization grant against an OpenID Connect issuer and keeps the sign-in in the per-user config directory with owner-only access. `token` prints a current access token and refreshes it near expiry, so an `[upstream.openai_api_key_helper]` can supply it to every upstream request without a separate credential tool. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: flazouh <[email protected]>
Follow RFC 8628 polling rules, keep the sign-in on transient issuer errors, lock login, refresh and logout, require same-origin endpoints, and let login and logout read the issuer, client ID and scopes from the configured API key helper. Document the sign-in. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: flazouh <[email protected]>
Replace the API key helper wiring with [upstream.openai_oidc] and
[upstream.anthropic_oidc]. The gateway reads the stored sign-in for each
upstream request, so the token expiry and a logout apply at once, and
a missing sign-in returns HTTP 401 naming nemo-relay auth login.
- auth login and logout read the provider from the effective config,
including --config, and support an Anthropic-only setup.
- Device polling keeps the issuer interval and slow_down without a cap,
checks expiry before each poll, and retries network errors.
- OAuth error codes and descriptions reach the user.
- nemo-relay doctor reports each configured sign-in state.
- Split the sign-in code into oidc/{mod,client,session}.rs.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: flazouh <[email protected]>
…h errors - A higher config layer replaces [upstream.*_oidc] as a whole, like an API key helper, so an issuer and a client ID from different layers never mix. - A token reply without expires_in is refused instead of being stored as an expired session. - A temporary refresh failure keeps using an access token that has not expired yet. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: flazouh <[email protected]>
preset = "openrouter" in [upstream.*_oidc] and --preset openrouter on nemo-relay auth set OpenRouter's issuer, public client ID and scopes, so users do not paste a client ID into config.toml. Explicit fields still override the preset. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: flazouh <[email protected]>
One line in [upstream] now sets both base URLs and an OpenRouter sign-in for each provider. Fields written next to the preset win, and a base URL changed by the same layer, a higher layer or an environment variable drops that provider's sign-in. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: flazouh <[email protected]>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
willkill07
requested changes
Nov 4, 2026
Comment on lines
+796
to
+798
| Fields written next to the preset win. A provider whose base URL is set to | ||
| another address, by the same layer, a higher layer, or an environment variable, | ||
| does not get the preset's sign-in. |
Member
There was a problem hiding this comment.
I think this should be more strict. Presets should not be combined with other options.
The gateway read the time once, before the lock wait, discovery and the refresh request. A token that expired during a slow failed refresh was still returned, and a refreshed token lost the time the request took. The token path now takes a clock: it reads it again before it uses the fallback token, and the refresh reads it when the reply arrives. A preset in [upstream.<provider>_oidc] now holds no other field, and auth login --preset cannot be combined with --issuer, --client-id or --scope. Each case is an error that names the field. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: flazouh <[email protected]>
Signed-off-by: flazouh <[email protected]> # Conflicts: # crates/cli/tests/coverage/commands/auth_tests.rs
A file that sets [upstream] preset and also a field the preset fills (either base URL, an *_oidc section, or another credential for those providers) is now a configuration error that names the field. Other [upstream] settings can still sit next to the preset. A higher layer or an environment variable can still change a base URL, and that provider then loses the preset sign-in. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: flazouh <[email protected]>
A request that waits too long for another request's refresh now reads the stored sign-in again and uses its access token while it is unexpired, instead of failing. The sign-in file is keyed by issuer, client ID and scope, so sources with other scopes no longer overwrite each other. The docs list the OIDC sign-in first in the credential order. Signed-off-by: flazouh <[email protected]>
Signed-off-by: flazouh <[email protected]>
The architecture test limits direct stderr to emergency and UI boundaries, so auth login and logout print their status on stdout, as the plugin lifecycle commands do. The credential-order docs say an inbound credential is kept only without an oidc section, since a configured section with no sign-in fails. Signed-off-by: flazouh <[email protected]>
Signed-off-by: flazouh <[email protected]>
1 of 2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Stacked on #1611. Review only these two commits:
The merge commits only bring in new #1611 heads.
Adds
[upstream] preset = "openrouter", so one line sets up both providers for OpenRouter:It stands for:
Both sign-ins use the same issuer and client, so one
nemo-relay auth logincovers both, with no--provider.Details
Exclusive in its file. The preset stands for both base URLs and both sign-ins, so it is not combined with them. A file that sets
[upstream] presetand alsoopenai_base_url,anthropic_base_url,openai_oidc,anthropic_oidc, or another credential for those providers (*_api_key,*_auth_header,*_api_key_helper) is a configuration error that names the file and the field. Other[upstream]settings, such as timeouts, can sit next to the preset.Layering. Each file expands its preset before the merge, so the existing layering rules apply unchanged:
NEMO_RELAY_OPENAI_BASE_URLorNEMO_RELAY_ANTHROPIC_BASE_URLset to another address clears that provider's sign-in, through the existingapply_env_configrule.FileUpstreamConfigrejects it with its name.I kept the override across layers on purpose. Rejecting it would stop a user from pointing one provider at their own gateway under a system preset.
OidcPresetnow also holds the two base URLs. The per-section[upstream.<provider>_oidc] presetfrom #1611 stays.Docs. The OIDC section of
docs/nemo-relay-cli/basic-usage.mdxshows the one-line form first, then the per-section form for another provider or a gateway in front of OpenRouter.Tests. Each new test was seen failing before its change:
auth loginwith only the[upstream]preset needs no--provider.The auth tests that load a config file now hold the environment lock with the two base-URL variables removed, so they do not race the environment test under
cargo test.cargo clippy -p nemo-relay-cli --all-targets -- -D warningsandcargo fmt --checkpass.cargo test -p nemo-relay-cli --lib -- oidc commands::auth error::tests configuration::tests --test-threads=1passes exceptmanaged_worker_dynamic_plugin_loading_reads_user_lifecycle_state, which also fails on #1611's head on this machine (it depends on the umask).🤖 Generated with Claude Code