Skip to content

Commit

Permalink
Tweak secrets manager export of password generator (#1021)
Browse files Browse the repository at this point in the history
## 🎟️ Tracking

<!-- Paste the link to the Jira or GitHub issue or otherwise describe /
point to where this change is coming from. -->

## 📔 Objective

<!-- Describe what the purpose of this PR is, for example what bug
you're fixing or new feature you're adding. -->

- Change generators export to not live under `secrets_manager`
namespace.
- Since we now provide a `client_generators` we can stop exporting the
generators.

## ⏰ Reminders before review

- Contributor guidelines followed
- All formatters and local linters executed and passed
- Written new unit and / or integration tests where applicable
- Protected functional changes with optionality (feature flags)
- Used internationalization (i18n) for all UI strings
- CI builds passed
- Communicated to DevOps any deployment requirements
- Updated any necessary documentation (Confluence, contributing docs) or
informed the documentation
  team

## 🦮 Reviewer guidelines

<!-- Suggested interactions but feel free to use (or not) as you desire!
-->

- 👍 (`:+1:`) or similar for great changes
- 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info
- ❓ (`:question:`) for questions
- 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry
that's not quite a confirmed
  issue and could potentially benefit from discussion
- 🎨 (`:art:`) for suggestions / improvements
- ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or
concerns needing attention
- 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or
indications of technical debt
- ⛏ (`:pick:`) for minor or nitpick changes
  • Loading branch information
Hinton authored Sep 9, 2024
1 parent 82065b1 commit 3f376b5
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 24 deletions.
5 changes: 3 additions & 2 deletions crates/bitwarden-generators/src/client_generator.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use bitwarden_core::Client;

use crate::{
passphrase, password, username, PassphraseError, PassphraseGeneratorRequest, PasswordError,
PasswordGeneratorRequest, UsernameError, UsernameGeneratorRequest,
passphrase::passphrase, password::password, username::username, PassphraseError,
PassphraseGeneratorRequest, PasswordError, PasswordGeneratorRequest, UsernameError,
UsernameGeneratorRequest,
};

pub struct ClientGenerator<'a> {
Expand Down
16 changes: 8 additions & 8 deletions crates/bitwarden-generators/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
mod passphrase;
pub use passphrase::{passphrase, PassphraseError, PassphraseGeneratorRequest};
mod password;
mod util;
pub use password::{password, PasswordError, PasswordGeneratorRequest};
mod username;
pub use username::{username, ForwarderServiceType, UsernameError, UsernameGeneratorRequest};
mod client_generator;
pub use client_generator::{ClientGenerator, ClientGeneratorExt};
mod username_forwarders;
pub use client_generator::{ClientGenerator, ClientGeneratorExt};
pub(crate) mod passphrase;
pub use passphrase::{PassphraseError, PassphraseGeneratorRequest};
pub(crate) mod password;
pub use password::{PasswordError, PasswordGeneratorRequest};
pub(crate) mod username;
pub use username::{ForwarderServiceType, UsernameError, UsernameGeneratorRequest};
mod util;

#[cfg(feature = "uniffi")]
uniffi::setup_scaffolding!();
2 changes: 1 addition & 1 deletion crates/bitwarden-generators/src/passphrase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl PassphraseGeneratorRequest {
}

/// Implementation of the random passphrase generator.
pub fn passphrase(request: PassphraseGeneratorRequest) -> Result<String, PassphraseError> {
pub(crate) fn passphrase(request: PassphraseGeneratorRequest) -> Result<String, PassphraseError> {
let options = request.validate_options()?;
Ok(passphrase_with_rng(rand::thread_rng(), options))
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-generators/src/password.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl PasswordGeneratorRequest {
}

/// Implementation of the random password generator.
pub fn password(input: PasswordGeneratorRequest) -> Result<String, PasswordError> {
pub(crate) fn password(input: PasswordGeneratorRequest) -> Result<String, PasswordError> {
let options = input.validate_options()?;
Ok(password_with_rng(rand::thread_rng(), options))
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-generators/src/username.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl ForwarderServiceType {
///
/// Note: The HTTP client is passed in as a required parameter for convenience,
/// as some username generators require making API calls.
pub async fn username(
pub(crate) async fn username(
input: UsernameGeneratorRequest,
http: &reqwest::Client,
) -> Result<String, UsernameError> {
Expand Down
9 changes: 5 additions & 4 deletions crates/bitwarden-json/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#[cfg(feature = "secrets")]
use bitwarden::secrets_manager::{
generators::ClientGeneratorExt, ClientProjectsExt, ClientSecretsExt,
};
#[cfg(feature = "internal")]
use bitwarden::vault::ClientVaultExt;
use bitwarden::ClientSettings;
#[cfg(feature = "secrets")]
use bitwarden::{
generators::ClientGeneratorExt,
secrets_manager::{ClientProjectsExt, ClientSecretsExt},
};

#[cfg(feature = "secrets")]
use crate::command::{GeneratorsCommand, ProjectsCommand, SecretsCommand};
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-json/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#[cfg(feature = "secrets")]
use bitwarden::{
auth::login::AccessTokenLoginRequest,
generators::PasswordGeneratorRequest,
secrets_manager::{
generators::PasswordGeneratorRequest,
projects::{
ProjectCreateRequest, ProjectGetRequest, ProjectPutRequest, ProjectsDeleteRequest,
ProjectsListRequest,
Expand Down
1 change: 1 addition & 0 deletions crates/bitwarden/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Added

- Support for secrets sync (#678)
- Password generator (#986)

### Changed

Expand Down
12 changes: 6 additions & 6 deletions crates/bitwarden/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ pub mod internal {
#[cfg(feature = "internal")]
pub use internal::*;

// Re-export generators used for secrets-manager, internal flag already exports all generators
#[cfg(all(feature = "secrets", not(feature = "internal")))]
pub mod generators {
pub use bitwarden_generators::{ClientGeneratorExt, PasswordError, PasswordGeneratorRequest};
}

#[cfg(feature = "secrets")]
pub mod secrets_manager {
pub use bitwarden_sm::*;

pub mod generators {
pub use bitwarden_generators::{
password, ClientGeneratorExt, PasswordError, PasswordGeneratorRequest,
};
}
}

0 comments on commit 3f376b5

Please sign in to comment.