mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-30 06:51:30 +02:00
mcp: add global runtime flag (#5604)
## Summary Adds global runtime flag to enable/disable MCP support. (off by default). ```yaml runtime_flags: mcp: true ``` ## Related issues Fix: https://linear.app/pomerium/issue/ENG-2367/place-mcp-support-behind-a-runtime-flag ## User Explanation <!-- How would you explain this change to the user? If this change doesn't create any user-facing changes, you can leave this blank. If filled out, add the `docs` label --> ## Checklist - [x] reference any related issues - [ ] updated unit tests - [ ] add appropriate label (`enhancement`, `bug`, `breaking`, `dependencies`, `ci`) - [ ] ready for review
This commit is contained in:
parent
d1559eaa86
commit
1a19ccabd8
10 changed files with 100 additions and 31 deletions
|
@ -76,18 +76,19 @@ func New(ctx context.Context, cfg *config.Config) (*Proxy, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
mcp, err := mcp.New(ctx, mcp.DefaultPrefix, cfg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("proxy: failed to create mcp handler: %w", err)
|
||||
}
|
||||
|
||||
p := &Proxy{
|
||||
tracerProvider: tracerProvider,
|
||||
state: atomicutil.NewValue(state),
|
||||
currentConfig: atomicutil.NewValue(&config.Config{Options: config.NewDefaultOptions()}),
|
||||
currentRouter: atomicutil.NewValue(httputil.NewRouter()),
|
||||
logoProvider: portal.NewLogoProvider(),
|
||||
mcp: atomicutil.NewValue(mcp),
|
||||
}
|
||||
if cfg.Options.IsRuntimeFlagSet(config.RuntimeFlagMCP) {
|
||||
mcp, err := mcp.New(ctx, mcp.DefaultPrefix, cfg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("proxy: failed to create mcp handler: %w", err)
|
||||
}
|
||||
p.mcp = atomicutil.NewValue(mcp)
|
||||
}
|
||||
p.OnConfigChange(ctx, cfg)
|
||||
p.webauthn = webauthn.New(p.getWebauthnState)
|
||||
|
@ -110,11 +111,13 @@ func (p *Proxy) OnConfigChange(ctx context.Context, cfg *config.Config) {
|
|||
return
|
||||
}
|
||||
|
||||
mcp, err := mcp.New(ctx, mcp.DefaultPrefix, cfg)
|
||||
if err != nil {
|
||||
log.Ctx(ctx).Error().Err(err).Msg("proxy: failed to update proxy state from configuration settings")
|
||||
} else {
|
||||
p.mcp.Store(mcp)
|
||||
if cfg.Options.IsRuntimeFlagSet(config.RuntimeFlagMCP) {
|
||||
mcp, err := mcp.New(ctx, mcp.DefaultPrefix, cfg)
|
||||
if err != nil {
|
||||
log.Ctx(ctx).Error().Err(err).Msg("proxy: failed to update proxy state from configuration settings")
|
||||
} else {
|
||||
p.mcp.Store(mcp)
|
||||
}
|
||||
}
|
||||
|
||||
p.currentConfig.Store(cfg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue