[APP-3801] implement remote environments auth (#9331)

This commit is contained in:
Moira Huang
2026-04-28 21:31:23 -05:00
committed by GitHub
parent c325d146ab
commit f0c8b7f723
21 changed files with 685 additions and 69 deletions
+21 -1
View File
@@ -54,6 +54,7 @@ use parking_lot::{Mutex, RwLock};
use reqwest::StatusCode;
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use std::fmt;
use std::path::Path;
use std::sync::Arc;
use std::time::Duration;
@@ -355,7 +356,7 @@ cfg_if::cfg_if! {
/// An event related to the server API itself (and not a particular API call).
/// Most errors should be handled in callbacks to individual APIs, rather than sent over the
/// server API channel.
#[derive(Debug, Clone)]
#[derive(Clone)]
pub enum ServerApiEvent {
/// We made a staging API call that was blocked, which may indicate a firewall misconfiguration.
StagingAccessBlocked,
@@ -364,6 +365,25 @@ pub enum ServerApiEvent {
NeedsReauth,
/// The user's account has been disabled.
UserAccountDisabled,
/// The current bearer token was refreshed.
AccessTokenRefreshed {
#[cfg_attr(target_family = "wasm", allow(dead_code))]
token: String,
},
}
impl fmt::Debug for ServerApiEvent {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::StagingAccessBlocked => f.write_str("StagingAccessBlocked"),
Self::NeedsReauth => f.write_str("NeedsReauth"),
Self::UserAccountDisabled => f.write_str("UserAccountDisabled"),
Self::AccessTokenRefreshed { .. } => f
.debug_struct("AccessTokenRefreshed")
.field("token", &"<redacted>")
.finish(),
}
}
}
/// An API wrapper struct with methods to requests to warp-server.
+6
View File
@@ -268,6 +268,12 @@ impl AuthClient for ServerApi {
let new_firebase_token_info = result?;
self.auth_state
.update_firebase_tokens(new_firebase_token_info.clone());
let _ = self
.event_sender
.send(ServerApiEvent::AccessTokenRefreshed {
token: new_firebase_token_info.id_token.clone(),
})
.await;
return Ok(AuthToken::Firebase(new_firebase_token_info.id_token));
}