From a0ea049a40081440f4738ad6da5ce24f5665a80a Mon Sep 17 00:00:00 2001 From: chesedo Date: Tue, 14 Mar 2023 09:08:29 +0200 Subject: [PATCH] refactor: trim dependencies Trim dependencies to minimize the build times of user projects. --- Cargo.lock | 1 - Cargo.toml | 2 +- auth/src/api/handlers.rs | 2 +- auth/src/user.rs | 2 +- auth/tests/api/session.rs | 2 +- common/Cargo.toml | 16 +- common/src/backends/auth.rs | 213 +----------------------- common/src/backends/future.rs | 17 -- common/src/backends/tracing.rs | 50 +----- common/src/lib.rs | 14 ++ common/src/models/mod.rs | 12 -- deployer/src/deployment/deploy_layer.rs | 2 +- deployer/src/deployment/queue.rs | 2 +- deployer/src/deployment/run.rs | 2 +- deployer/src/handlers/mod.rs | 3 +- gateway/src/api/latest.rs | 5 +- gateway/src/auth.rs | 2 +- gateway/src/lib.rs | 3 +- proto/Cargo.toml | 2 +- proto/src/lib.rs | 2 +- provisioner/src/lib.rs | 2 +- runtime/Cargo.toml | 6 +- runtime/src/legacy/mod.rs | 2 +- runtime/src/provisioner_factory.rs | 2 +- service/Cargo.toml | 17 +- 25 files changed, 61 insertions(+), 322 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec6ba38328..0ace53bce2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4840,7 +4840,6 @@ version = "0.11.0" dependencies = [ "anyhow", "async-trait", - "axum", "cargo", "cargo_metadata", "crossbeam-channel", diff --git a/Cargo.toml b/Cargo.toml index ad2d9a375a..86627999be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ shuttle-service = { path = "service", version = "0.11.0" } anyhow = "1.0.66" async-trait = "0.1.58" axum = { version = "0.6.0", default-features = false } -chrono = { version = "0.4.23", default-features = false, features = ["clock"] } +chrono = { version = "0.4.23", default-features = false } clap = { version = "4.0.27", features = [ "derive" ] } headers = "0.3.8" http = "0.2.8" diff --git a/auth/src/api/handlers.rs b/auth/src/api/handlers.rs index 2d08221ce5..b45061bf6f 100644 --- a/auth/src/api/handlers.rs +++ b/auth/src/api/handlers.rs @@ -9,7 +9,7 @@ use axum::{ use axum_sessions::extractors::{ReadableSession, WritableSession}; use http::StatusCode; use serde::{Deserialize, Serialize}; -use shuttle_common::{backends::auth::Claim, models::user}; +use shuttle_common::{claims::Claim, models::user}; use tracing::instrument; use super::{ diff --git a/auth/src/user.rs b/auth/src/user.rs index 264adfb60f..8d9b5a0c9f 100644 --- a/auth/src/user.rs +++ b/auth/src/user.rs @@ -9,7 +9,7 @@ use axum::{ }; use rand::distributions::{Alphanumeric, DistString}; use serde::{Deserialize, Deserializer, Serialize}; -use shuttle_common::backends::auth::Scope; +use shuttle_common::claims::Scope; use sqlx::{query, Row, SqlitePool}; use tracing::{trace, Span}; diff --git a/auth/tests/api/session.rs b/auth/tests/api/session.rs index aa07e8bdda..b768a0096c 100644 --- a/auth/tests/api/session.rs +++ b/auth/tests/api/session.rs @@ -2,7 +2,7 @@ use axum_extra::extract::cookie::{self, Cookie}; use http::{Request, StatusCode}; use hyper::Body; use serde_json::{json, Value}; -use shuttle_common::backends::auth::Claim; +use shuttle_common::claims::Claim; use crate::helpers::app; diff --git a/common/Cargo.toml b/common/Cargo.toml index 3028367c4b..51a4c3ec1c 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -12,10 +12,10 @@ anyhow = { workspace = true, optional = true } async-trait = { workspace = true , optional = true } axum = { workspace = true, optional = true } bytes = { version = "1.3.0", optional = true } -chrono = { workspace = true, features = ["serde"] } +chrono = { workspace = true } comfy-table = { version = "6.1.3", optional = true } crossterm = { version = "0.25.0", optional = true } -headers = { workspace = true } +headers = { workspace = true, optional = true } http = { workspace = true, optional = true } http-body = { version = "0.4.5", optional = true } http-serde = { version = "1.1.2", optional = true } @@ -25,7 +25,7 @@ once_cell = { workspace = true, optional = true } opentelemetry = { workspace = true, optional = true } opentelemetry-http = { workspace = true, optional = true } opentelemetry-otlp = { version = "0.11.0", optional = true } -pin-project = { workspace = true } +pin-project = { workspace = true, optional = true } prost-types = { workspace = true, optional = true } reqwest = { version = "0.11.13", optional = true } rmp-serde = { version = "1.1.1", optional = true } @@ -44,12 +44,14 @@ ttl_cache = { workspace = true, optional = true } uuid = { workspace = true, features = ["v4", "serde"], optional = true } [features] -backend = ["async-trait", "axum/matched-path", "bytes", "http", "http-body", "hyper/client", "jsonwebtoken", "opentelemetry", "opentelemetry-http", "opentelemetry-otlp", "thiserror", "tower", "tower-http", "tracing-opentelemetry", "tracing-subscriber/env-filter", "tracing-subscriber/fmt", "ttl_cache"] -display = ["comfy-table", "crossterm"] -models = ["anyhow", "async-trait", "display", "http", "prost-types", "reqwest", "serde_json", "service", "thiserror"] +backend = ["async-trait", "axum/matched-path", "claims", "hyper/client", "opentelemetry-otlp", "thiserror", "tower-http", "tracing-subscriber/env-filter", "tracing-subscriber/fmt", "ttl_cache"] +claims = ["bytes", "chrono/clock", "headers", "http", "http-body", "jsonwebtoken", "opentelemetry", "opentelemetry-http", "pin-project", "tower", "tracing", "tracing-opentelemetry"] +display = ["chrono/clock", "comfy-table", "crossterm"] +error = ["prost-types", "serde_json", "thiserror", "uuid"] +models = ["anyhow", "async-trait", "display", "http", "reqwest", "serde_json", "service"] service = ["chrono/serde", "once_cell", "rustrict", "serde/derive", "strum", "uuid"] tracing = ["serde_json"] -wasm = ["http-serde", "http", "rmp-serde", "tracing", "tracing-subscriber"] +wasm = ["chrono/clock", "http-serde", "http", "rmp-serde", "tracing", "tracing-subscriber"] [dev-dependencies] axum = { workspace = true } diff --git a/common/src/backends/auth.rs b/common/src/backends/auth.rs index dc293c24b5..f87bd3fed5 100644 --- a/common/src/backends/auth.rs +++ b/common/src/backends/auth.rs @@ -1,13 +1,11 @@ -use std::{convert::Infallible, future::Future, ops::Add, pin::Pin, sync::Arc}; +use std::{convert::Infallible, future::Future, pin::Pin, sync::Arc}; use async_trait::async_trait; use bytes::Bytes; -use chrono::{Duration, Utc}; use headers::{authorization::Bearer, Authorization, HeaderMapExt}; use http::{Request, Response, StatusCode, Uri}; use http_body::combinators::UnsyncBoxBody; use hyper::{body, Body, Client}; -use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header as JwtHeader, Validation}; use opentelemetry::global; use opentelemetry_http::HeaderInjector; use serde::{Deserialize, Serialize}; @@ -16,14 +14,14 @@ use tower::{Layer, Service}; use tracing::{error, trace, Span}; use tracing_opentelemetry::OpenTelemetrySpanExt; +use crate::claims::{Claim, Scope}; + use super::{ cache::{CacheManagement, CacheManager}, - future::{ResponseFuture, StatusCodeFuture}, + future::StatusCodeFuture, headers::XShuttleAdminSecret, }; -pub const EXP_MINUTES: i64 = 5; -const ISS: &str = "shuttle"; const PUBLIC_KEY_CACHE_KEY: &str = "shuttle.public-key"; /// Layer to check the admin secret set by deployer is correct @@ -86,164 +84,12 @@ where } } -/// The scope of operations that can be performed on shuttle -/// Every scope defaults to read and will use a suffix for updating tasks -#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)] -#[serde(rename_all = "snake_case")] -pub enum Scope { - /// Read the details, such as status and address, of a deployment - Deployment, - - /// Push a new deployment - DeploymentPush, - - /// Read the logs of a deployment - Logs, - - /// Read the details of a service - Service, - - /// Create a new service - ServiceCreate, - - /// Read the status of a project - Project, - - /// Create a new project - ProjectCreate, - - /// Get the resources for a project - Resources, - - /// Provision new resources for a project or update existing ones - ResourcesWrite, - - /// List the secrets of a project - Secret, - - /// Add or update secrets of a project - SecretWrite, - - /// Get list of users - User, - - /// Add or update users - UserCreate, - - /// Create an ACME account - AcmeCreate, - - /// Create a custom domain, - CustomDomainCreate, - - /// Admin level scope to internals - Admin, -} - #[derive(Deserialize, Serialize)] /// Response used internally to pass around JWT token pub struct ConvertResponse { pub token: String, } -#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)] -pub struct Claim { - /// Expiration time (as UTC timestamp). - pub exp: usize, - /// Issued at (as UTC timestamp). - iat: usize, - /// Issuer. - iss: String, - /// Not Before (as UTC timestamp). - nbf: usize, - /// Subject (whom token refers to). - pub sub: String, - /// Scopes this token can access - pub scopes: Vec, - /// The original token that was parsed - token: Option, -} - -impl Claim { - /// Create a new claim for a user with the given scopes - pub fn new(sub: String, scopes: Vec) -> Self { - let iat = Utc::now(); - let exp = iat.add(Duration::minutes(EXP_MINUTES)); - - Self { - exp: exp.timestamp() as usize, - iat: iat.timestamp() as usize, - iss: ISS.to_string(), - nbf: iat.timestamp() as usize, - sub, - scopes, - token: None, - } - } - - pub fn into_token(self, encoding_key: &EncodingKey) -> Result { - if let Some(token) = self.token { - Ok(token) - } else { - encode( - &JwtHeader::new(jsonwebtoken::Algorithm::EdDSA), - &self, - encoding_key, - ) - .map_err(|err| { - error!( - error = &err as &dyn std::error::Error, - "failed to convert claim to token" - ); - match err.kind() { - jsonwebtoken::errors::ErrorKind::Json(_) => StatusCode::INTERNAL_SERVER_ERROR, - jsonwebtoken::errors::ErrorKind::Crypto(_) => StatusCode::SERVICE_UNAVAILABLE, - _ => StatusCode::INTERNAL_SERVER_ERROR, - } - }) - } - } - - pub fn from_token(token: &str, public_key: &[u8]) -> Result { - let decoding_key = DecodingKey::from_ed_der(public_key); - let mut validation = Validation::new(jsonwebtoken::Algorithm::EdDSA); - validation.set_issuer(&[ISS]); - - trace!(token, "converting token to claim"); - let mut claim: Self = decode(token, &decoding_key, &validation) - .map_err(|err| { - error!( - error = &err as &dyn std::error::Error, - "failed to convert token to claim" - ); - match err.kind() { - jsonwebtoken::errors::ErrorKind::InvalidSignature - | jsonwebtoken::errors::ErrorKind::InvalidAlgorithmName - | jsonwebtoken::errors::ErrorKind::ExpiredSignature - | jsonwebtoken::errors::ErrorKind::InvalidIssuer - | jsonwebtoken::errors::ErrorKind::ImmatureSignature => { - StatusCode::UNAUTHORIZED - } - jsonwebtoken::errors::ErrorKind::InvalidToken - | jsonwebtoken::errors::ErrorKind::InvalidAlgorithm - | jsonwebtoken::errors::ErrorKind::Base64(_) - | jsonwebtoken::errors::ErrorKind::Json(_) - | jsonwebtoken::errors::ErrorKind::Utf8(_) => StatusCode::BAD_REQUEST, - jsonwebtoken::errors::ErrorKind::MissingAlgorithm => { - StatusCode::INTERNAL_SERVER_ERROR - } - jsonwebtoken::errors::ErrorKind::Crypto(_) => StatusCode::SERVICE_UNAVAILABLE, - _ => StatusCode::INTERNAL_SERVER_ERROR, - } - })? - .claims; - - claim.token = Some(token.to_string()); - - Ok(claim) - } -} - /// Trait to get a public key asynchronously #[async_trait] pub trait PublicKeyFn: Send + Sync + Clone { @@ -439,53 +285,6 @@ where } } -/// This layer takes a claim on a request extension and uses it's internal token to set the Authorization Bearer -#[derive(Clone)] -pub struct ClaimLayer; - -impl Layer for ClaimLayer { - type Service = ClaimService; - - fn layer(&self, inner: S) -> Self::Service { - ClaimService { inner } - } -} - -#[derive(Clone)] -pub struct ClaimService { - inner: S, -} - -impl Service>> for ClaimService -where - S: Service>> + Send + 'static, - S::Future: Send + 'static, -{ - type Response = S::Response; - type Error = S::Error; - type Future = ResponseFuture; - - fn poll_ready( - &mut self, - cx: &mut std::task::Context<'_>, - ) -> std::task::Poll> { - self.inner.poll_ready(cx) - } - - fn call(&mut self, mut req: Request>) -> Self::Future { - if let Some(claim) = req.extensions().get::() { - if let Some(token) = claim.token.clone() { - req.headers_mut() - .typed_insert(Authorization::bearer(&token).expect("to set JWT token")); - } - } - - let future = self.inner.call(req); - - ResponseFuture(future) - } -} - /// Check that the required scopes are set on the [Claim] extension on a [Request] #[derive(Clone)] pub struct ScopedLayer { @@ -568,7 +367,9 @@ mod tests { use serde_json::json; use tower::{ServiceBuilder, ServiceExt}; - use super::{Claim, JwtAuthenticationLayer, Scope, ScopedLayer}; + use crate::claims::{Claim, Scope}; + + use super::{JwtAuthenticationLayer, ScopedLayer}; #[test] fn to_token_and_back() { diff --git a/common/src/backends/future.rs b/common/src/backends/future.rs index 5603fdaa0f..e50bd41d4d 100644 --- a/common/src/backends/future.rs +++ b/common/src/backends/future.rs @@ -8,23 +8,6 @@ use axum::response::Response; use http::StatusCode; use pin_project::pin_project; -// Future for layers that just return the inner response -#[pin_project] -pub struct ResponseFuture(#[pin] pub F); - -impl Future for ResponseFuture -where - F: Future>, -{ - type Output = Result; - - fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - let this = self.project(); - - this.0.poll(cx) - } -} - /// Future for layers that might return a different status code #[pin_project(project = StatusCodeProj)] pub enum StatusCodeFuture { diff --git a/common/src/backends/tracing.rs b/common/src/backends/tracing.rs index 64a95cb8f4..a3fa04eb70 100644 --- a/common/src/backends/tracing.rs +++ b/common/src/backends/tracing.rs @@ -11,7 +11,7 @@ use opentelemetry::{ sdk::{propagation::TraceContextPropagator, trace, Resource}, KeyValue, }; -use opentelemetry_http::{HeaderExtractor, HeaderInjector}; +use opentelemetry_http::HeaderExtractor; use opentelemetry_otlp::WithExportConfig; use pin_project::pin_project; use tower::{Layer, Service}; @@ -19,8 +19,6 @@ use tracing::{debug_span, instrument::Instrumented, Instrument, Span, Subscriber use tracing_opentelemetry::OpenTelemetrySpanExt; use tracing_subscriber::{fmt, prelude::*, registry::LookupSpan, EnvFilter}; -use super::future::ResponseFuture; - pub fn setup_tracing(subscriber: S, service_name: &str) where S: Subscriber + for<'a> LookupSpan<'a> + Send + Sync, @@ -139,49 +137,3 @@ where ExtractPropagationFuture { response_future } } } - -/// This layer adds the current tracing span to any outgoing request -#[derive(Clone)] -pub struct InjectPropagationLayer; - -impl Layer for InjectPropagationLayer { - type Service = InjectPropagation; - - fn layer(&self, inner: S) -> Self::Service { - InjectPropagation { inner } - } -} - -#[derive(Clone)] -pub struct InjectPropagation { - inner: S, -} - -impl Service> for InjectPropagation -where - S: Service> + Send + 'static, - S::Future: Send + 'static, -{ - type Response = S::Response; - type Error = S::Error; - type Future = ResponseFuture; - - fn poll_ready( - &mut self, - cx: &mut std::task::Context<'_>, - ) -> std::task::Poll> { - self.inner.poll_ready(cx) - } - - fn call(&mut self, mut req: Request) -> Self::Future { - let cx = Span::current().context(); - - global::get_text_map_propagator(|propagator| { - propagator.inject_context(&cx, &mut HeaderInjector(req.headers_mut())) - }); - - let future = self.inner.call(req); - - ResponseFuture(future) - } -} diff --git a/common/src/lib.rs b/common/src/lib.rs index 11d3741c14..a680670849 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -1,5 +1,7 @@ #[cfg(feature = "backend")] pub mod backends; +#[cfg(feature = "claims")] +pub mod claims; #[cfg(feature = "service")] pub mod database; #[cfg(feature = "service")] @@ -38,6 +40,18 @@ pub type Host = String; #[cfg(feature = "service")] pub type DeploymentId = Uuid; +#[cfg(feature = "error")] +/// Errors that can occur when changing types. Especially from prost +#[derive(thiserror::Error, Debug)] +pub enum ParseError { + #[error("failed to parse UUID: {0}")] + Uuid(#[from] uuid::Error), + #[error("failed to parse timestamp: {0}")] + Timestamp(#[from] prost_types::TimestampError), + #[error("failed to parse serde: {0}")] + Serde(#[from] serde_json::Error), +} + #[derive(Debug, Clone, Serialize, Deserialize)] pub struct DatabaseReadyInfo { engine: String, diff --git a/common/src/models/mod.rs b/common/src/models/mod.rs index 2d80425012..328a33cf8d 100644 --- a/common/src/models/mod.rs +++ b/common/src/models/mod.rs @@ -11,7 +11,6 @@ use anyhow::{Context, Result}; use async_trait::async_trait; use http::StatusCode; use serde::de::DeserializeOwned; -use thiserror::Error; use tracing::trace; /// A to_json wrapper for handling our error states @@ -50,14 +49,3 @@ impl ToJson for reqwest::Response { } } } - -/// Errors that can occur when changing types. Especially from prost -#[derive(Error, Debug)] -pub enum ParseError { - #[error("failed to parse UUID: {0}")] - Uuid(#[from] uuid::Error), - #[error("failed to parse timestamp: {0}")] - Timestamp(#[from] prost_types::TimestampError), - #[error("failed to parse serde: {0}")] - Serde(#[from] serde_json::Error), -} diff --git a/deployer/src/deployment/deploy_layer.rs b/deployer/src/deployment/deploy_layer.rs index ad0877360f..0708051a9a 100644 --- a/deployer/src/deployment/deploy_layer.rs +++ b/deployer/src/deployment/deploy_layer.rs @@ -21,7 +21,7 @@ use chrono::{DateTime, Utc}; use serde_json::json; -use shuttle_common::{models::ParseError, tracing::JsonVisitor, STATE_MESSAGE}; +use shuttle_common::{tracing::JsonVisitor, ParseError, STATE_MESSAGE}; use shuttle_proto::runtime; use std::{convert::TryFrom, str::FromStr, time::SystemTime}; use tracing::{field::Visit, span, warn, Metadata, Subscriber}; diff --git a/deployer/src/deployment/queue.rs b/deployer/src/deployment/queue.rs index 1c7263f3d7..c48a20306f 100644 --- a/deployer/src/deployment/queue.rs +++ b/deployer/src/deployment/queue.rs @@ -11,7 +11,7 @@ use chrono::Utc; use crossbeam_channel::Sender; use opentelemetry::global; use serde_json::json; -use shuttle_common::backends::auth::Claim; +use shuttle_common::claims::Claim; use shuttle_service::builder::{build_crate, get_config, Runtime}; use tokio::time::{sleep, timeout}; use tracing::{debug, debug_span, error, info, instrument, trace, warn, Instrument, Span}; diff --git a/deployer/src/deployment/run.rs b/deployer/src/deployment/run.rs index 4df39521c6..0d5e16a5eb 100644 --- a/deployer/src/deployment/run.rs +++ b/deployer/src/deployment/run.rs @@ -8,7 +8,7 @@ use std::{ use async_trait::async_trait; use opentelemetry::global; use portpicker::pick_unused_port; -use shuttle_common::{backends::auth::Claim, storage_manager::ArtifactsStorageManager}; +use shuttle_common::{claims::Claim, storage_manager::ArtifactsStorageManager}; use shuttle_proto::runtime::{ runtime_client::RuntimeClient, LoadRequest, StartRequest, StopReason, SubscribeStopRequest, diff --git a/deployer/src/handlers/mod.rs b/deployer/src/handlers/mod.rs index c7a01f1c39..f0185f02f3 100644 --- a/deployer/src/handlers/mod.rs +++ b/deployer/src/handlers/mod.rs @@ -13,10 +13,11 @@ use fqdn::FQDN; use futures::StreamExt; use hyper::Uri; use shuttle_common::backends::auth::{ - AdminSecretLayer, AuthPublicKey, Claim, JwtAuthenticationLayer, Scope, ScopedLayer, + AdminSecretLayer, AuthPublicKey, JwtAuthenticationLayer, ScopedLayer, }; use shuttle_common::backends::headers::XShuttleAccountName; use shuttle_common::backends::metrics::{Metrics, TraceLayer}; +use shuttle_common::claims::{Claim, Scope}; use shuttle_common::models::secret; use shuttle_common::project::ProjectName; use shuttle_common::storage_manager::StorageManager; diff --git a/gateway/src/api/latest.rs b/gateway/src/api/latest.rs index 94c43d56e8..42f1ff3a69 100644 --- a/gateway/src/api/latest.rs +++ b/gateway/src/api/latest.rs @@ -16,11 +16,10 @@ use futures::Future; use http::{StatusCode, Uri}; use instant_acme::{AccountCredentials, ChallengeType}; use serde::{Deserialize, Serialize}; -use shuttle_common::backends::auth::{ - AuthPublicKey, JwtAuthenticationLayer, Scope, ScopedLayer, EXP_MINUTES, -}; +use shuttle_common::backends::auth::{AuthPublicKey, JwtAuthenticationLayer, ScopedLayer}; use shuttle_common::backends::cache::CacheManager; use shuttle_common::backends::metrics::{Metrics, TraceLayer}; +use shuttle_common::claims::{Scope, EXP_MINUTES}; use shuttle_common::models::error::ErrorKind; use shuttle_common::models::{project, stats}; use shuttle_common::request_span; diff --git a/gateway/src/auth.rs b/gateway/src/auth.rs index 679890b0cb..0c9910aa93 100644 --- a/gateway/src/auth.rs +++ b/gateway/src/auth.rs @@ -4,7 +4,7 @@ use std::str::FromStr; use axum::extract::{FromRef, FromRequestParts, Path}; use axum::http::request::Parts; use serde::{Deserialize, Serialize}; -use shuttle_common::backends::auth::{Claim, Scope}; +use shuttle_common::claims::{Claim, Scope}; use tracing::{trace, Span}; use crate::api::latest::RouterState; diff --git a/gateway/src/lib.rs b/gateway/src/lib.rs index fcfd2cdb21..0007001429 100644 --- a/gateway/src/lib.rs +++ b/gateway/src/lib.rs @@ -344,7 +344,8 @@ pub mod tests { use jsonwebtoken::EncodingKey; use rand::distributions::{Alphanumeric, DistString, Distribution, Uniform}; use ring::signature::{self, Ed25519KeyPair, KeyPair}; - use shuttle_common::backends::auth::{Claim, ConvertResponse, Scope}; + use shuttle_common::backends::auth::ConvertResponse; + use shuttle_common::claims::{Claim, Scope}; use shuttle_common::models::project; use sqlx::SqlitePool; use tokio::sync::mpsc::channel; diff --git a/proto/Cargo.toml b/proto/Cargo.toml index aadf6f749b..bb6725807f 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -19,7 +19,7 @@ uuid = { workspace = true, features = ["v4"] } [dependencies.shuttle-common] workspace = true -features = ["models", "service", "wasm"] +features = ["error", "service", "wasm"] [build-dependencies] tonic-build = "0.8.3" diff --git a/proto/src/lib.rs b/proto/src/lib.rs index f27281d130..39275985dd 100644 --- a/proto/src/lib.rs +++ b/proto/src/lib.rs @@ -104,7 +104,7 @@ pub mod runtime { use anyhow::Context; use chrono::DateTime; use prost_types::Timestamp; - use shuttle_common::models::ParseError; + use shuttle_common::ParseError; use tokio::process; use tonic::transport::{Channel, Endpoint}; use tracing::info; diff --git a/provisioner/src/lib.rs b/provisioner/src/lib.rs index 7c732149ad..cfa9ebdc8a 100644 --- a/provisioner/src/lib.rs +++ b/provisioner/src/lib.rs @@ -6,7 +6,7 @@ use aws_sdk_rds::{error::ModifyDBInstanceErrorKind, model::DbInstance, types::Sd pub use error::Error; use mongodb::{bson::doc, options::ClientOptions}; use rand::Rng; -use shuttle_common::backends::auth::{Claim, Scope}; +use shuttle_common::claims::{Claim, Scope}; pub use shuttle_proto::provisioner::provisioner_server::ProvisionerServer; use shuttle_proto::provisioner::{ aws_rds, database_request::DbType, shared, AwsRds, DatabaseRequest, DatabaseResponse, Shared, diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 19925fba79..0a417f5029 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -14,7 +14,7 @@ required-features = ["next"] anyhow = { workspace = true } async-trait = { workspace = true } chrono = { workspace = true } -clap ={ version = "4.0.18", features = ["derive"] } +clap = { workspace = true } serde_json = { workspace = true } strfmt = "0.2.2" thiserror = { workspace = true } @@ -37,19 +37,19 @@ wasmtime-wasi = { version = "4.0.0", optional = true } [dependencies.shuttle-common] workspace = true -features = ["backend", "service"] +features = ["claims"] [dependencies.shuttle-proto] workspace = true [dependencies.shuttle-service] workspace = true -features = ["builder"] [dev-dependencies] crossbeam-channel = "0.5.6" portpicker = "0.1.1" futures = { version = "0.3.25" } +shuttle-service = { workspace = true, features = ["builder"] } [features] default = [] diff --git a/runtime/src/legacy/mod.rs b/runtime/src/legacy/mod.rs index 1c11df974d..d5b1f88931 100644 --- a/runtime/src/legacy/mod.rs +++ b/runtime/src/legacy/mod.rs @@ -13,7 +13,7 @@ use async_trait::async_trait; use clap::Parser; use core::future::Future; use shuttle_common::{ - backends::{auth::ClaimLayer, tracing::InjectPropagationLayer}, + claims::{ClaimLayer, InjectPropagationLayer}, storage_manager::{ArtifactsStorageManager, StorageManager, WorkingDirStorageManager}, LogItem, }; diff --git a/runtime/src/provisioner_factory.rs b/runtime/src/provisioner_factory.rs index 8193af78ef..56d91e94c2 100644 --- a/runtime/src/provisioner_factory.rs +++ b/runtime/src/provisioner_factory.rs @@ -2,7 +2,7 @@ use std::{collections::BTreeMap, path::PathBuf, sync::Arc}; use async_trait::async_trait; use shuttle_common::{ - backends::{auth::ClaimService, tracing::InjectPropagation}, + claims::{ClaimService, InjectPropagation}, database, storage_manager::StorageManager, DatabaseReadyInfo, diff --git a/service/Cargo.toml b/service/Cargo.toml index c895c042e5..64178f8638 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -13,17 +13,16 @@ doctest = false [dependencies] anyhow = { workspace = true } async-trait = { workspace = true } -axum = { workspace = true, optional = true } # TODO: debug the libgit2-sys conflict with cargo-edit when upgrading cargo to 0.66 cargo = { version = "0.65.0", optional = true } -cargo_metadata = "0.15.2" -crossbeam-channel = "0.5.6" -pipe = "0.4.0" -serde_json = { workspace = true } +cargo_metadata = { version = "0.15.2", optional = true } +crossbeam-channel = { version = "0.5.6", optional = true } +pipe = { version = "0.4.0", optional = true } +serde_json = { workspace = true, optional = true } strfmt = "0.2.2" thiserror = { workspace = true } -tokio = { version = "1.26.0", features = ["sync"] } -tracing = { workspace = true } +tokio = { version = "1.26.0", features = ["sync"], optional = true } +tracing = { workspace = true, optional = true } [dependencies.shuttle-codegen] workspace = true @@ -31,7 +30,7 @@ optional = true [dependencies.shuttle-common] workspace = true -features = ["tracing", "service"] +features = ["service"] [dev-dependencies] tokio = { version = "1.26.0", features = ["macros", "rt"] } @@ -40,4 +39,4 @@ tokio = { version = "1.26.0", features = ["macros", "rt"] } default = ["codegen"] codegen = ["shuttle-codegen/frameworks"] -builder = ["cargo"] +builder = ["cargo", "cargo_metadata", "crossbeam-channel", "pipe", "tokio", "tracing"]