Skip to content
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

chore: revert auth json #7026

Merged
merged 10 commits into from
Jan 19, 2024
5 changes: 0 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions cli/internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ func (c *APIClient) SetToken(token string) {
c.token = token
}

// BaseURL returns the APIClient's base URL
func (c *APIClient) BaseURL() string {
return c.baseURL
}

// NewClient creates a new APIClient
func NewClient(config turbostate.APIClientConfig, logger hclog.Logger, turboVersion string) *APIClient {
client := &APIClient{
Expand Down
15 changes: 0 additions & 15 deletions cli/internal/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
gocontext "context"
"fmt"
"sort"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -433,20 +432,6 @@ func (r *run) initAnalyticsClient(ctx gocontext.Context) analytics.Client {

if apiClient.IsLinked() {
analyticsSink = apiClient
if r.base.Config.Token == "" {
apiBase := r.base.APIClient.BaseURL()
// If it's a third party cache, tell the user to login with that API.
loginCommand := fmt.Sprintf("turbo login%s", func() string {
if strings.Contains(apiBase, "vercel") {
return ""
}
return fmt.Sprintf(" --api %s", apiBase)
}())

missingTokenMessage := fmt.Sprintf("No token found for %s. Run `turbo link` or %s first.", apiBase, loginCommand)

r.base.UI.Warn(missingTokenMessage)
}
} else {
r.opts.cacheOpts.SkipRemote = true
analyticsSink = analytics.NullSink
Expand Down
23 changes: 1 addition & 22 deletions crates/turborepo-api-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use serde::Deserialize;
use turborepo_ci::{is_ci, Vendor};
use turborepo_vercel_api::{
APIError, CachingStatus, CachingStatusResponse, PreflightResponse, SpacesResponse, Team,
TeamsResponse, TokenMetadata, TokenMetadataResponse, UserResponse, VerificationResponse,
VerifiedSsoUser,
TeamsResponse, UserResponse, VerificationResponse, VerifiedSsoUser,
};
use url::Url;

Expand All @@ -33,7 +32,6 @@ lazy_static! {

#[async_trait]
pub trait Client {
fn base_url(&self) -> &str;
async fn get_user(&self, token: &str) -> Result<UserResponse>;
async fn get_teams(&self, token: &str) -> Result<TeamsResponse>;
async fn get_team(&self, token: &str, team_id: &str) -> Result<Option<Team>>;
Expand All @@ -46,7 +44,6 @@ pub trait Client {
) -> Result<CachingStatusResponse>;
async fn get_spaces(&self, token: &str, team_id: Option<&str>) -> Result<SpacesResponse>;
async fn verify_sso_token(&self, token: &str, token_name: &str) -> Result<VerifiedSsoUser>;
async fn get_token_metadata(&self, token: &str) -> Result<TokenMetadata>;
#[allow(clippy::too_many_arguments)]
async fn put_artifact(
&self,
Expand Down Expand Up @@ -101,24 +98,6 @@ pub struct APIAuth {

#[async_trait]
impl Client for APIClient {
fn base_url(&self) -> &str {
&self.base_url
}
async fn get_token_metadata(&self, token: &str) -> Result<TokenMetadata> {
let url = self.make_url("/v5/user/tokens/current")?;
let request_builder = self
.client
.get(url)
.header("User-Agent", self.user_agent.clone())
.header("Authorization", format!("Bearer {}", token))
.header("Content-Type", "application/json");
let response = retry::make_retryable_request(request_builder)
.await?
.error_for_status()?;
let json: TokenMetadataResponse = response.json().await?;

Ok(json.token)
}
async fn get_user(&self, token: &str) -> Result<UserResponse> {
let url = self.make_url("/v2/user")?;
let request_builder = self
Expand Down
4 changes: 0 additions & 4 deletions crates/turborepo-auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ async-trait.workspace = true
axum-server = { workspace = true }
axum.workspace = true
chrono.workspace = true
dirs-next = "2.0.0"
hostname = "0.3.1"
lazy_static.workspace = true
reqwest.workspace = true
serde.workspace = true
serde_json.workspace = true
tempfile.workspace = true
thiserror = "1.0.38"
tokio.workspace = true
tracing.workspace = true
turbopath = { workspace = true }
turborepo-api-client = { workspace = true }
turborepo-ui.workspace = true
turborepo-vercel-api = { workspace = true }
Expand Down
Loading
Loading