MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / new

Method new

src/environmentd/src/http.rs:224–667  ·  view source on GitHub ↗
(
        HttpConfig {
            source,
            tls,
            authenticator_kind,
            frontegg,
            oidc_rx,
            adapter_client_rx,
            allowed_origin,
      

Source from the content-addressed store, hash-verified

222
223impl HttpServer {
224 pub fn new(
225 HttpConfig {
226 source,
227 tls,
228 authenticator_kind,
229 frontegg,
230 oidc_rx,
231 adapter_client_rx,
232 allowed_origin,
233 allowed_origin_list,
234 active_connection_counter,
235 helm_chart_version,
236 http_host_name,
237 frontegg_oauth_issuer_url,
238 concurrent_webhook_req,
239 dyncfgs,
240 metrics,
241 metrics_registry,
242 mcp_metrics,
243 oauth_metadata_metrics,
244 allowed_roles,
245 internal_route_config,
246 routes_enabled,
247 replica_http_locator,
248 }: HttpConfig,
249 ) -> HttpServer {
250 let tls_enabled = tls.is_some();
251 let webhook_cache = WebhookAppenderCache::new();
252
253 // Compute OAuth discovery once per listener so the Bearer challenge
254 // and the discovery handler always agree, and the middleware doesn't
255 // re-derive (and re-allocate the Frontegg issuer) on each request.
256 let oauth_discovery = Arc::new(oauth_metadata::McpOAuthDiscovery::for_authenticator(
257 authenticator_kind,
258 frontegg_oauth_issuer_url.as_deref(),
259 ));
260
261 // Create secure session store and manager
262 let session_store = TowerSessionMemoryStore::default();
263 let session_layer = TowerSessionManagerLayer::new(session_store)
264 .with_secure(tls_enabled) // Enforce HTTPS
265 .with_same_site(tower_sessions::cookie::SameSite::Strict) // Prevent CSRF
266 .with_http_only(true) // Prevent XSS
267 .with_name("mz_session") // Custom cookie name
268 .with_path("/"); // Set cookie path
269
270 let frontegg_middleware = frontegg.clone();
271 let oidc_middleware_rx = oidc_rx.clone();
272 let adapter_client_middleware_rx = adapter_client_rx.clone();
273 let auth_middleware = middleware::from_fn(move |req, next| {
274 let frontegg = frontegg_middleware.clone();
275 let oidc_rx = oidc_middleware_rx.clone();
276 let adapter_client_rx = adapter_client_middleware_rx.clone();
277 async move {
278 http_auth(
279 req,
280 next,
281 tls_enabled,

Callers

nothing calls this directly

Calls 15

http_authFunction · 0.85
cloneFunction · 0.85
handle_homeFunction · 0.85
disableFunction · 0.85
anyFunction · 0.85
handle_prometheusFunction · 0.85
handle_promsqlFunction · 0.85
HelmChartVersionClass · 0.85
epoch_to_uuid_v7Function · 0.85
is_someMethod · 0.80
layerMethod · 0.80
routeMethod · 0.80

Tested by

no test coverage detected