Skip to content

Add OAuth2 login command#271

Open
atimin wants to merge 4 commits into
mainfrom
add-login-command
Open

Add OAuth2 login command#271
atimin wants to merge 4 commits into
mainfrom
add-login-command

Conversation

@atimin

@atimin atimin commented Jul 20, 2026

Copy link
Copy Markdown
Member

Closes #

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • CHANGELOG.md has been updated (for bug fixes / features / docs)

What kind of change does this PR introduce?

Feature

What was changed?

Add reduct-cli login <alias-or-url> for OAuth2 authentication through a local loopback callback server. The command stores a received token in an alias configuration or prints an authenticated direct URL.

Add focused coverage for login targets, callback parsing, redirect URL generation, configuration persistence, and receiving HTTP callbacks.

Add a reusable Kilo create-pr skill that fetches the shared PR template and records the created PR in the changelog.

Related issues

None.

Does this PR introduce a breaking change?

No.

Other information:

Testing:

  • cargo test --locked cmd::login passed.
  • cargo test --locked could not complete because 74 existing integration-style tests require ReductStore at localhost:8383, which was not running.

@atimin
atimin requested a review from AnthonyCvn July 20, 2026 18:30
Comment thread src/cmd/login.rs
}

struct Callback {
access_token: String,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would be better to have a one-time code here and request the token over https to avoid having the token in the URL.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, it makes sense to do. I thought at the current stage it's a bit overkill keeping in mind that the tokens are stored unencrypted on the disk and if you have access to the localhost you can't protect them only with one-time code. However, it's better to implement from the beginning since the gateway API must be changed.

Comment thread src/cmd/login.rs
Ok(url)
}

async fn receive_callback(listener: &TcpListener) -> anyhow::Result<Callback> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need to check who sent the request for security.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think this would be too much, since the worst that could happen someone sends an invalid token.

Comment thread src/cmd/login.rs
.context("Failed to start local OAuth2 callback server")?;
let login_url = login_url(&target.url, listener.local_addr()?)?;

output!(ctx, "Open this URL to authenticate:\n {login_url}");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's try to open the browser and keep that as fallback ?

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.

2 participants