-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
OrchardCore.Cors #2682
OrchardCore.Cors #2682
Conversation
Merge of orchardCore
/cc @petedavis @jrestall @PinpointTownes @rserj Feel free to criticize as much as you want, I didn't write it 😄 |
src/OrchardCore.Modules/OrchardCore.Cors/Views/CorsSettings.Edit.cshtml
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Cors/Views/CorsSettings.Edit.cshtml
Outdated
Show resolved
Hide resolved
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.
Thanks for making the changes, module looks great and will be very useful!
I'm going to test this branch ; I want to see how the UI/data is working 😉 |
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.
The UI should be changed in favor of using a sortable to reorder each policy. Each sortable element should be containing the form elements to edit each policy. The "Add policy button" would need to be set underneath that sortable list just like we did with the Predefined List Vue.js component for Text fields. We also could add a radio button to be able to select the default policy to make it more evident than just using the first policy in that list by default (optional). Also, each sortable elements could be collapsible so that we can just see a list of policies by name and if we need to edit it we could expand it to see the actual form details. Also optionally, we could have a "edit data" icon set on top of that list to be able to actually just manually edit/copy/paste the json data and also to be able to change the default policy by typing it's name.
src/OrchardCore.Modules/OrchardCore.Cors/Drivers/CorsSettingsDisplayDriver.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Cors/Services/CorsOptionsConfiguration.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Cors/Drivers/CorsSettingsDisplayDriver.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Cors/Drivers/CorsSettingsDisplayDriver.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Cors/Services/CorsOptionsConfiguration.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Cors/Services/CorsOptionsConfiguration.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Cors/Settings/CorsSettings.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Cors/Drivers/CorsSettingsDisplayDriver.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Cors/Views/CorsSettings.Edit.cshtml
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Cors/Views/CorsSettings.Edit.cshtml
Outdated
Show resolved
Hide resolved
For infos about the distributed cache, based on what i'm working on in the distributed branch.
So here, for the settings driver, if possible maybe better to use the last pattern. |
So remove the IMemoryCache and rework when the warning message displays. |
My suggestion is to do, if possible, as in some other drivers e.g Which uses the following warning in the edit view.
And force the reloading when updating by doing something like this.
Same suggestion for the |
# Conflicts: # OrchardCore.sln
Sorry for the lack of updates, been really swamped the last couple of months. Going to pick this up as soon as I get some time. |
# Conflicts: # OrchardCore.sln
65e698a
to
2fdfec6
Compare
Can you please resolve the conflicts ? |
@agriffard will do, have to upgrade the UI as well. |
# Conflicts: # OrchardCore.sln # src/OrchardCore/OrchardCore.Application.Cms.Targets/OrchardCore.Application.Cms.Targets.csproj
@agriffard done ;) |
Yeah... it threw me cause I felt like the first save should have been enough and then I moved onto another screen which of course meant my policy was not there when I went back. |
@MatthijsKrempel - I think you should add policies the same way you add steps to deployment plans. Once you add and save a step you don't have to click save on the deployment plan separately to have the step saved to the plan. Just a thought. |
Hello all, any updates on this PR? |
Please merge dev and put the title into the Title zone. |
@MatthijsKrempel Can you please merge dev and finalize the PR? |
src/OrchardCore.Modules/OrchardCore.Cors/Views/Admin/Index.cshtml
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Cors/Views/Admin/Index.cshtml
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Cors/Views/Admin/Index.cshtml
Outdated
Show resolved
Hide resolved
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.
LGTM
src/OrchardCore.Modules/OrchardCore.Cors/OrchardCore.Cors.csproj
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Cors/Settings/CorsPolicySetting.cs
Outdated
Show resolved
Hide resolved
@agriffard I did a review, LGTM But maybe need a review by others for the UI part as many changes were done around UI design |
If it works. UI can wait. If I remember, there's a lot in this PR about UI that could be done. |
src/OrchardCore.Modules/OrchardCore.Cors/Services/CorsOptionsConfiguration.cs
Show resolved
Hide resolved
I'm open to suggestions 👍
________________________________
From: Sébastien Ros <[email protected]>
Sent: Tuesday, December 29, 2020 9:26:46 PM
To: OrchardCMS/OrchardCore <[email protected]>
Cc: Matthijs Krempel <[email protected]>; Mention <[email protected]>
Subject: Re: [OrchardCMS/OrchardCore] OrchardCore.Cors (#2682)
@sebastienros commented on this pull request.
________________________________
In src/OrchardCore.Modules/OrchardCore.Cors/Services/CorsOptionsConfiguration.cs<#2682 (comment)>:
+ {
+ _corsService = corsService;
+ _logger = logger;
+ }
+
+ public void Configure(CorsOptions options)
+ {
+ var corsSettings = _corsService.GetSettingsAsync().GetAwaiter().GetResult();
+ if (corsSettings?.Policies == null || !corsSettings.Policies.Any())
+ return;
+
+ foreach (var corsPolicy in corsSettings.Policies)
+ {
+ if (corsPolicy.AllowCredentials && corsPolicy.AllowAnyOrigin)
+ {
+ _logger.LogWarning($"AllowCredentials and AllowAnyOrigin is considered a security risk, policy {corsPolicy.Name} not loaded");
Bad logging usage
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#2682 (review)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAMGIKVWRQTDAQ7VUSYKA4LSXI3QNANCNFSM4GD2AE7A>.
|
<script asp-src="https://vuejs.org/js/vue.min.js" debug-src="https://vuejs.org/js/vue.js" asp-name="vuejs" at="Foot" depends-on="jQuery"></script> | ||
<script depends-on="vuejs" asp-src="~/OrchardCore.Cors/Scripts/cors-admin.min.js" debug-src="~/OrchardCore.Cors/Scripts/cors-admin.js" type="text/javascript" asp-name="cors-admin" at="Foot"></script> | ||
<script depends-on="cors-admin" at="Foot"> | ||
corsApp.policies = @Html.Raw(Json.Serialize(Model.Policies, settings)); |
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.
Ue data- attribute to pass the value
I can do that, no problem. 👍
Will have a look at all this feedback tomorrow.
________________________________
From: Jean-Thierry Kéchichian <[email protected]>
Sent: Tuesday, December 29, 2020 11:49:10 PM
To: OrchardCMS/OrchardCore <[email protected]>
Cc: Matthijs Krempel <[email protected]>; Mention <[email protected]>
Subject: Re: [OrchardCMS/OrchardCore] OrchardCore.Cors (#2682)
@jtkech commented on this pull request.
________________________________
In src/OrchardCore.Modules/OrchardCore.Cors/Services/CorsOptionsConfiguration.cs<#2682 (comment)>:
+ {
+ _corsService = corsService;
+ _logger = logger;
+ }
+
+ public void Configure(CorsOptions options)
+ {
+ var corsSettings = _corsService.GetSettingsAsync().GetAwaiter().GetResult();
+ if (corsSettings?.Policies == null || !corsSettings.Policies.Any())
+ return;
+
+ foreach (var corsPolicy in corsSettings.Policies)
+ {
+ if (corsPolicy.AllowCredentials && corsPolicy.AllowAnyOrigin)
+ {
+ _logger.LogWarning($"AllowCredentials and AllowAnyOrigin is considered a security risk, policy {corsPolicy.Name} not loaded");
@MatthijsKrempel<https://github.com/MatthijsKrempel>
@sebastienros<https://github.com/sebastienros> means that in place of using string interpolation, the logger allows to pass parameter and parse them efficiently when it is called.
_logger.LogWarning("AllowCredentials ... policy {PolicyName} not loaded", corsPolicy.Name);
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#2682 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAMGIKUYC7K73BFU5RC4ZFLSXJMGNANCNFSM4GD2AE7A>.
|
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Navigation.Core\OrchardCore.Navigation.Core.csproj" /> | ||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Admin.Abstractions\OrchardCore.Admin.Abstractions.csproj" /> | ||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.DisplayManagement\OrchardCore.DisplayManagement.csproj" /> | ||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Users.Core\OrchardCore.Users.Core.csproj" /> |
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.
Missing reference to OrchardCore.ResourceManagement
busted in production as it won't find the Taghelpers. Easy to fix @scleaver
@@ -352,6 +353,7 @@ EndProject | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Contents.TagHelpers", "src\OrchardCore\OrchardCore.Contents.TagHelpers\OrchardCore.Contents.TagHelpers.csproj", "{6236734E-507B-461B-8E92-068886058E84}" | |||
EndProject | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Search.Abstractions", "src\OrchardCore\OrchardCore.Search.Abstractions\OrchardCore.Search.Abstractions.csproj", "{5283A8BC-DFF4-436D-AA9C-EE2DBFC5D51A}" | |||
>>>>>>> dev |
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.
Nah no one notice this ;)
@MatthijsKrempel Do you remember why a UI for this module was created? I find it kind of odd that we have a CORS UI when the policies created there still need to be consumed in code. If you're already writing code to apply a policy, it seems like defining it in code would make more sense. Maybe a recipe to set up policies would be helpful, but I'm curious—does anyone actually use the UI? Do we even need it? Thank you |
Cors module
Fixes #2680
Feedback is welcome