diff --git a/rust/agama-lib/src/users.rs b/rust/agama-lib/src/users.rs index d570b15386..45fb90b649 100644 --- a/rust/agama-lib/src/users.rs +++ b/rust/agama-lib/src/users.rs @@ -3,6 +3,7 @@ mod client; mod http_client; pub mod proxies; +pub mod model; mod settings; mod store; diff --git a/rust/agama-lib/src/users/http_client.rs b/rust/agama-lib/src/users/http_client.rs index 72007f9fd0..7897461319 100644 --- a/rust/agama-lib/src/users/http_client.rs +++ b/rust/agama-lib/src/users/http_client.rs @@ -1,25 +1,14 @@ use anyhow::anyhow; // WIP -use serde::Deserialize; //use reqwest::StatusCode; use super::client::FirstUser; use crate::{base_http_client::BaseHTTPClient, error::ServiceError}; +use crate::users::model::RootConfig; pub struct UsersHttpClient { client: BaseHTTPClient, } -// copying agama_server::users::web::RootConfig -// but not all derives -// #[derive(Clone, Debug, Default, Serialize, Deserialize, utoipa::ToSchema)] -#[derive(Clone, Debug, Default, Deserialize)] -pub struct RootConfig { - /// returns if password for root is set or not - password: bool, - /// empty string mean no sshkey is specified - sshkey: String, -} - impl UsersHttpClient { pub async fn new() -> Result { Ok(Self { @@ -91,7 +80,6 @@ impl UsersHttpClient { Ok(root_config.sshkey) } - /// SetRootSSHKey method pub async fn set_root_sshkey(&self, value: &str) -> Result { //Ok(self.users_proxy.set_root_sshkey(value).await?) diff --git a/rust/agama-server/src/users/web.rs b/rust/agama-server/src/users/web.rs index d360c8bc1f..12be77bf59 100644 --- a/rust/agama-server/src/users/web.rs +++ b/rust/agama-server/src/users/web.rs @@ -13,7 +13,11 @@ use crate::{ }; use agama_lib::{ error::ServiceError, - users::{proxies::Users1Proxy, FirstUser, UsersClient}, + users::{ + model::{RootConfig, RootPatchSettings}, + proxies::Users1Proxy, + FirstUser, UsersClient + }, }; use axum::{ extract::State, @@ -23,7 +27,6 @@ use axum::{ Json, Router, }; //use reqwest; -use serde::{Deserialize, Serialize}; use tokio_stream::{Stream, StreamExt}; #[derive(Clone)] @@ -191,17 +194,6 @@ async fn get_user_config(State(state): State>) -> Result, - /// empty string here means remove password for root - pub password: Option, - /// specify if patched password is provided in encrypted form - pub password_encrypted: Option, -} - #[utoipa::path(patch, path = "/users/root", responses( (status = 200, description = "Root configuration is modified", body = RootPatchSettings), (status = 400, description = "The D-Bus service could not perform the action"), @@ -226,14 +218,6 @@ async fn patch_root( Ok(()) } -#[derive(Clone, Debug, Default, Serialize, Deserialize, utoipa::ToSchema)] -pub struct RootConfig { - /// returns if password for root is set or not - password: bool, - /// empty string mean no sshkey is specified - sshkey: String, -} - #[utoipa::path(get, path = "/users/root", responses( (status = 200, description = "Configuration for the root user", body = RootConfig), (status = 400, description = "The D-Bus service could not perform the action"), diff --git a/rust/agama-server/src/web/docs.rs b/rust/agama-server/src/web/docs.rs index af9d28eacd..2241a686c6 100644 --- a/rust/agama-server/src/web/docs.rs +++ b/rust/agama-server/src/web/docs.rs @@ -113,8 +113,8 @@ use utoipa::OpenApi; schemas(crate::storage::web::iscsi::InitiatorParams), schemas(crate::storage::web::iscsi::LoginParams), schemas(crate::storage::web::iscsi::NodeParams), - schemas(crate::users::web::RootConfig), - schemas(crate::users::web::RootPatchSettings), + schemas(agama_lib::users::model::RootConfig), + schemas(agama_lib::users::model::RootPatchSettings), schemas(super::http::PingResponse) ) )]