Skip to content

Commit

Permalink
Revert required test
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton committed Feb 8, 2024
1 parent 4a00e53 commit d395a4c
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 25 deletions.
7 changes: 7 additions & 0 deletions crates/bitwarden-api-identity/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ src/apis/info_api.rs
src/apis/mod.rs
src/apis/sso_api.rs
src/lib.rs
src/models/assertion_options.rs
src/models/authentication_extensions_client_inputs.rs
src/models/authenticator_transport.rs
src/models/kdf_type.rs
src/models/keys_request_model.rs
src/models/mod.rs
src/models/prelogin_request_model.rs
src/models/prelogin_response_model.rs
src/models/public_key_credential_descriptor.rs
src/models/public_key_credential_type.rs
src/models/register_request_model.rs
src/models/register_response_model.rs
src/models/user_verification_requirement.rs
src/models/web_authn_login_assertion_options_response_model.rs
38 changes: 23 additions & 15 deletions crates/bitwarden-api-identity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,38 @@ bitwarden-api-identity = { path = "./bitwarden-api-identity" }

All URIs are relative to _http://localhost_

| Class | Method | HTTP request | Description |
| ------------- | ----------------------------------------------------------------------------------- | ---------------------------------- | ----------- |
| _AccountsApi_ | [**accounts_prelogin_post**](docs/AccountsApi.md#accounts_prelogin_post) | **POST** /accounts/prelogin |
| _AccountsApi_ | [**accounts_register_post**](docs/AccountsApi.md#accounts_register_post) | **POST** /accounts/register |
| _InfoApi_ | [**alive_get**](docs/InfoApi.md#alive_get) | **GET** /alive |
| _InfoApi_ | [**now_get**](docs/InfoApi.md#now_get) | **GET** /now |
| _InfoApi_ | [**version_get**](docs/InfoApi.md#version_get) | **GET** /version |
| _SsoApi_ | [**account_external_callback_get**](docs/SsoApi.md#account_external_callback_get) | **GET** /account/ExternalCallback |
| _SsoApi_ | [**account_external_challenge_get**](docs/SsoApi.md#account_external_challenge_get) | **GET** /account/ExternalChallenge |
| _SsoApi_ | [**account_login_get**](docs/SsoApi.md#account_login_get) | **GET** /account/Login |
| _SsoApi_ | [**account_pre_validate_get**](docs/SsoApi.md#account_pre_validate_get) | **GET** /account/PreValidate |
| _SsoApi_ | [**sso_external_callback_get**](docs/SsoApi.md#sso_external_callback_get) | **GET** /sso/ExternalCallback |
| _SsoApi_ | [**sso_external_challenge_get**](docs/SsoApi.md#sso_external_challenge_get) | **GET** /sso/ExternalChallenge |
| _SsoApi_ | [**sso_login_get**](docs/SsoApi.md#sso_login_get) | **GET** /sso/Login |
| _SsoApi_ | [**sso_pre_validate_get**](docs/SsoApi.md#sso_pre_validate_get) | **GET** /sso/PreValidate |
| Class | Method | HTTP request | Description |
| ------------- | ---------------------------------------------------------------------------------------------------------- | -------------------------------------------- | ----------- |
| _AccountsApi_ | [**accounts_prelogin_post**](docs/AccountsApi.md#accounts_prelogin_post) | **POST** /accounts/prelogin |
| _AccountsApi_ | [**accounts_register_post**](docs/AccountsApi.md#accounts_register_post) | **POST** /accounts/register |
| _AccountsApi_ | [**accounts_webauthn_assertion_options_get**](docs/AccountsApi.md#accounts_webauthn_assertion_options_get) | **GET** /accounts/webauthn/assertion-options |
| _InfoApi_ | [**alive_get**](docs/InfoApi.md#alive_get) | **GET** /alive |
| _InfoApi_ | [**now_get**](docs/InfoApi.md#now_get) | **GET** /now |
| _InfoApi_ | [**version_get**](docs/InfoApi.md#version_get) | **GET** /version |
| _SsoApi_ | [**account_external_callback_get**](docs/SsoApi.md#account_external_callback_get) | **GET** /account/ExternalCallback |
| _SsoApi_ | [**account_external_challenge_get**](docs/SsoApi.md#account_external_challenge_get) | **GET** /account/ExternalChallenge |
| _SsoApi_ | [**account_login_get**](docs/SsoApi.md#account_login_get) | **GET** /account/Login |
| _SsoApi_ | [**account_pre_validate_get**](docs/SsoApi.md#account_pre_validate_get) | **GET** /account/PreValidate |
| _SsoApi_ | [**sso_external_callback_get**](docs/SsoApi.md#sso_external_callback_get) | **GET** /sso/ExternalCallback |
| _SsoApi_ | [**sso_external_challenge_get**](docs/SsoApi.md#sso_external_challenge_get) | **GET** /sso/ExternalChallenge |
| _SsoApi_ | [**sso_login_get**](docs/SsoApi.md#sso_login_get) | **GET** /sso/Login |
| _SsoApi_ | [**sso_pre_validate_get**](docs/SsoApi.md#sso_pre_validate_get) | **GET** /sso/PreValidate |

## Documentation For Models

- [AssertionOptions](docs/AssertionOptions.md)
- [AuthenticationExtensionsClientInputs](docs/AuthenticationExtensionsClientInputs.md)
- [AuthenticatorTransport](docs/AuthenticatorTransport.md)
- [KdfType](docs/KdfType.md)
- [KeysRequestModel](docs/KeysRequestModel.md)
- [PreloginRequestModel](docs/PreloginRequestModel.md)
- [PreloginResponseModel](docs/PreloginResponseModel.md)
- [PublicKeyCredentialDescriptor](docs/PublicKeyCredentialDescriptor.md)
- [PublicKeyCredentialType](docs/PublicKeyCredentialType.md)
- [RegisterRequestModel](docs/RegisterRequestModel.md)
- [RegisterResponseModel](docs/RegisterResponseModel.md)
- [UserVerificationRequirement](docs/UserVerificationRequirement.md)
- [WebAuthnLoginAssertionOptionsResponseModel](docs/WebAuthnLoginAssertionOptionsResponseModel.md)

To get access to the crate's generated documentation, use:

Expand Down
49 changes: 49 additions & 0 deletions crates/bitwarden-api-identity/src/apis/accounts_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ pub enum AccountsRegisterPostError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`accounts_webauthn_assertion_options_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AccountsWebauthnAssertionOptionsGetError {
UnknownValue(serde_json::Value),
}

pub async fn accounts_prelogin_post(
configuration: &configuration::Configuration,
prelogin_request_model: Option<crate::models::PreloginRequestModel>,
Expand Down Expand Up @@ -102,3 +109,45 @@ pub async fn accounts_register_post(
Err(Error::ResponseError(local_var_error))
}
}

pub async fn accounts_webauthn_assertion_options_get(
configuration: &configuration::Configuration,
) -> Result<
crate::models::WebAuthnLoginAssertionOptionsResponseModel,
Error<AccountsWebauthnAssertionOptionsGetError>,
> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!(
"{}/accounts/webauthn/assertion-options",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}

let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;

let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;

if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<AccountsWebauthnAssertionOptionsGetError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
14 changes: 14 additions & 0 deletions crates/bitwarden-api-identity/src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
pub mod assertion_options;
pub use self::assertion_options::AssertionOptions;
pub mod authentication_extensions_client_inputs;
pub use self::authentication_extensions_client_inputs::AuthenticationExtensionsClientInputs;
pub mod authenticator_transport;
pub use self::authenticator_transport::AuthenticatorTransport;
pub mod kdf_type;
pub use self::kdf_type::KdfType;
pub mod keys_request_model;
Expand All @@ -6,7 +12,15 @@ pub mod prelogin_request_model;
pub use self::prelogin_request_model::PreloginRequestModel;
pub mod prelogin_response_model;
pub use self::prelogin_response_model::PreloginResponseModel;
pub mod public_key_credential_descriptor;
pub use self::public_key_credential_descriptor::PublicKeyCredentialDescriptor;
pub mod public_key_credential_type;
pub use self::public_key_credential_type::PublicKeyCredentialType;
pub mod register_request_model;
pub use self::register_request_model::RegisterRequestModel;
pub mod register_response_model;
pub use self::register_response_model::RegisterResponseModel;
pub mod user_verification_requirement;
pub use self::user_verification_requirement::UserVerificationRequirement;
pub mod web_authn_login_assertion_options_response_model;
pub use self::web_authn_login_assertion_options_response_model::WebAuthnLoginAssertionOptionsResponseModel;
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct PreloginResponseModel {
#[serde(rename = "kdf")]
pub kdf: crate::models::KdfType,
#[serde(rename = "kdfIterations")]
pub kdf_iterations: i32,
#[serde(rename = "kdf", skip_serializing_if = "Option::is_none")]
pub kdf: Option<crate::models::KdfType>,
#[serde(rename = "kdfIterations", skip_serializing_if = "Option::is_none")]
pub kdf_iterations: Option<i32>,
#[serde(rename = "kdfMemory", skip_serializing_if = "Option::is_none")]
pub kdf_memory: Option<i32>,
#[serde(rename = "kdfParallelism", skip_serializing_if = "Option::is_none")]
pub kdf_parallelism: Option<i32>,
}

impl PreloginResponseModel {
pub fn new(kdf: crate::models::KdfType, kdf_iterations: i32) -> PreloginResponseModel {
pub fn new() -> PreloginResponseModel {
PreloginResponseModel {
kdf,
kdf_iterations,
kdf: None,
kdf_iterations: None,
kdf_memory: None,
kdf_parallelism: None,
}
Expand Down
12 changes: 9 additions & 3 deletions crates/bitwarden/src/auth/login/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,19 @@ pub(crate) fn parse_prelogin(response: PreloginResponseModel) -> Result<Kdf> {
default_pbkdf2_iterations,
};

Ok(match response.kdf {
let kdf = response.kdf.ok_or("KDF not found")?;

Ok(match kdf {
KdfType::Variant0 => Kdf::PBKDF2 {
iterations: NonZeroU32::new(response.kdf_iterations as u32)
iterations: response
.kdf_iterations
.and_then(|e| NonZeroU32::new(e as u32))
.unwrap_or_else(default_pbkdf2_iterations),
},
KdfType::Variant1 => Kdf::Argon2id {
iterations: NonZeroU32::new(response.kdf_iterations as u32)
iterations: response
.kdf_iterations
.and_then(|e| NonZeroU32::new(e as u32))
.unwrap_or_else(default_argon2_iterations),
memory: response
.kdf_memory
Expand Down

0 comments on commit d395a4c

Please sign in to comment.