@@ -164,6 +164,14 @@ impl Default for UpdaterConfig {
164164 }
165165}
166166
167+ /// Security configuration.
168+ #[ derive( PartialEq , Deserialize , Debug , Clone , Default ) ]
169+ #[ serde( tag = "updater" , rename_all = "camelCase" ) ]
170+ pub struct SecurityConfig {
171+ /// Content security policy to inject to HTML files with the custom protocol.
172+ pub csp : Option < String > ,
173+ }
174+
167175/// A CLI argument definition
168176#[ derive( PartialEq , Deserialize , Debug , Default , Clone ) ]
169177#[ serde( rename_all = "camelCase" ) ]
@@ -340,6 +348,9 @@ pub struct TauriConfig {
340348 /// The updater configuration.
341349 #[ serde( default ) ]
342350 pub updater : UpdaterConfig ,
351+ /// The security configuration.
352+ #[ serde( default ) ]
353+ pub security : SecurityConfig ,
343354}
344355
345356impl Default for TauriConfig {
@@ -349,6 +360,7 @@ impl Default for TauriConfig {
349360 cli : None ,
350361 bundle : BundleConfig :: default ( ) ,
351362 updater : UpdaterConfig :: default ( ) ,
363+ security : SecurityConfig :: default ( ) ,
352364 }
353365 }
354366}
@@ -756,14 +768,23 @@ mod build {
756768 }
757769 }
758770
771+ impl ToTokens for SecurityConfig {
772+ fn to_tokens ( & self , tokens : & mut TokenStream ) {
773+ let csp = opt_str_lit ( self . csp . as_ref ( ) ) ;
774+
775+ literal_struct ! ( tokens, SecurityConfig , csp) ;
776+ }
777+ }
778+
759779 impl ToTokens for TauriConfig {
760780 fn to_tokens ( & self , tokens : & mut TokenStream ) {
761781 let windows = vec_lit ( & self . windows , identity) ;
762782 let cli = opt_lit ( self . cli . as_ref ( ) ) ;
763783 let bundle = & self . bundle ;
764784 let updater = & self . updater ;
785+ let security = & self . security ;
765786
766- literal_struct ! ( tokens, TauriConfig , windows, cli, bundle, updater) ;
787+ literal_struct ! ( tokens, TauriConfig , windows, cli, bundle, updater, security ) ;
767788 }
768789 }
769790
@@ -857,6 +878,7 @@ mod test {
857878 pubkey : None ,
858879 endpoints : None ,
859880 } ,
881+ security : SecurityConfig { csp : None } ,
860882 } ;
861883
862884 // create a build config
0 commit comments