From f1ecc1ce3ca85cbae51ee04818b87df083df79e9 Mon Sep 17 00:00:00 2001 From: Kenny Gutierrez Date: Sun, 26 Feb 2023 14:44:25 -0600 Subject: [PATCH 1/4] Add Claims and Roles Screen --- .../Views/ClaimsRoles/ClaimsRoles.cshtml | 23 +++++++++++++++++++ .../ClaimsRoles/ClaimsRolesController.cs | 20 ++++++++++++++++ .../Features/ClaimsRoles/ClaimsRolesModel.cs | 11 +++++++++ EPiServer.DeveloperTools/MenuProvider.cs | 3 ++- 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/ClaimsRoles.cshtml create mode 100644 EPiServer.DeveloperTools/Features/ClaimsRoles/ClaimsRolesController.cs create mode 100644 EPiServer.DeveloperTools/Features/ClaimsRoles/ClaimsRolesModel.cs diff --git a/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/ClaimsRoles.cshtml b/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/ClaimsRoles.cshtml new file mode 100644 index 0000000..80cba92 --- /dev/null +++ b/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/ClaimsRoles.cshtml @@ -0,0 +1,23 @@ +@using System.Collections +@model EPiServer.DeveloperTools.Features.ClaimsRoles.ClaimsRolesModel + +
+

Roles/Claims

+

+ Dumps all roles for the current user +

+
+
+ +

Roles

+

+            @foreach (var claim in Model.Roles)
+            {
+        
+        
+        
+            
+            }
+    
@claim.Type@claim.Value
+ +
\ No newline at end of file diff --git a/EPiServer.DeveloperTools/Features/ClaimsRoles/ClaimsRolesController.cs b/EPiServer.DeveloperTools/Features/ClaimsRoles/ClaimsRolesController.cs new file mode 100644 index 0000000..3defb55 --- /dev/null +++ b/EPiServer.DeveloperTools/Features/ClaimsRoles/ClaimsRolesController.cs @@ -0,0 +1,20 @@ +using EPiServer.DeveloperTools.Features.Common; +using Microsoft.AspNetCore.Mvc; +using System.Linq; + + +namespace EPiServer.DeveloperTools.Features.ClaimsRoles +{ + public class ClaimsRolesController : DeveloperToolsController + { + public IActionResult Index() + { + var user = base.User; + var claims = user.Identities.First().Claims.ToList(); + + var model = new ClaimsRolesModel { Roles = claims }; + + return View(model); + } + } +} diff --git a/EPiServer.DeveloperTools/Features/ClaimsRoles/ClaimsRolesModel.cs b/EPiServer.DeveloperTools/Features/ClaimsRoles/ClaimsRolesModel.cs new file mode 100644 index 0000000..eec3f8e --- /dev/null +++ b/EPiServer.DeveloperTools/Features/ClaimsRoles/ClaimsRolesModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using System.Security.Claims; + +namespace EPiServer.DeveloperTools.Features.ClaimsRoles +{ + public class ClaimsRolesModel + { + public List Roles { get; set; } + + } +} diff --git a/EPiServer.DeveloperTools/MenuProvider.cs b/EPiServer.DeveloperTools/MenuProvider.cs index 26de714..593620b 100644 --- a/EPiServer.DeveloperTools/MenuProvider.cs +++ b/EPiServer.DeveloperTools/MenuProvider.cs @@ -34,7 +34,8 @@ public IEnumerable GetMenuItems() CreateUrlMenuItem("Routes", "Routes", 110), CreateUrlMenuItem("View Locations", "ViewLocations", 120), CreateUrlMenuItem("Module Dependencies", "ModuleDependencies", 130), - CreateUrlMenuItem("Local Object Cache", "LocalObjectCache", 140) + CreateUrlMenuItem("Local Object Cache", "LocalObjectCache", 140), + CreateUrlMenuItem("Claims And Roles", "ClaimsRoles", 150) }; } From 9bad2474756e70df9968cfa0f1c1c28b1110c36c Mon Sep 17 00:00:00 2001 From: Kenny Gutierrez Date: Sun, 26 Feb 2023 14:50:25 -0600 Subject: [PATCH 2/4] Rename view --- .../Views/ClaimsRoles/{ClaimsRoles.cshtml => Index.cshtml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/{ClaimsRoles.cshtml => Index.cshtml} (100%) diff --git a/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/ClaimsRoles.cshtml b/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/Index.cshtml similarity index 100% rename from EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/ClaimsRoles.cshtml rename to EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/Index.cshtml From 234241013ae031ee9f842063a881e7686cdfeece Mon Sep 17 00:00:00 2001 From: Kenny Gutierrez Date: Sun, 26 Feb 2023 21:22:54 -0600 Subject: [PATCH 3/4] appsettings.json viewer --- .../Views/AppSettings/Index.cshtml | 26 ++++++++++++++ .../Views/ClaimsRoles/Index.cshtml | 4 +-- .../AppSettings/AppSettingsController.cs | 36 +++++++++++++++++++ EPiServer.DeveloperTools/MenuProvider.cs | 3 +- 4 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/AppSettings/Index.cshtml create mode 100644 EPiServer.DeveloperTools/Features/AppSettings/AppSettingsController.cs diff --git a/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/AppSettings/Index.cshtml b/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/AppSettings/Index.cshtml new file mode 100644 index 0000000..6fde685 --- /dev/null +++ b/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/AppSettings/Index.cshtml @@ -0,0 +1,26 @@ +@using System.Collections +@model List + +
+

AppSettings

+

+ Displays the transformed active AppSettings.json file +

+
+
+ +

AppSettings.json

+ @if (Model != null && Model.Any()) + { + if (Model.Any() && Model != null) + { +
+                    @foreach (var line in Model)
+                    {
+                        @($"{line}\n") 
+                    }
+                
+ } + } + +
\ No newline at end of file diff --git a/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/Index.cshtml b/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/Index.cshtml index 80cba92..a3cfde1 100644 --- a/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/Index.cshtml +++ b/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/Index.cshtml @@ -2,9 +2,9 @@ @model EPiServer.DeveloperTools.Features.ClaimsRoles.ClaimsRolesModel
-

Roles/Claims

+

Claims/Roles

- Dumps all roles for the current user + Displays all claims/roles for the current user

diff --git a/EPiServer.DeveloperTools/Features/AppSettings/AppSettingsController.cs b/EPiServer.DeveloperTools/Features/AppSettings/AppSettingsController.cs new file mode 100644 index 0000000..ade0ab1 --- /dev/null +++ b/EPiServer.DeveloperTools/Features/AppSettings/AppSettingsController.cs @@ -0,0 +1,36 @@ +using EPiServer.DeveloperTools.Features.Common; +using EPiServer.Licensing.Services; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using System.IO; +using System.Linq; + + +namespace EPiServer.DeveloperTools.Features.AppSettings +{ + public class AppSettingsController : DeveloperToolsController + { + private readonly IWebHostEnvironment _webHostEnvironment; + + public AppSettingsController(IWebHostEnvironment webHostEnvironment) + { + _webHostEnvironment = webHostEnvironment; + } + public IActionResult Index() + { + string webRootPath = _webHostEnvironment.ContentRootPath; + string file = "appsettings.json"; + string[] str = null; + + string path = ""; + path = Path.Combine(webRootPath, file); + + if (System.IO.File.Exists(path)) + { + str = System.IO.File.ReadAllLines(path); + } + + return View(str.ToList()); + } + } +} diff --git a/EPiServer.DeveloperTools/MenuProvider.cs b/EPiServer.DeveloperTools/MenuProvider.cs index 593620b..7362e66 100644 --- a/EPiServer.DeveloperTools/MenuProvider.cs +++ b/EPiServer.DeveloperTools/MenuProvider.cs @@ -35,7 +35,8 @@ public IEnumerable GetMenuItems() CreateUrlMenuItem("View Locations", "ViewLocations", 120), CreateUrlMenuItem("Module Dependencies", "ModuleDependencies", 130), CreateUrlMenuItem("Local Object Cache", "LocalObjectCache", 140), - CreateUrlMenuItem("Claims And Roles", "ClaimsRoles", 150) + CreateUrlMenuItem("Claims And Roles", "ClaimsRoles", 150), + CreateUrlMenuItem("AppSettings", "AppSettings", 160) }; } From 18bbde618be6b25c3db5e527649ad6a0e519f556 Mon Sep 17 00:00:00 2001 From: Kenny Gutierrez Date: Fri, 17 Mar 2023 18:15:48 -0500 Subject: [PATCH 4/4] no longer reading appsettings.json from file since transform takes place in memory --- .../Views/AppSettings/Index.cshtml | 23 +++++++---------- .../Views/ClaimsRoles/Index.cshtml | 22 ++++++++++------ .../AppSettings/AppSettingsController.cs | 25 ++++++------------- .../Features/AppSettings/AppSettingsModel.cs | 7 ++++++ 4 files changed, 38 insertions(+), 39 deletions(-) create mode 100644 EPiServer.DeveloperTools/Features/AppSettings/AppSettingsModel.cs diff --git a/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/AppSettings/Index.cshtml b/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/AppSettings/Index.cshtml index 6fde685..abec0ef 100644 --- a/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/AppSettings/Index.cshtml +++ b/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/AppSettings/Index.cshtml @@ -1,26 +1,21 @@ -@using System.Collections -@model List +@using System.IO +@model EPiServer.DeveloperTools.Features.AppSettings.AppSettingsModel
-

AppSettings

+

Final AppSettings Values

- Displays the transformed active AppSettings.json file + Displays the transformed appSettings values after the appSettings.{environment}.config has been applied

AppSettings.json

- @if (Model != null && Model.Any()) + + @if (!string.IsNullOrEmpty(Model.FinalValues)) { - if (Model.Any() && Model != null) - { -
-                    @foreach (var line in Model)
-                    {
-                        @($"{line}\n") 
-                    }
-                
- } +
+            @Html.Raw(Model.FinalValues)
+        
}
\ No newline at end of file diff --git a/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/Index.cshtml b/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/Index.cshtml index a3cfde1..824fe35 100644 --- a/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/Index.cshtml +++ b/EPiServer.DeveloperTools/EPiServer.DeveloperTools.Views/Views/ClaimsRoles/Index.cshtml @@ -10,14 +10,22 @@

Roles

-

-            @foreach (var claim in Model.Roles)
-            {
+    
+ - - + + + + + + @foreach (var claim in Model.Roles) + { + + + - } -
@claim.Type@claim.ValueClaimValue
@claim.Type@claim.Value
+ } + +
\ No newline at end of file diff --git a/EPiServer.DeveloperTools/Features/AppSettings/AppSettingsController.cs b/EPiServer.DeveloperTools/Features/AppSettings/AppSettingsController.cs index ade0ab1..ca13a9e 100644 --- a/EPiServer.DeveloperTools/Features/AppSettings/AppSettingsController.cs +++ b/EPiServer.DeveloperTools/Features/AppSettings/AppSettingsController.cs @@ -1,36 +1,25 @@ using EPiServer.DeveloperTools.Features.Common; -using EPiServer.Licensing.Services; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; -using System.IO; -using System.Linq; +using Microsoft.Extensions.Configuration; namespace EPiServer.DeveloperTools.Features.AppSettings { public class AppSettingsController : DeveloperToolsController { - private readonly IWebHostEnvironment _webHostEnvironment; + private readonly IConfiguration _configuration; - public AppSettingsController(IWebHostEnvironment webHostEnvironment) + public AppSettingsController(IConfiguration configuration) { - _webHostEnvironment = webHostEnvironment; + _configuration = configuration; } public IActionResult Index() { - string webRootPath = _webHostEnvironment.ContentRootPath; - string file = "appsettings.json"; - string[] str = null; - string path = ""; - path = Path.Combine(webRootPath, file); + var root = (IConfigurationRoot)_configuration; + var model = new AppSettingsModel { FinalValues = root.GetDebugView() }; - if (System.IO.File.Exists(path)) - { - str = System.IO.File.ReadAllLines(path); - } - - return View(str.ToList()); + return View(model); } } } diff --git a/EPiServer.DeveloperTools/Features/AppSettings/AppSettingsModel.cs b/EPiServer.DeveloperTools/Features/AppSettings/AppSettingsModel.cs new file mode 100644 index 0000000..8bb6ffb --- /dev/null +++ b/EPiServer.DeveloperTools/Features/AppSettings/AppSettingsModel.cs @@ -0,0 +1,7 @@ +namespace EPiServer.DeveloperTools.Features.AppSettings +{ + public class AppSettingsModel + { + public string FinalValues { get; set; } + } +}