-
-
Notifications
You must be signed in to change notification settings - Fork 254
fix forwarded headers options's allowed hosts with trusted origins (#10916) #10917
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
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes refactor origin validation across the server and web projects by introducing and standardizing a Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ServerApi
participant Settings
Client->>ServerApi: Sends request with Origin header
ServerApi->>Settings: Calls IsTrustedOrigin(origin)
Settings-->>ServerApi: Returns true/false
alt Origin is trusted
ServerApi-->>Client: Process request as valid
else Origin is not trusted
ServerApi-->>Client: Return BadRequestException
end
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Pull Request Overview
Fix merging of trusted origins into forwarded headers allowed hosts and introduce TrustedOrigins setting for CORS, social sign-in redirect URLs, and forwarded headers.
- Add
TrustedOriginsarray and documentation to both Web and API settings. - Update middleware configuration to include
TrustedOriginsinForwardedHeadersOptions.AllowedHosts. - Rename
IsAllowedOrigintoIsTrustedOriginand update all references. - Adjust
appsettings.jsonto replace top-levelAllowedHostswithTrustedOrigins.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| appsettings.json | Replaced top-level AllowedHosts with TrustedOrigins, moved ResponseCaching and AllowedHosts entries. |
| ServerWebSettings.cs | Added TrustedOrigins property with XML doc comment. |
| Program.Middlewares.cs (Web) | Merge TrustedOrigins into ForwardedHeadersOptions.AllowedHosts and adjust conditional UseForwardedHeaders. |
| ServerApiSettings.cs | Moved TrustedOrigins definition, renamed IsAllowedOrigin to IsTrustedOrigin. |
| Program.Services.cs | Updated CORS policy to call settings.IsTrustedOrigin. |
| Program.Middlewares.cs (API) | Same merge of TrustedOrigins for API forwarded headers. |
| HttpRequestExtensions.cs | Changed origin check to use settings.IsTrustedOrigin. |
Comments suppressed due to low confidence (2)
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/ServerWebSettings.cs:14
- [nitpick] Summary for TrustedOrigins conflates multiple responsibilities (CORS, social sign-in URLs, forwarded headers). Consider splitting documentation or clarifying this property’s single responsibility.
/// Specifies the allowed origins for CORS requests, URLs returned after social sign-in and email confirmation, and permitted origins for Web Auth, as well as forwarded headers middleware in ASP.NET Core.
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Program.Middlewares.cs:34
- Consider adding unit or integration tests to cover merging of
TrustedOriginsintoForwardedHeadersOptions.AllowedHostsand verifyingUseForwardedHeadersbehavior under different environments.
var forwardedHeadersOptions = settings.ForwardedHeaders;
...mplates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Program.Middlewares.cs
Outdated
Show resolved
Hide resolved
...mplates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Middlewares.cs
Outdated
Show resolved
Hide resolved
...rplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Extensions/HttpRequestExtensions.cs
Show resolved
Hide resolved
…te.Server.Web/Program.Middlewares.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Yaser Moradi <ysmoradi@outlook.com>
…te.Server.Api/Program.Middlewares.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Yaser Moradi <ysmoradi@outlook.com>
Signed-off-by: Yaser Moradi <ysmoradi@outlook.com>
Signed-off-by: Yaser Moradi <ysmoradi@outlook.com>
Signed-off-by: Yaser Moradi <ysmoradi@outlook.com>
closes ##10916
Summary by CodeRabbit
New Features
Improvements
Configuration