wayver's git archive


a simple self-hosted git server
git clone https://git.wayver.dev/bile

Commit: 71b17dd92232913d023854951d629e9876076719 (tree)
Parent: 1160e836ead3fbd29e297268d1009d648b68cae0 (tree)
Author: wayverd
Date: 2026 M02 23, Mon 16:23:39 -0500
4 files changed; 22 insertions 26 deletions
move http-equiv permissions-policy meta to tower-helmet

diff --git a/Cargo.toml b/Cargo.toml
index e69c2ce..b536b21 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -20,10 +20,6 @@ clap = { version = "=4.5.59", features = ["derive", "string"] }
 comrak = { version = "=0.50.0", default-features = false }
 figment = { version = "=0.10.19", default-features = false, features = ["env", "toml"] }
 git2 = { version = "=0.20.4", default-features = false }
-# hitbox = "=0.2.1"
-# hitbox-http = "=0.2.0"
-# hitbox-moka = "=0.2.0"
-# hitbox-tower = "=0.2.0"
 http = "=1.4.0"
 jiff = "=0.2.20"
 mimalloc = "=0.1.48"
diff --git a/src/http/mod.rs b/src/http/mod.rs
index 19d0b35..0b77af4 100644
--- a/src/http/mod.rs
+++ b/src/http/mod.rs
@@ -60,3 +60,19 @@ fn wrap_err(state: BileState, res: Result<Response>) -> Response {
         }
     }
 }
+
+pub(crate) struct PermissionsPolicy;
+
+impl tower_helmet::IntoHeader for PermissionsPolicy {
+    fn header_name(&self) -> http::HeaderName {
+        http::HeaderName::from_static("permissions-policy")
+    }
+
+    fn header_value(
+        &self,
+    ) -> std::result::Result<http::HeaderValue, http::header::InvalidHeaderValue> {
+        http::HeaderValue::from_str(
+            "accelerometer=(),ambient-light-sensor=(),attribution-reporting=(),autoplay=(),bluetooth=(),browsing-topics=(),camera=(),captured-surface-control=(),clipboard-read=(),clipboard-write=(),compute-pressure=(),display-capture=(),document-domain=(),encrypted-media=(),fullscreen=(),gamepad=(),geolocation=(),gyroscope=(),hid=(),identity-credentials-get=(),idle-detection=(),interest-cohort=(),local-fonts=(),magnetometer=(),microphone=(),midi=(),on-device-speech-recognition=(),otp-credentials=(),payment=(),picture-in-picture=(),private-state-token-issuance=(),private-state-token-redemption=(),publickey-credentials-create=(),publickey-credentials-get=(),screen-wake-lock=(),serial=(),speaker-selection=(),storage-access=(),sync-xhr=(),usb=(),web-share=(),window-management=(),xr-spatial-tracking=()",
+        )
+    }
+}
diff --git a/src/lib.rs b/src/lib.rs
index d3864e4..d91824d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -287,25 +287,6 @@ impl Bile {
 
     #[rustfmt::skip]
     pub fn routes(&self) -> Router {
-        // let backend = MokaBackend::builder().max_entries(10_000).build();
-
-        // let config = hitbox::Config::builder()
-        //     .request_predicate(predicates::request::Method::new(http::Method::GET).unwrap())
-        //     .response_predicate(hitbox::Neutral::new().status_code_class(predicates::response::StatusClass::Success))
-        //     .extractor(extractors::Method::new())
-        //     .policy(
-        //         hitbox::policy::PolicyConfig::builder()
-        //             .ttl(Duration::from_secs(60))
-        //             .stale(Duration::from_secs(30))
-        //             .build(),
-        //     )
-        //     .build();
-
-        // let cache = hitbox_tower::Cache::builder()
-        //     .backend(backend.clone())
-        //     .config(config)
-        //     .build();
-
         Router::new()
             .route("/", get(handlers::index::get))
             // assets
@@ -353,7 +334,11 @@ impl Bile {
                 TraceLayer::new_for_http(),
                 TimeoutLayer::with_status_code(StatusCode::REQUEST_TIMEOUT, Duration::from_secs(10)),
                 CacheLayer::with_lifespan(Duration::from_secs(60)).use_stale_on_failure(),
-                HelmetLayer::with_defaults(),
+                {
+                    let mut layer = HelmetLayer::with_defaults();
+                    layer.enable(http::PermissionsPolicy);
+                    layer
+                },
             ))
     }
 }
diff --git a/templates/base.html b/templates/base.html
index 5796569..aaf3993 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -3,7 +3,6 @@
 
 <head>
   <meta charset="utf-8">
-  <meta http-equiv="Permissions-Policy" content="interest-cohort=()" />
   <meta name="mobile-web-app-capable" content="yes">
   <meta name="apple-mobile-web-app-capable" content="yes">
   <meta name="application-name" content="Bile">
@@ -11,7 +10,7 @@
   <meta name="theme-color" content="#3f8142">
   <meta name="msapplication-navbutton-color" content="#3f8142">
   <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
-  <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta name="description" content="My self-hosted git repositories">
   <title>{% block title %}{{config.site_name}}{% endblock %}</title>
   <link rel="manifest" href="manifest.json">