Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dropshot-authorization-header/src/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use async_trait::async_trait;
use base64::{prelude::BASE64_STANDARD, Engine};
use base64::{Engine, prelude::BASE64_STANDARD};
use dropshot::{
ApiEndpointBodyContentType, ExtensionMode, ExtractorMetadata, HttpError, RequestContext,
ServerContext, SharedExtractor,
Expand Down
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
style_edition = "2021"
style_edition = "2024"
edition = "2024"
4 changes: 2 additions & 2 deletions v-api-installer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use diesel::{
r2d2::{ConnectionManager, ManageConnection},
PgConnection,
r2d2::{ConnectionManager, ManageConnection},
};
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
use diesel_migrations::{EmbeddedMigrations, MigrationHarness, embed_migrations};

const MIGRATIONS: EmbeddedMigrations = embed_migrations!("../v-model/migrations");

Expand Down
4 changes: 3 additions & 1 deletion v-api-installer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ fn main() {
if let Ok(url) = std::env::var("DATABASE_URL") {
run_migrations(&url);
} else {
println!("DATABASE_URL environment variable must be specified to run migrations and must be in the form of a connection string")
println!(
"DATABASE_URL environment variable must be specified to run migrations and must be in the form of a connection string"
)
}
}
2 changes: 1 addition & 1 deletion v-api-permission-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use std::{
hash::{Hash, Hasher},
};
use syn::{
Data, DeriveInput, Error, Ident, Result, Token, Variant,
parse::{Parse, ParseStream},
parse_macro_input,
spanned::Spanned,
Data, DeriveInput, Error, Ident, Result, Token, Variant,
};

static MACRO_ID: &str = "v_api";
Expand Down
9 changes: 4 additions & 5 deletions v-api/src/authn/jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine};
use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD};
use chrono::{DateTime, Utc};
use dropshot::{RequestContext, SharedExtractor};
use dropshot_authorization_header::bearer::BearerAuth;
use jsonwebtoken::{
decode, decode_header,
Algorithm, DecodingKey, Header, Validation, decode, decode_header,
jwk::{AlgorithmParameters, Jwk},
Algorithm, DecodingKey, Header, Validation,
};
use newtype_uuid::TypedUuid;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde::{Deserialize, Serialize, de::DeserializeOwned};
use std::{fmt::Debug, sync::Arc};
use thiserror::Error;
use tracing::instrument;
use v_model::{AccessTokenId, UserId, UserProviderId};

use crate::{authn::Signer, context::VContext, permissions::VAppPermission, ApiContext};
use crate::{ApiContext, authn::Signer, context::VContext, permissions::VAppPermission};

use super::SigningKeyError;

Expand Down
2 changes: 1 addition & 1 deletion v-api/src/authn/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ mod tests {
use super::RawKey;
use crate::{
authn::{VerificationResult, Verify},
util::tests::{mock_key, MockKey},
util::tests::{MockKey, mock_key},
};

struct TestVerifier {
Expand Down
6 changes: 3 additions & 3 deletions v-api/src/authn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use async_trait::async_trait;
use base64::{prelude::BASE64_STANDARD, Engine};
use base64::{Engine, prelude::BASE64_STANDARD};
use crc32c::crc32c;
use dropshot::{HttpError, RequestContext, SharedExtractor};
use dropshot_authorization_header::bearer::BearerAuth;
use google_cloudkms1::{
api::AsymmetricSignRequest, hyper_rustls::HttpsConnector,
hyper_util::client::legacy::connect::HttpConnector, CloudKMS,
CloudKMS, api::AsymmetricSignRequest, hyper_rustls::HttpsConnector,
hyper_util::client::legacy::connect::HttpConnector,
};
use rsa::sha2::{Digest, Sha256};
use rsa::{
Expand Down
10 changes: 5 additions & 5 deletions v-api/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine};
use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD};
use futures::executor::block_on;
use jsonwebtoken::jwk::{
AlgorithmParameters, CommonParameters, Jwk, KeyAlgorithm, PublicKeyUse, RSAKeyParameters,
RSAKeyType,
};
use rsa::{
RsaPrivateKey, RsaPublicKey,
pkcs1v15::{SigningKey, VerifyingKey},
pkcs8::{DecodePrivateKey, DecodePublicKey},
traits::PublicKeyParts,
RsaPrivateKey, RsaPublicKey,
};
use secrecy::ExposeSecret;
use serde::{
de::{self, Visitor},
Deserialize, Deserializer,
de::{self, Visitor},
};
use std::path::PathBuf;
use thiserror::Error;
use v_api_param::StringParam;

use crate::{
authn::{
jwt::JwtSignerError, CloudKmsError, CloudKmsSigningKey, CloudKmsVerifyingKey,
LocalSigningKey, LocalVerifyingKey, Signer, SignerKey, SigningKeyError, Verifier,
CloudKmsError, CloudKmsSigningKey, CloudKmsVerifyingKey, LocalSigningKey,
LocalVerifyingKey, Signer, SignerKey, SigningKeyError, Verifier, jwt::JwtSignerError,
},
util::cloud_kms_client,
};
Expand Down
6 changes: 3 additions & 3 deletions v-api/src/context/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ use std::{collections::HashMap, fmt::Debug, sync::Arc};
use v_model::permissions::Caller;

use crate::{
ApiContext,
authn::{
jwt::{JwtSigner, JwtSignerError},
AuthError, AuthToken, Sign, Signer, VerificationResult, Verifier, Verify,
jwt::{JwtSigner, JwtSignerError},
},
config::JwtConfig,
endpoints::login::oauth::{
OAuthProvider, OAuthProviderError, OAuthProviderFn, OAuthProviderName,
},
error::AppError,
permissions::{VAppPermission, VPermission},
ApiContext,
};

pub struct AuthContext<T> {
Expand Down Expand Up @@ -195,7 +195,7 @@ mod tests {
config::JwtConfig,
context::auth::AuthContext,
permissions::VPermission,
util::tests::{mock_key, MockKey},
util::tests::{MockKey, mock_key},
};

#[tokio::test]
Expand Down
6 changes: 3 additions & 3 deletions v-api/src/context/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
use newtype_uuid::TypedUuid;
use std::sync::Arc;
use v_model::{
AccessGroup, AccessGroupId, NewAccessGroup,
permissions::Caller,
storage::{AccessGroupFilter, AccessGroupStore, ListPagination, StoreError},
AccessGroup, AccessGroupId, NewAccessGroup,
};

use crate::{
permissions::{VAppPermission, VPermission},
response::{resource_restricted, OptionalResource, ResourceResult},
VApiStorage,
permissions::{VAppPermission, VPermission},
response::{OptionalResource, ResourceResult, resource_restricted},
};

#[derive(Clone)]
Expand Down
8 changes: 4 additions & 4 deletions v-api/src/context/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ use chrono::{TimeDelta, Utc};
use newtype_uuid::{GenericUuid, TypedUuid};
use std::{ops::Add, sync::Arc};
use v_model::{
LinkRequest, LinkRequestId, NewLinkRequest, UserId, UserProviderId,
permissions::Caller,
storage::{LinkRequestStore, StoreError},
LinkRequest, LinkRequestId, NewLinkRequest, UserId, UserProviderId,
};

use crate::{
VApiStorage,
authn::{
key::{RawKey, SignedKey},
Sign,
key::{RawKey, SignedKey},
},
permissions::{VAppPermission, VPermission},
response::{resource_restricted, ResourceResult},
VApiStorage,
response::{ResourceResult, resource_restricted},
};

#[derive(Clone)]
Expand Down
4 changes: 2 additions & 2 deletions v-api/src/context/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use newtype_uuid::TypedUuid;
use oauth2::CsrfToken;
use std::sync::Arc;
use v_model::{
storage::{ListPagination, LoginAttemptFilter, LoginAttemptStore, StoreError},
LoginAttempt, LoginAttemptId, LoginAttemptState, NewLoginAttempt,
storage::{ListPagination, LoginAttemptFilter, LoginAttemptStore, StoreError},
};

use crate::{permissions::VAppPermission, VApiStorage};
use crate::{VApiStorage, permissions::VAppPermission};

#[derive(Clone)]
pub struct LoginContext<T> {
Expand Down
18 changes: 9 additions & 9 deletions v-api/src/context/magic_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ use thiserror::Error;
use tracing::instrument;
use url::Url;
use v_model::{
MagicLink, MagicLinkAttempt, MagicLinkAttemptId, MagicLinkId, MagicLinkRedirectUri,
MagicLinkRedirectUriId, MagicLinkSecret, MagicLinkSecretId, NewMagicLink, NewMagicLinkAttempt,
NewMagicLinkRedirectUri, NewMagicLinkSecret,
permissions::Caller,
schema_ext::{MagicLinkAttemptState, MagicLinkMedium},
storage::{
ListPagination, MagicLinkAttemptFilter, MagicLinkAttemptStore, MagicLinkFilter,
MagicLinkRedirectUriStore, MagicLinkSecretStore, MagicLinkStore, StoreError,
},
MagicLink, MagicLinkAttempt, MagicLinkAttemptId, MagicLinkId, MagicLinkRedirectUri,
MagicLinkRedirectUriId, MagicLinkSecret, MagicLinkSecretId, NewMagicLink, NewMagicLinkAttempt,
NewMagicLinkRedirectUri, NewMagicLinkSecret,
};

use crate::{
authn::{
key::{ApiKeyError, RawKey},
Sign, SigningKeyError,
key::{ApiKeyError, RawKey},
},
messenger::{Message, Messenger, MessengerError},
permissions::{VAppPermission, VPermission},
response::{
resource_error, resource_restricted, OptionalResource, ResourceError, ResourceErrorInner,
ResourceResult,
OptionalResource, ResourceError, ResourceErrorInner, ResourceResult, resource_error,
resource_restricted,
},
};

Expand Down Expand Up @@ -452,22 +452,22 @@ mod tests {
use std::{
ops::Add,
sync::{
atomic::{AtomicBool, Ordering},
Arc, RwLock,
atomic::{AtomicBool, Ordering},
},
};
use url::Url;
use uuid::Uuid;
use v_model::{
MagicLinkAttempt,
schema_ext::{MagicLinkAttemptState, MagicLinkMedium},
storage::MockMagicLinkAttemptStore,
MagicLinkAttempt,
};

use super::{MagicLinkContext, MagicLinkMessage, MagicLinkTarget};
use crate::{
authn::key::RawKey,
context::test_mocks::{mock_context, MockStorage},
context::test_mocks::{MockStorage, mock_context},
messenger::{Message, Messenger, MessengerError},
permissions::VPermission,
response::ResourceError,
Expand Down
11 changes: 7 additions & 4 deletions v-api/src/context/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ use newtype_uuid::TypedUuid;
use serde_json::Value;
use std::{collections::BTreeSet, sync::Arc};
use v_model::{
AccessGroupId, Mapper, MapperId, NewMapper, Permissions,
permissions::Caller,
storage::{ListPagination, MapperFilter, MapperStore, StoreError},
AccessGroupId, Mapper, MapperId, NewMapper, Permissions,
};

use crate::{
VApiStorage,
endpoints::login::UserInfo,
mapper::MappingEngine,
permissions::{VAppPermission, VPermission},
response::{resource_restricted, OptionalResource, ResourceResult},
VApiStorage,
response::{OptionalResource, ResourceResult, resource_restricted},
};

pub struct MappingContext<T> {
Expand Down Expand Up @@ -150,7 +150,10 @@ where
Err(err) => {
// TODO: Inspect the error. We expect to see a conflict error, and
// should is expected to be seen. Other errors are problematic.
tracing::warn!(?err, "Login may have attempted to use depleted mapper. This may be ok if it is an isolated occurrence, but should occur repeatedly.");
tracing::warn!(
?err,
"Login may have attempted to use depleted mapper. This may be ok if it is an isolated occurrence, but should occur repeatedly."
);
false
}
}
Expand Down
Loading
Loading