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

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

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

8 changes: 4 additions & 4 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/defguard_certs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl Csr<'_> {
}
}

#[derive(Debug, Copy, Clone)]
#[derive(Clone, Copy)]
pub enum PemLabel {
Certificate,
PrivateKey,
Expand Down
16 changes: 6 additions & 10 deletions crates/defguard_common/src/db/models/certificates.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use chrono::NaiveDateTime;
use serde::{Deserialize, Serialize};
use sqlx::{PgExecutor, query, query_as};
use sqlx::{PgExecutor, Type, query, query_as};
use utoipa::ToSchema;

/// Certificate source for the proxy HTTP/HTTPS listener.
Expand All @@ -9,9 +9,7 @@ use utoipa::ToSchema;
/// - `SelfSigned`: cert issued by the Core CA
/// - `LetsEncrypt`: cert obtained via ACME/Let's Encrypt
/// - `Custom`: admin-uploaded PEM cert + key
#[derive(
Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize, ToSchema, sqlx::Type,
)]
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, ToSchema, Type)]
#[sqlx(type_name = "text", rename_all = "snake_case")]
pub enum ProxyCertSource {
#[default]
Expand All @@ -26,9 +24,7 @@ pub enum ProxyCertSource {
/// - `None`: no cert configured, core runs plain HTTP
/// - `SelfSigned`: cert issued by the Core CA
/// - `Custom`: admin-uploaded PEM cert + key
#[derive(
Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize, ToSchema, sqlx::Type,
)]
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, ToSchema, Type)]
#[sqlx(type_name = "text", rename_all = "snake_case")]
pub enum CoreCertSource {
#[default]
Expand All @@ -41,7 +37,7 @@ pub enum CoreCertSource {
///
/// Holds the Core CA (used to sign gRPC TLS certs for gateways/proxies),
/// the proxy HTTP/HTTPS cert, and the core web server HTTPS cert.
#[derive(Clone, Debug, Default)]
#[derive(Clone, Default)]
pub struct Certificates {
// Core CA
pub ca_cert_der: Option<Vec<u8>>,
Expand Down Expand Up @@ -75,13 +71,13 @@ impl Certificates {
ca_cert_der, \
ca_key_der, \
ca_expiry, \
proxy_http_cert_source AS \"proxy_http_cert_source: ProxyCertSource\", \
proxy_http_cert_source \"proxy_http_cert_source: ProxyCertSource\", \
proxy_http_cert_pem, \
proxy_http_cert_key_pem, \
proxy_http_cert_expiry, \
acme_domain, \
acme_account_credentials, \
core_http_cert_source AS \"core_http_cert_source: CoreCertSource\", \
core_http_cert_source \"core_http_cert_source: CoreCertSource\", \
core_http_cert_pem, \
core_http_cert_key_pem, \
core_http_cert_expiry \
Expand Down
10 changes: 5 additions & 5 deletions crates/defguard_core/src/db/models/enrollment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,14 @@ impl Token {
where
E: PgExecutor<'e>,
{
debug!("Fetch admin data.");
debug!("Fetch admin data");
if self.admin_id.is_none() {
debug!("Admin don't have id. Stop fetching data...");
debug!("Admin doesn't have ID; stop fetching data");
return Ok(None);
}

let admin_id = self.admin_id.unwrap();
debug!("Trying to find admin using id {admin_id}");
debug!("Trying to find admin using ID {admin_id}");
let user = User::find_by_id(executor, admin_id).await?;
debug!("Fetched admin {user:?}.");

Expand All @@ -267,7 +267,7 @@ impl Token {
where
E: PgExecutor<'e>,
{
debug!("Deleting unused tokens for the user.");
debug!("Deleting unused tokens for the user");
let result = query!(
"DELETE FROM token \
WHERE user_id = $1 \
Expand All @@ -277,7 +277,7 @@ impl Token {
.execute(executor)
.await?;
info!(
"Deleted {} unused enrollment tokens for the user.",
"Deleted {} unused enrollment tokens for the user",
result.rows_affected()
);

Expand Down
4 changes: 2 additions & 2 deletions crates/defguard_core/src/enterprise/db/models/acl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl Default for AclRule {
impl<I> AclRule<I> {
pub(crate) fn stamp_modified(&mut self, actor: &str) {
self.modified_at = Utc::now().naive_utc();
self.modified_by = actor.to_owned();
actor.clone_into(&mut self.modified_by);
}
}

Expand Down Expand Up @@ -1538,7 +1538,7 @@ impl Default for AclAlias {
impl<I> AclAlias<I> {
pub(crate) fn stamp_modified(&mut self, actor: &str) {
self.modified_at = Utc::now().naive_utc();
self.modified_by = actor.to_owned();
actor.clone_into(&mut self.modified_by);
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/defguard_core/src/enterprise/ldap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ impl LDAPConnection {
info!("Found LDAP user with DN: {dn}");
user_from_searchentry(&entry, &user.username, None)
}
None => Err(LdapError::ObjectNotFound(format!("User {dn} not found",))),
None => Err(LdapError::ObjectNotFound(format!("User {dn} not found"))),
}
}

Expand Down
11 changes: 4 additions & 7 deletions crates/defguard_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,13 +697,10 @@ pub async fn run_web_server(
let app = webapp
.clone()
.into_make_service_with_connect_info::<SocketAddr>();
let current_tls_cert_pair = Certificates::get_or_default(&pool)
.await
.map(|c| {
c.core_http_cert_pair()
.map(|(cert, key)| (cert.to_owned(), key.to_owned()))
})
.unwrap_or(None);
let current_tls_cert_pair = Certificates::get_or_default(&pool).await.map_or(None, |c| {
c.core_http_cert_pair()
.map(|(cert, key)| (cert.to_owned(), key.to_owned()))
});

let mut server_task = tokio::spawn(async move {
if let Some((cert_pem, key_pem)) = current_tls_cert_pair {
Expand Down
Loading
Loading