Skip to content
Closed
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
50 changes: 0 additions & 50 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ webauthn-rs = { version = "0.5", features = [
] }
webauthn-rs-proto = "0.5"
x25519-dalek = { version = "2.0", features = ["static_secrets"] }
# openapi
utoipa = { version = "4", features = ["axum_extras"] }

[dev-dependencies]
bytes = "1.6"
Expand Down
3 changes: 1 addition & 2 deletions src/db/models/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use ipnetwork::IpNetwork;
use model_derive::Model;
use sqlx::{query, query_as, Error as SqlxError, FromRow, PgConnection, PgExecutor};
use thiserror::Error;
use utoipa::ToSchema;

use super::{
error::ModelError,
Expand Down Expand Up @@ -93,7 +92,7 @@ impl DeviceInfo {

// helper struct which includes full device info
// including network activity metadata
#[derive(Serialize, Deserialize, Clone, Debug, ToSchema)]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct UserDevice {
#[serde(flatten)]
pub device: Device,
Expand Down
5 changes: 2 additions & 3 deletions src/db/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub mod wireguard;
pub mod yubikey;

use sqlx::{query_as, Error as SqlxError, PgConnection};
use utoipa::ToSchema;

use self::{
device::UserDevice,
Expand Down Expand Up @@ -62,7 +61,7 @@ pub struct SecurityKey {
}

// Basic user info used in user list, etc.
#[derive(Deserialize, Serialize, Debug, Clone, ToSchema)]
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct UserInfo {
pub id: Option<i64>,
pub username: String,
Expand Down Expand Up @@ -185,7 +184,7 @@ impl UserInfo {
}

// Full user info with related objects
#[derive(Deserialize, Serialize, Debug, ToSchema)]
#[derive(Deserialize, Serialize, Debug)]
pub struct UserDetails {
pub user: UserInfo,
#[serde(default)]
Expand Down
3 changes: 1 addition & 2 deletions src/db/models/wireguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use model_derive::Model;
use rand_core::OsRng;
use sqlx::{query_as, query_scalar, Error as SqlxError, FromRow, PgConnection, PgExecutor};
use thiserror::Error;
use utoipa::ToSchema;
use x25519_dalek::{PublicKey, StaticSecret};

use super::{
Expand Down Expand Up @@ -68,7 +67,7 @@ pub enum GatewayEvent {
}

/// Stores configuration required to setup a WireGuard network
#[derive(Clone, Debug, Model, Deserialize, Serialize, PartialEq, ToSchema)]
#[derive(Clone, Debug, Model, Deserialize, Serialize, PartialEq)]
#[table(wireguard_network)]
pub struct WireguardNetwork {
pub id: Option<i64>,
Expand Down
3 changes: 1 addition & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use axum::http::StatusCode;
use sqlx::error::Error as SqlxError;
use thiserror::Error;
use utoipa::ToSchema;

use crate::{
auth::failed_login::FailedLoginError,
Expand All @@ -15,7 +14,7 @@ use crate::{
};

/// Represents kinds of error that occurred
#[derive(Debug, Error, ToSchema)]
#[derive(Debug, Error)]
pub enum WebError {
#[error("GRPC error: {0}")]
Grpc(String),
Expand Down
11 changes: 1 addition & 10 deletions src/handlers/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use axum::{
};
use serde_json::json;
use sqlx::query_as;
use utoipa::ToSchema;

use super::{ApiResponse, EditGroupInfo, GroupInfo, Username};
use crate::{
Expand All @@ -16,7 +15,7 @@ use crate::{
// ldap::utils::{ldap_add_user_to_group, ldap_modify_group, ldap_remove_user_from_group},
};

#[derive(Serialize, ToSchema)]
#[derive(Serialize)]
pub(crate) struct Groups {
groups: Vec<String>,
}
Expand Down Expand Up @@ -117,14 +116,6 @@ pub(crate) async fn list_groups_info(
}

/// GET: Retrieve all groups.
#[utoipa::path(
get,
path = "/api/v1/group",
responses(
(status = 200, description = "Retrieve all groups.", body = Groups),
(status = 403, description = "Forbidden error: ...")
)
)]
pub(crate) async fn list_groups(
_session: SessionInfo,
State(appstate): State<AppState>,
Expand Down
17 changes: 8 additions & 9 deletions src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use axum::{
Json,
};
use serde_json::{json, Value};
use utoipa::ToSchema;
use webauthn_rs::prelude::RegisterPublicKeyCredential;

#[cfg(feature = "wireguard")]
Expand Down Expand Up @@ -39,7 +38,7 @@ pub(crate) mod yubikey;
pub(crate) static SESSION_COOKIE_NAME: &str = "defguard_session";
static SIGN_IN_COOKIE_NAME: &str = "defguard_sign_in";

#[derive(Default, ToSchema)]
#[derive(Default)]
pub struct ApiResponse {
pub json: Value,
pub status: StatusCode,
Expand Down Expand Up @@ -197,7 +196,7 @@ pub struct EditGroupInfo {
pub members: Vec<String>,
}

#[derive(Deserialize, Serialize, ToSchema)]
#[derive(Deserialize, Serialize)]
pub struct Username {
pub username: String,
}
Expand All @@ -212,37 +211,37 @@ pub struct AddUserData {
pub password: Option<String>,
}

#[derive(Deserialize, ToSchema)]
#[derive(Deserialize)]
pub struct StartEnrollmentRequest {
#[serde(default)]
pub send_enrollment_notification: bool,
pub email: Option<String>,
}

#[derive(Deserialize, Serialize, ToSchema)]
#[derive(Deserialize, Serialize)]
pub struct PasswordChangeSelf {
pub old_password: String,
pub new_password: String,
}

#[derive(Deserialize, Serialize, ToSchema)]
#[derive(Deserialize, Serialize)]
pub struct PasswordChange {
pub new_password: String,
}

#[derive(Deserialize, ToSchema)]
#[derive(Deserialize)]
pub struct WalletSignature {
pub address: String,
pub signature: String,
}

#[derive(Deserialize, Serialize, ToSchema)]
#[derive(Deserialize, Serialize)]
pub struct WalletChallenge {
pub id: i64,
pub message: String,
}

#[derive(Deserialize, ToSchema)]
#[derive(Deserialize)]
pub struct WalletChange {
pub use_for_mfa: bool,
}
Expand Down
Loading