Skip to content

Comments

feat: implement rust server OAuth authorization#1508

Open
trim21 wants to merge 7 commits intomasterfrom
rust-api
Open

feat: implement rust server OAuth authorization#1508
trim21 wants to merge 7 commits intomasterfrom
rust-api

Conversation

@trim21
Copy link
Contributor

@trim21 trim21 commented Feb 18, 2026

No description provided.

…ment

- Add OAuth authorization endpoints for GET and POST requests.
- Implement CSRF protection for authorization requests.
- Create HTML template for authorization page with error handling.
- Integrate Redis for storing authorization codes and refresh tokens.
- Update dependencies in Cargo.toml for new features.
- Add error handling for user authentication and authorization processes.
- Refactor server setup to include Redis connection pooling.
@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.23%. Comparing base (6a32bcf) to head (c777487).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1508   +/-   ##
=======================================
  Coverage   56.23%   56.23%           
=======================================
  Files         142      142           
  Lines        6284     6284           
  Branches     1298     1298           
=======================================
  Hits         3534     3534           
  Misses       2135     2135           
  Partials      615      615           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@trim21 trim21 requested a review from Copilot February 18, 2026 21:53
@trim21 trim21 changed the title feat: implement OAuth 2.0 authorization flow with access token manage… feat: implement rust server OAuth authorization Feb 18, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements the OAuth 2.0 authorization flow in Rust as part of the broader TypeScript-to-Rust migration effort. The implementation includes authorization endpoints (GET/POST /oauth/authorize), token exchange endpoint (POST /oauth/access_token), CSRF protection, Redis integration for authorization codes, and MySQL persistence for access and refresh tokens.

Changes:

  • Implements complete OAuth 2.0 authorization code and refresh token grant flows in Rust
  • Adds Redis connection pooling and integration for storing temporary authorization codes
  • Updates migration documentation to track OAuth API implementation progress and parity status
  • Creates HTML templates for OAuth authorization page and error handling

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
crates/api/src/oauth.rs Complete OAuth 2.0 flow implementation including authorization endpoints, token exchange, CSRF protection, scope parsing, and database/Redis operations
crates/api/src/server.rs Adds Redis pool setup, cookie signing key initialization, and routes OAuth endpoints through auth middleware
crates/api/src/lib.rs Adds oauth module declaration
crates/api/src/error.rs Adds not_found error constructor for 404 responses
crates/api/templates/oauth/authorize.html OAuth authorization page template with app info, scope permissions, and CSRF-protected form
crates/api/templates/oauth/error.html OAuth error page template for authorization failures
crates/api/Cargo.toml Adds dependencies for cookies, Redis, URL handling, and random token generation
Cargo.lock Lock file updates for new dependencies
docs/rust-migration-plan.md Comprehensive updates documenting OAuth migration timeline, implementation status, parity checklist, and migration tracking tables

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +798 to +802
#[derive(Debug, FromRow)]
struct RefreshTokenRow {
user_id: String,
scope: Option<String>,
}
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

The RefreshTokenRow struct is missing fields that are selected in the SQL query. The query at line 638 selects refresh_token, client_id, user_id, expires, scope, but the RefreshTokenRow struct at lines 798-802 only defines user_id and scope. This mismatch will cause a runtime error when sqlx tries to map the query results to the struct.

Add the missing fields to the RefreshTokenRow struct:

  • refresh_token: String
  • client_id: String
  • expires: chrono::DateTime<Utc> (or appropriate timestamp type)

Even if these fields aren't used in the business logic, they need to be present for sqlx to successfully deserialize the query results.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant