diff --git a/Cargo.lock b/Cargo.lock index 1d2606663..ff2deceb9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3249,6 +3249,7 @@ dependencies = [ "base64 0.22.1", "gix", "serde", + "sha2", "toml", ] diff --git a/libs/profiles/Cargo.toml b/libs/profiles/Cargo.toml index 99555b59a..038b582c4 100644 --- a/libs/profiles/Cargo.toml +++ b/libs/profiles/Cargo.toml @@ -20,9 +20,10 @@ test = false doctest = false [dependencies] -serde = { workspace = true, features = ["derive"] } -toml = { workspace = true } base64 = { workspace = true } +serde = { workspace = true, features = ["derive"] } +sha2 = { workspace = true } +toml = { workspace = true } [build-dependencies] base64 = { workspace = true } diff --git a/libs/profiles/src/lib.rs b/libs/profiles/src/lib.rs index 3b2ba2234..136338a10 100644 --- a/libs/profiles/src/lib.rs +++ b/libs/profiles/src/lib.rs @@ -1,5 +1,7 @@ +use base64::prelude::BASE64_STANDARD; use base64::{engine::general_purpose, Engine as _}; use serde::Deserialize; +use sha2::Digest; use std::env; // To debug why a rebuild is requested. @@ -83,16 +85,22 @@ pub fn apply_profile() { println!("cargo:rerun-if-env-changed=CARGO_PKG_VERSION"); println!("cargo:rerun-if-env-changed=KANIDM_PKG_COMMIT_REV"); - let version = env!("CARGO_PKG_VERSION"); - if let Some(commit_rev) = option_env!("KANIDM_PKG_COMMIT_REV") { - println!( - "cargo:rustc-env=KANIDM_PKG_VERSION={} {}", - version, commit_rev - ); - } else { - println!("cargo:rustc-env=KANIDM_PKG_VERSION={}", version); + let kanidm_pkg_version = match option_env!("KANIDM_PKG_COMMIT_REV") { + Some(commit_rev) => format!("{} {}", env!("CARGO_PKG_VERSION"), commit_rev), + None => env!("CARGO_PKG_VERSION").to_string(), }; + println!("cargo:rustc-env=KANIDM_PKG_VERSION={}", kanidm_pkg_version); + + // KANIDM_PKG_VERSION_HASH is used for cache busting in the web UI + let mut kanidm_pkg_version_hash = sha2::Sha256::new(); + kanidm_pkg_version_hash.update(kanidm_pkg_version.as_bytes()); + let kanidm_pkg_version_hash = &BASE64_STANDARD.encode(kanidm_pkg_version_hash.finalize())[..8]; + println!( + "cargo:rustc-env=KANIDM_PKG_VERSION_HASH={}", + kanidm_pkg_version_hash + ); + let version_pre = env!("CARGO_PKG_VERSION_PRE"); if version_pre == "dev" { println!("cargo:rustc-env=KANIDM_PRE_RELEASE=1"); diff --git a/libs/sketching/src/otel.rs b/libs/sketching/src/otel.rs index 3fb27d247..5c8fe32d8 100644 --- a/libs/sketching/src/otel.rs +++ b/libs/sketching/src/otel.rs @@ -68,7 +68,7 @@ pub fn start_logging_pipeline( ); // this env var gets set at build time, if we can pull it, add it to the metadata - let git_rev = match option_env!("KANIDM_KANIDM_PKG_COMMIT_REV") { + let git_rev = match option_env!("KANIDM_PKG_COMMIT_REV") { Some(rev) => format!("-{}", rev), None => "".to_string(), }; diff --git a/scripts/setup_dev_environment.sh b/scripts/setup_dev_environment.sh index 91ceadd45..0fdb91334 100755 --- a/scripts/setup_dev_environment.sh +++ b/scripts/setup_dev_environment.sh @@ -7,6 +7,8 @@ # - set up a test oauth2 rp (https://kanidm.com) # - prompt to reset testuser's creds online +set -e + if [ -n "${BUILD_MODE}" ]; then BUILD_MODE="--${BUILD_MODE}" else diff --git a/server/core/src/config.rs b/server/core/src/config.rs index ac18b4238..66a9bf00b 100644 --- a/server/core/src/config.rs +++ b/server/core/src/config.rs @@ -256,8 +256,13 @@ impl ServerConfig { let ignorable_build_fields = [ "KANIDM_CPU_FLAGS", + "KANIDM_CPU_FLAGS", + "KANIDM_DEFAULT_CONFIG_PATH", "KANIDM_DEFAULT_CONFIG_PATH", "KANIDM_DEFAULT_UNIX_SHELL_PATH", + "KANIDM_DEFAULT_UNIX_SHELL_PATH", + "KANIDM_HTMX_UI_PKG_PATH", + "KANIDM_PKG_VERSION_HASH", "KANIDM_PKG_VERSION", "KANIDM_PRE_RELEASE", "KANIDM_PROFILE_NAME", diff --git a/server/core/src/https/cache_buster.rs b/server/core/src/https/cache_buster.rs new file mode 100644 index 000000000..1d48d94b5 --- /dev/null +++ b/server/core/src/https/cache_buster.rs @@ -0,0 +1,11 @@ +//! Used for appending cache-busting query parameters to URLs. +//! + +#[allow(dead_code)] // Because it's used in templates +/// Gets the git rev from the KANIDM_PKG_COMMIT_REV variable else drops back to the version, to allow for cache-busting parameters in URLs +#[inline] +pub fn get_cache_buster_key() -> String { + option_env!("KANIDM_PKG_VERSION_HASH") // this comes from the profiles crate at build time + .unwrap_or(env!("CARGO_PKG_VERSION")) + .to_string() +} diff --git a/server/core/src/https/javascript.rs b/server/core/src/https/javascript.rs index f84901fd5..caca71e4b 100644 --- a/server/core/src/https/javascript.rs +++ b/server/core/src/https/javascript.rs @@ -43,7 +43,7 @@ pub struct JavaScriptFile { } impl JavaScriptFile { - /// returns a ` - + + + (% block head %)(% endblock %) @@ -26,7 +24,8 @@ (% block body %)(% endblock %) diff --git a/server/core/templates/base_htmx.html b/server/core/templates/base_htmx.html index 3f2719cb2..6cd2a6bba 100644 --- a/server/core/templates/base_htmx.html +++ b/server/core/templates/base_htmx.html @@ -1,25 +1,26 @@ - + + (% block title %)(( title )) - Kanidm(% endblock %) - - - - - + (% include "base_icons.html" %) - - - - + + + + (% block head %)(% endblock %) @@ -28,9 +29,9 @@ (% block body %)(% endblock %) - diff --git a/server/core/templates/base_icons.html b/server/core/templates/base_icons.html new file mode 100644 index 000000000..218f9ebbc --- /dev/null +++ b/server/core/templates/base_icons.html @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/server/core/templates/credentials_reset_form.html b/server/core/templates/credentials_reset_form.html index 3907a9e8f..0bbc27fa2 100644 --- a/server/core/templates/credentials_reset_form.html +++ b/server/core/templates/credentials_reset_form.html @@ -4,47 +4,57 @@ (% block head %) - - + + (% endblock %) (% block body %)
- +

Credential Reset

(( domain_info.display_name() ))

- + - (% if wrong_code %) -
-
  • Unknown reset token.
    Brand-new tokens might not be synced yet,
    wait a few minutes before trying again.
+ id="token" + name="token" + autofocus + aria-describedby="unknown-reset-token-validation-feedback" + (% if wrong_code %) + class='form-control is-invalid' + (% else %) + class='form-control' + (% endif %)> + (% if wrong_code %) +
+
  • Unknown reset token.
    Brand-new tokens might not be + synced yet,
    wait a few minutes before trying + again.
- (% endif %) + (% endif %)

-

diff --git a/server/core/templates/credentials_update_partial.html b/server/core/templates/credentials_update_partial.html index 741c824f7..de35c791f 100644 --- a/server/core/templates/credentials_update_partial.html +++ b/server/core/templates/credentials_update_partial.html @@ -1,121 +1,147 @@ - - + + -
+
(% match ext_cred_portal %) - (% when CUExtPortal::None %) - (% when CUExtPortal::Hidden %) -
-

This account is externally managed. Some features may not be available.

- (% when CUExtPortal::Some(url) %) -
-

This account is externally managed. Some features may not be available.

- Visit the external account portal + (% when CUExtPortal::None %) + (% when CUExtPortal::Hidden %) +
+

This account is externally managed. Some features may not be + available.

+ (% when CUExtPortal::Some(url) %) +
+

This account is externally managed. Some features may not be + available.

+ Visit the external account portal (% endmatch %) (% if warnings.len() > 0 %) -
- (% for warning in warnings %) - (% let is_danger = [CURegWarning::WebauthnAttestationUnsatisfiable, CURegWarning::Unsatisfiable].contains(warning) %) - (% if is_danger %) -
+ +
diff --git a/server/core/templates/login_base.html b/server/core/templates/login_base.html index 867442087..b8403ff47 100644 --- a/server/core/templates/login_base.html +++ b/server/core/templates/login_base.html @@ -6,18 +6,21 @@ (% endblock %) (% block body %) -
-
- (% if domain_custom_image %) - - (% else %) - - (% endif %) -

Kanidm

-
-
- (% block logincontainer %) - (% endblock %) -
-
+
+
+ (% if domain_custom_image %) + + (% else %) + + (% endif %) +

Kanidm

+
+
+ (% block logincontainer %) + (% endblock %) +
+
(% endblock %) diff --git a/server/core/templates/login_webauthn.html b/server/core/templates/login_webauthn.html index 19f9fcf7e..bb749ad35 100644 --- a/server/core/templates/login_webauthn.html +++ b/server/core/templates/login_webauthn.html @@ -5,13 +5,19 @@ (( chal|safe )) - - + + (% if passkey %) - + (% else %) - + (% endif %) (% endblock %) diff --git a/server/core/templates/navbar.html b/server/core/templates/navbar.html index d330488f2..2e170eabf 100644 --- a/server/core/templates/navbar.html +++ b/server/core/templates/navbar.html @@ -1,22 +1,33 @@