Răsfoiți Sursa

feat(bundler) add exception_domain option by nothingismagick (#439)

Lucas Fernandes Nogueira 5 ani în urmă
părinte
comite
12ed096bea

+ 21 - 0
cli/tauri-bundler/src/bundle/osx_bundle.rs

@@ -214,6 +214,27 @@ fn create_info_plist(
       copyright
     )?;
   }
+
+  if let Some(exception_domain) = settings.exception_domain() {
+    write!(
+      file,
+      "  <key>NSAppTransportSecurity</key>\n  \
+      <dict>\n  \
+          <key>NSExceptionDomains</key>\n  \
+          <dict>\n  \
+              <key>{}</key>\n  \
+              <dict>\n  \
+                  <key>NSExceptionAllowsInsecureHTTPLoads</key>\n  \
+                  <true/>\n  \
+                  <key>NSIncludesSubdomains</key>\n  \
+                  <true/>\n  \
+              </dict>\n  \
+          </dict>\n  \
+      </dict>",
+      exception_domain
+    )?;
+  }
+
   write!(file, "</dict>\n</plist>\n")?;
   file.flush()?;
   Ok(())

+ 5 - 0
cli/tauri-bundler/src/bundle/settings.rs

@@ -111,6 +111,7 @@ struct BundleSettings {
   bin: Option<HashMap<String, BundleSettings>>,
   example: Option<HashMap<String, BundleSettings>>,
   external_bin: Option<Vec<String>>,
+  exception_domain: Option<String>,
 }
 
 #[derive(Clone, Debug, Deserialize)]
@@ -433,6 +434,10 @@ impl Settings {
     }
   }
 
+  pub fn exception_domain(&self) -> Option<&String> {
+    return self.bundle_settings.exception_domain.as_ref()
+  }
+
   // copy external binaries to a path.
   pub fn copy_binaries(&self, path: &Path) -> crate::Result<()> {
     for src in self.external_binaries() {