Skip to content

Add client.allowedOrigins config option#13829

Open
lukasmasuch wants to merge 1 commit intodevelopfrom
lukasmasuch/allowed-origins
Open

Add client.allowedOrigins config option#13829
lukasmasuch wants to merge 1 commit intodevelopfrom
lukasmasuch/allowed-origins

Conversation

@lukasmasuch
Copy link
Collaborator

@lukasmasuch lukasmasuch commented Feb 5, 2026

Describe your changes

Implement a new client.allowedOrigins configuration option to allow deployers to customize which origins can send cross-origin postMessage commands to embedded Streamlit apps. The default list of Community Cloud origins is now configurable via config.toml instead of being hardcoded.

Github Issues

Testing Plan

  • All existing unit tests pass (127 tests)
  • Configuration option is properly validated and accessible via config.get_option()
  • Both Tornado and Starlette server implementations use the config option

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

Cursor Bugbot reviewed your changes and found no issues for commit f20b7b5

Implement a new configuration option to allow deployers to customize which
origins can send cross-origin postMessage commands to embedded Streamlit apps.
Moves the default allowed origins list from hardcoded constants in routes.py
to the config system, making it configurable via config.toml.
Copilot AI review requested due to automatic review settings February 5, 2026 00:28
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-13829/streamlit-1.53.1-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-13829.streamlit.app (☁️ Deploy here if not accessible)

@snyk-io
Copy link
Contributor

snyk-io bot commented Feb 5, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@lukasmasuch lukasmasuch changed the title Add client.allowedOrigins config option Add client.allowedOrigins config option Feb 5, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a new client.allowedOrigins configuration option that allows deployers to customize which origins can send cross-origin postMessage commands to embedded Streamlit apps. Previously, the list of allowed Community Cloud origins was hardcoded in routes.py.

Changes:

  • Moved _DEFAULT_ALLOWED_MESSAGE_ORIGINS constant from routes.py to config.py
  • Added new client.allowedOrigins config option with multiple=True to accept a list of origin strings
  • Updated both Tornado (routes.py) and Starlette (starlette_routes.py) server implementations to use config.get_option("client.allowedOrigins") instead of the hardcoded constant
  • Updated test imports and added the new config key to the test that validates all config option keys
  • Added unrelated ty: ignore[unresolved-attribute] type checker suppression comments to existing test code

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/streamlit/config.py Defines _DEFAULT_ALLOWED_MESSAGE_ORIGINS constant and creates new client.allowedOrigins config option with proper description and default value
lib/streamlit/web/server/routes.py Removes hardcoded constant and updates HostConfigHandler to use config option
lib/streamlit/web/server/starlette/starlette_routes.py Updates _host_config_endpoint to use config option instead of importing constant
lib/tests/streamlit/web/server/routes_test.py Updates import to reference constant from config module instead of routes
lib/tests/streamlit/config_test.py Adds new config key to validation test and adds type checker suppression comments to unrelated test code

@lukasmasuch lukasmasuch added security-assessment-completed Security assessment has been completed for PR change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users labels Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make "allowed message origins" a config option instead of hard-coded list

1 participant