Skip to content

Commit

Permalink
Handle CORS in secure connections (#5855)
Browse files Browse the repository at this point in the history
  • Loading branch information
eapolinario authored Oct 18, 2024
1 parent 38af4ec commit eda7521
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion flyteadmin/pkg/server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,19 @@ func serveGatewaySecure(ctx context.Context, pluginRegistry *plugins.Registry, c
panic(err)
}

handler := grpcHandlerFunc(grpcServer, httpServer)
if cfg.Security.AllowCors {
handler = handlers.CORS(
handlers.AllowCredentials(),
handlers.AllowedOrigins(cfg.Security.AllowedOrigins),
handlers.AllowedHeaders(append(defaultCorsHeaders, cfg.Security.AllowedHeaders...)),
handlers.AllowedMethods([]string{"GET", "POST", "DELETE", "HEAD", "PUT", "PATCH"}),
)(handler)
}

srv := &http.Server{
Addr: cfg.GetHostAddress(),
Handler: grpcHandlerFunc(grpcServer, httpServer),
Handler: handler,
// #nosec G402
TLSConfig: &tls.Config{
Certificates: []tls.Certificate{*cert},
Expand Down

0 comments on commit eda7521

Please sign in to comment.