-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: select CSP by mounted application #9408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mvanhorn
wants to merge
3
commits into
logto-io:master
Choose a base branch
from
mvanhorn:fix/7456-console-path-csp-selection
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+58
−3
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@logto/core": patch | ||
| --- | ||
|
|
||
| fix self-hosted Console entry points when requests are served by the Experience fallback |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify what you actually observed? Specifically: which URL you requested (core endpoint vs. admin endpoint), and what the response looked like — blank page, 404, or the sign-in page. I'd like to make sure we're fixing the same thing.
The reason I ask is that in the scenarios listed in the description,
koaSecurityHeadersisn't the last middleware to set the CSP header. When/consoleis requested on a tenant that doesn't mount the Console (e.g.localhost:3001/console, which resolves to thedefaulttenant), the request continues down tokoaExperienceSecurityHeadersinTenant.ts. That middleware guards on the samemountedAppslist, so it doesn't early-return either — it calls helmet again, and since helmet usesres.setHeader, the Console policy is replaced rather than merged.Stepping through the chain on current master, production mode,
mountedApps= the default tenant's list,GET /console:So the header that reaches the browser already carries
'unsafe-inline', and the inline SSR bootstrap that setswindow.logtoSsrisn't blocked. The two conditions are the same predicate over the same list, so this holds by construction: any request where the Console branch matches wrongly is a request the experience middleware rewrites. That was fixed in #8778 when the experience CSP moved into its own middleware.If you're still hitting the blank page, that would point at something the above doesn't cover, and I'd rather understand that case first before we change the branch here.
One separate note on the original report: forwarding
/consoleto port 3002 isn't enough on its own. Tenant resolution matches on origin, not port, so unlessADMIN_ENDPOINTis set to the externally visible origin, the request falls to thedefaulttenant and gets the sign-in page rather than the Console.