@@ -159,79 +159,6 @@ impl TryFrom<ApplicationTrigger> for RedisTriggerConfiguration {
159159 }
160160}
161161
162- /// An HTTP host allow-list.
163- #[ derive( Clone , Debug , Eq , PartialEq ) ]
164- pub enum AllowedHttpHosts {
165- /// All HTTP hosts are allowed (the "insecure:allow-all" value was present in the list)
166- AllowAll ,
167- /// Only the specified hosts are allowed.
168- AllowSpecific ( Vec < AllowedHttpHost > ) ,
169- }
170-
171- impl Default for AllowedHttpHosts {
172- fn default ( ) -> Self {
173- Self :: AllowSpecific ( vec ! [ ] )
174- }
175- }
176-
177- impl AllowedHttpHosts {
178- /// Tests whether the given URL is allowed according to the allow-list.
179- pub fn allow ( & self , url : & url:: Url ) -> bool {
180- match self {
181- Self :: AllowAll => true ,
182- Self :: AllowSpecific ( hosts) => hosts. iter ( ) . any ( |h| h. allow ( url) ) ,
183- }
184- }
185- }
186-
187- /// An HTTP host allow-list entry.
188- #[ derive( Clone , Debug , Default , Eq , PartialEq ) ]
189- pub struct AllowedHttpHost {
190- domain : String ,
191- port : Option < u16 > ,
192- }
193-
194- impl AllowedHttpHost {
195- /// Creates a new allow-list entry.
196- pub fn new ( name : impl Into < String > , port : Option < u16 > ) -> Self {
197- Self {
198- domain : name. into ( ) ,
199- port,
200- }
201- }
202-
203- /// An allow-list entry that specifies a host and allows the default port.
204- pub fn host ( name : impl Into < String > ) -> Self {
205- Self {
206- domain : name. into ( ) ,
207- port : None ,
208- }
209- }
210-
211- /// An allow-list entry that specifies a host and port.
212- pub fn host_and_port ( name : impl Into < String > , port : u16 ) -> Self {
213- Self {
214- domain : name. into ( ) ,
215- port : Some ( port) ,
216- }
217- }
218-
219- fn allow ( & self , url : & url:: Url ) -> bool {
220- ( url. scheme ( ) == "http" || url. scheme ( ) == "https" )
221- && self . domain == url. host_str ( ) . unwrap_or_default ( )
222- && self . port == url. port ( )
223- }
224- }
225-
226- impl From < AllowedHttpHost > for String {
227- fn from ( allowed : AllowedHttpHost ) -> Self {
228- match allowed. port {
229- Some ( port) => format ! ( "{}:{}" , allowed. domain, port) ,
230- None => allowed. domain ,
231- }
232- }
233- }
234-
235162/// WebAssembly configuration.
236163#[ derive( Clone , Debug , Default ) ]
237164pub struct WasmConfig {
@@ -240,7 +167,7 @@ pub struct WasmConfig {
240167 /// List of directory mounts that need to be mapped inside the WebAssembly module.
241168 pub mounts : Vec < DirectoryMount > ,
242169 /// Optional list of HTTP hosts the component is allowed to connect.
243- pub allowed_http_hosts : AllowedHttpHosts ,
170+ pub allowed_http_hosts : Vec < String > ,
244171}
245172
246173/// Directory mount for the assets of a component.
0 commit comments