Skip to content

Commit

Permalink
fix: fill oauth secret to client (#1379)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxiaoys authored Feb 5, 2024
1 parent 2fbabbe commit 35a91a6
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 14 deletions.
5 changes: 1 addition & 4 deletions ee/tabby-webserver/src/oauth/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ impl GithubClient {
code: String,
credential: OAuthCredential,
) -> Result<GithubOAuthResponse> {
let Some(client_secret) = credential.client_secret else {
return Err(anyhow::anyhow!("Missing client secret"));
};

let client_secret = credential.client_secret;
let params = [
("client_id", credential.client_id.as_str()),
("client_secret", client_secret.as_str()),
Expand Down
4 changes: 1 addition & 3 deletions ee/tabby-webserver/src/oauth/google.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ impl GoogleClient {
code: String,
credential: OAuthCredential,
) -> Result<GoogleOAuthResponse> {
let Some(client_secret) = credential.client_secret else {
return Err(anyhow::anyhow!("Missing client secret"));
};
let client_secret = credential.client_secret;

let Some(redirect_uri) = credential.redirect_uri else {
return Err(anyhow::anyhow!("Missing redirect uri"));
Expand Down
3 changes: 1 addition & 2 deletions ee/tabby-webserver/src/schema/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,7 @@ pub struct OAuthCredential {
pub provider: OAuthProvider,
pub client_id: String,

/// Won't be passed to client side.
pub client_secret: Option<String>,
pub client_secret: String,
pub redirect_uri: Option<String>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
Expand Down
4 changes: 2 additions & 2 deletions ee/tabby-webserver/src/schema/dao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl From<GithubOAuthCredentialDAO> for OAuthCredential {
OAuthCredential {
provider: OAuthProvider::Github,
client_id: val.client_id,
client_secret: Some(val.client_secret),
client_secret: val.client_secret,
redirect_uri: None,
created_at: val.created_at,
updated_at: val.updated_at,
Expand All @@ -66,7 +66,7 @@ impl From<GoogleOAuthCredentialDAO> for OAuthCredential {
OAuthCredential {
provider: OAuthProvider::Google,
client_id: val.client_id,
client_secret: Some(val.client_secret),
client_secret: val.client_secret,
redirect_uri: Some(val.redirect_uri),
created_at: val.created_at,
updated_at: val.updated_at,
Expand Down
4 changes: 1 addition & 3 deletions ee/tabby-webserver/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,10 @@ impl Query {
) -> Result<Option<OAuthCredential>> {
if let Some(claims) = &ctx.claims {
if claims.is_admin {
let Some(mut credentials) =
ctx.locator.auth().read_oauth_credential(provider).await?
let Some(credentials) = ctx.locator.auth().read_oauth_credential(provider).await?
else {
return Ok(None);
};
credentials.client_secret = None;
return Ok(Some(credentials));
}
}
Expand Down

0 comments on commit 35a91a6

Please sign in to comment.