diff --git a/vicky/src/bin/vicky/auth.rs b/vicky/src/bin/vicky/auth.rs index 187cb80..4240dea 100644 --- a/vicky/src/bin/vicky/auth.rs +++ b/vicky/src/bin/vicky/auth.rs @@ -33,7 +33,6 @@ impl FromStr for Role { } } -#[allow(dead_code)] #[derive(Deserialize)] pub struct User { pub id: Uuid, @@ -41,8 +40,6 @@ pub struct User { pub role: Role, } -pub struct Machine {} - async fn extract_user_from_token(jwks_verifier: &State, db: &Database, oidc_config: &OIDCConfigResolved, token: &str) -> Result { let jwt = jwks_verifier.verify::>(token).await?; diff --git a/vicky/src/bin/vicky/locks.rs b/vicky/src/bin/vicky/locks.rs index e756734..4f1fbe1 100644 --- a/vicky/src/bin/vicky/locks.rs +++ b/vicky/src/bin/vicky/locks.rs @@ -5,7 +5,7 @@ use uuid::Uuid; use vickylib::database::entities::{Database, Lock}; use vickylib::database::entities::lock::db_impl::LockDatabase; use vickylib::database::entities::lock::PoisonedLock; -use crate::auth::{Machine, User}; +use crate::auth::{User}; use crate::errors::AppError; async fn locks_get_poisoned(db: &Database) -> Result>, AppError> { diff --git a/vickyctl/src/account.rs b/vickyctl/src/account.rs index f92ccbe..468044a 100644 --- a/vickyctl/src/account.rs +++ b/vickyctl/src/account.rs @@ -1,7 +1,7 @@ -use openidconnect::{ErrorResponse, ClientId, IssuerUrl, core::{CoreProviderMetadata, CoreClient, CoreDeviceAuthorizationResponse, CoreAuthDisplay, CoreClientAuthMethod, CoreClaimName, CoreClaimType, CoreGrantType, CoreJweContentEncryptionAlgorithm, CoreJweKeyManagementAlgorithm, CoreJsonWebKey, CoreResponseMode, CoreResponseType, CoreSubjectIdentifierType, CoreJwsSigningAlgorithm, CoreJsonWebKeyType, CoreJsonWebKeyUse}, Scope, reqwest::{http_client}, AdditionalProviderMetadata, ProviderMetadata, DeviceAuthorizationUrl, AuthType, OAuth2TokenResponse}; +use openidconnect::{ClientId, IssuerUrl, core::{CoreClient, CoreDeviceAuthorizationResponse, CoreAuthDisplay, CoreClientAuthMethod, CoreClaimName, CoreClaimType, CoreGrantType, CoreJweContentEncryptionAlgorithm, CoreJweKeyManagementAlgorithm, CoreJsonWebKey, CoreResponseMode, CoreResponseType, CoreSubjectIdentifierType, CoreJwsSigningAlgorithm, CoreJsonWebKeyType, CoreJsonWebKeyUse}, Scope, reqwest::{http_client}, AdditionalProviderMetadata, ProviderMetadata, DeviceAuthorizationUrl, AuthType, OAuth2TokenResponse}; use serde::{Deserialize, Serialize}; -use crate::{cli::AppContext, error::Error, FileConfig, AuthState}; +use crate::{FileConfig, AuthState}; // Taken from https://github.com/ramosbugs/openidconnect-rs/blob/support/3.x/examples/okta_device_grant.rs @@ -30,11 +30,11 @@ type DeviceProviderMetadata = ProviderMetadata< pub fn show(auth_state: &AuthState) -> Result<(), anyhow::Error> { - print!("{:?}", auth_state.clone()); + print!("{:?}", auth_state); Ok(()) } -pub fn login(ctx: &AppContext, vicky_url_str: String, issuer_url_str: String, client_id_str: String) -> Result<(), anyhow::Error> { +pub fn login(vicky_url_str: String, issuer_url_str: String, client_id_str: String) -> Result<(), anyhow::Error> { let client_id = ClientId::new(client_id_str.clone().to_string()); let issuer_url = IssuerUrl::new(issuer_url_str.clone().to_string())?; diff --git a/vickyctl/src/http_client.rs b/vickyctl/src/http_client.rs index 037b199..d005ba0 100644 --- a/vickyctl/src/http_client.rs +++ b/vickyctl/src/http_client.rs @@ -11,11 +11,11 @@ pub fn prepare_client(auth_state: &AuthState) -> Result<(Client, String), Error> let auth_token: String = "".to_owned(); match auth_state { - AuthState::EnvironmentAuthenticated(envConfig) => { - base_url = envConfig.url.clone(); + AuthState::EnvironmentAuthenticated(env_config) => { + base_url = env_config.url.clone(); }, - AuthState::FileAuthenticated(fileCfg) => { - base_url = fileCfg.vicky_url.clone(); + AuthState::FileAuthenticated(file_config) => { + base_url = file_config.vicky_url.clone(); }, AuthState::Unauthenticated => { return Err(Error::Unauthenticated()) diff --git a/vickyctl/src/locks/http.rs b/vickyctl/src/locks/http.rs index 82ee599..68ec32f 100644 --- a/vickyctl/src/locks/http.rs +++ b/vickyctl/src/locks/http.rs @@ -1,8 +1,6 @@ use reqwest::blocking::Client; -use crate::AuthState; use crate::error::Error; -use crate::http_client::prepare_client; use crate::locks::types::{LockType, PoisonedLock}; pub fn get_locks_endpoint(lock_type: LockType, detailed: bool) -> &'static str { diff --git a/vickyctl/src/main.rs b/vickyctl/src/main.rs index 1cd8937..b45fe80 100644 --- a/vickyctl/src/main.rs +++ b/vickyctl/src/main.rs @@ -89,11 +89,11 @@ fn main() { }, Cli::Tasks(tasks_args) => tasks::show_tasks(&tasks_args, &auth_state), Cli::Locks(locks_args) => tui::show_locks(&locks_args, &auth_state), - Cli::Resolve(resolve_args) => tui::resolve_lock(&resolve_args, &auth_state), + Cli::Resolve(_) => tui::resolve_lock(&auth_state), Cli::Account(account_args) => match account_args.commands { AccountCommands::Show => show(&auth_state).map_err(crate::error::Error::from), - AccountCommands::Login{ vicky_url, client_id, issuer_url} => login(&account_args.ctx, vicky_url, issuer_url, client_id).map_err(crate::error::Error::from) + AccountCommands::Login{ vicky_url, client_id, issuer_url} => login( vicky_url, issuer_url, client_id).map_err(crate::error::Error::from) } }; diff --git a/vickyctl/src/tui/lock_resolver.rs b/vickyctl/src/tui/lock_resolver.rs index bf54786..cb3bf8b 100644 --- a/vickyctl/src/tui/lock_resolver.rs +++ b/vickyctl/src/tui/lock_resolver.rs @@ -1,4 +1,4 @@ -use crate::cli::{LocksArgs, ResolveArgs}; +use crate::cli::{LocksArgs}; use crate::error::Error; use crate::http_client::prepare_client; use crate::{humanize, AuthState}; @@ -44,7 +44,7 @@ pub fn show_locks(locks_args: &LocksArgs, auth_state: &AuthState) -> Result<(), Ok(()) } -pub fn resolve_lock(resolve_args: &ResolveArgs, auth_state: &AuthState) -> Result<(), Error> { +pub fn resolve_lock(auth_state: &AuthState) -> Result<(), Error> { let (client, vicky_url) = prepare_client(auth_state)?; let mut locks = fetch_detailed_poisoned_locks(&client, vicky_url.clone())?;