-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(oauth): implement authentication flow with login and logout #442
Conversation
…out functionality
…d add tracing libraries
…-tls feature; remove unused packages from Cargo.lock
@@ -0,0 +1,19 @@ | |||
use anyhow::Result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to app
crates/forge_api/src/api.rs
Outdated
@@ -63,6 +67,18 @@ impl<F: App + Infrastructure> API for ForgeAPI<F> { | |||
self.app.conversation_service().create(workflow).await | |||
} | |||
|
|||
async fn login(&self) -> anyhow::Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async fn login(&self) -> anyhow::Result<()> { | |
async fn authenticate(&self) -> anyhow::Result<()> { |
crates/forge_api/src/lib.rs
Outdated
fn logout(&self) -> anyhow::Result<bool>; | ||
|
||
/// Checks if the user is currently authenticated | ||
fn is_authenticated(&self) -> bool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete it
crates/forge_oauth/src/oauth.rs
Outdated
let (auth_url, pkce_verifier, csrf_token, _nonce) = self.generate_auth_url(); | ||
|
||
// 2. Open browser for user authentication | ||
println!("Opening browser for authentication..."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove println
crates/forge_oauth/src/oauth.rs
Outdated
} | ||
|
||
/// Complete the OAuth2 flow and return the token and user info | ||
pub async fn complete_auth_flow(&self) -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub async fn complete_auth_flow(&self) -> Result<()> { | |
pub async fn complete_auth_flow(&self) -> Result<URL> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be split this flow in two parts one to create the URL and other to actually login. api.rs needs to be changed
crates/forge_oauth/src/oauth.rs
Outdated
// 7. create a new key | ||
let client = reqwest::Client::new(); | ||
let key: Key = client | ||
.put("https://antinomy.ai/api/v1/key") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url in new should come as argument
crates/forge_oauth/src/oauth.rs
Outdated
} | ||
|
||
impl Default for ClerkConfig { | ||
fn default() -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implement new with config as argument
crates/forge_main/src/ui.rs
Outdated
@@ -118,6 +119,62 @@ impl<F: API> UI<F> { | |||
input = self.console.prompt(prompt_input).await?; | |||
continue; | |||
} | |||
Command::Login => { | |||
info!("Starting OAuth authentication flow..."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make logging consistent with our existing formats
…for Antinomy provider (#459) Co-authored-by: amitksingh1490 <amitksingh1490@users.noreply.github.com>
…er to ClerkAuthClient
crates/forge_app/src/provider.rs
Outdated
|
||
Self { or, cache: Cache::new(1024) } | ||
fn build_provider_service(&self) -> Result<Self> { | ||
if self.or.is_some() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will never be some
.
crates/forge_app/src/provider.rs
Outdated
or: Box<dyn ProviderService>, | ||
pub struct ForgeProviderService<F> { | ||
infra: Arc<F>, | ||
or: Option<Arc<dyn ProviderService>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or: Option<Arc<dyn ProviderService>>, | |
or: Option<Arc<P>>, |
Don't use dyn
.
crates/forge_app/src/provider.rs
Outdated
self.or | ||
this.or | ||
.as_ref() | ||
.ok_or_else(|| anyhow::anyhow!("Provider service not initialized"))? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate error messages. Move them to a common place.
…method names with repository pattern - Rename AuthService to CredentialRepository for better semantic clarity - Change method names from init_auth/logout to create/delete to align with repository pattern - Update method call sites across the codebase - Refactor AuthFlowState to encapsulate internal implementation details
…structure provider initialization
…handling - Refactor Provider enum with hierarchical OpenAiCompat structure - Improve URL handling with proper Url type and consistent API - Simplify ClientBuilder implementation and authentication flow - Consolidate provider identification with helper methods
No description provided.