Skip to content

Commit

Permalink
Apply suggestion, add back authentication middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
boxbeam committed Apr 10, 2024
1 parent 8b7b73d commit 6e33d34
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
6 changes: 5 additions & 1 deletion ee/tabby-webserver/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ impl WebserverHandle {
)
.nest(
"/integrations/github",
integrations::github::routes(ctx.setting(), ctx.github_repository_provider()),
integrations::github::routes(
ctx.auth(),
ctx.setting(),
ctx.github_repository_provider(),
),
)
.route(
"/avatar/:id",
Expand Down
4 changes: 2 additions & 2 deletions ee/tabby-webserver/src/hub/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl Hub for Arc<HubImpl> {

let provider_service = self.ctx.github_repository_provider();
let repository_providers = provider_service
.list_github_repository_providers(None, None, Some(1024), None)
.list_github_repository_providers(None, None, None, None)
.await
.unwrap_or_else(|e| {
warn!("Failed to fetch GitHub repository providers: {e}");
Expand All @@ -186,7 +186,7 @@ impl Hub for Arc<HubImpl> {
vec![provider.id.clone()],
None,
None,
Some(1024),
None,
None,
)
.await
Expand Down
11 changes: 9 additions & 2 deletions ee/tabby-webserver/src/integrations/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::sync::Arc;
use anyhow::Result;
use axum::{
extract::{Path, Query, State},
middleware::from_fn_with_state,
response::Redirect,
routing, Router,
};
Expand All @@ -12,8 +13,12 @@ use serde::Deserialize;
use tracing::error;
use url::Url;

use crate::schema::{
github_repository_provider::GithubRepositoryProviderService, setting::SettingService,
use crate::{
handler::require_login_middleware,
schema::{
auth::AuthenticationService, github_repository_provider::GithubRepositoryProviderService,
setting::SettingService,
},
};

#[derive(Debug, Deserialize)]
Expand Down Expand Up @@ -47,6 +52,7 @@ struct IntegrationState {
}

pub fn routes(
auth: Arc<dyn AuthenticationService>,
settings: Arc<dyn SettingService>,
github_repository_provider: Arc<dyn GithubRepositoryProviderService>,
) -> Router {
Expand All @@ -57,6 +63,7 @@ pub fn routes(
Router::new()
.route("/connect/:id", routing::get(connect))
.route("/callback", routing::get(callback))
.layer(from_fn_with_state(auth, require_login_middleware))
.with_state(state)
}

Expand Down

0 comments on commit 6e33d34

Please sign in to comment.