Parcourir la source

[Blazor] Add instructions to configure the authority when it is missing

* For individual auth cases, when creating the template from Visual Studio there is no way to provide parameters.
* This change adds a message in the index.html to indicate the steps that need to be followed.
Javier Calvarro Nelson il y a 6 ans
Parent
commit
a52e708e55

+ 4 - 0
src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/.template.config/template.json

@@ -267,6 +267,10 @@
       "replaces": "https://login.microsoftonline.com/",
       "description": "The authority of the OIDC provider (use with standalone Individual auth)."
     },
+    "MissingAuthority": {
+      "type": "computed",
+      "value": "(IndividualAuth && !Hosted && Authority == \"https://login.microsoftonline.com/\" && ClientId == \"33333333-3333-3333-33333333333333333\")"
+    },
     "AAdB2CInstance": {
       "type": "parameter",
       "datatype": "string",

+ 6 - 0
src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/Pages/Index.razor

@@ -2,6 +2,12 @@
 
 <h1>Hello, world!</h1>
 
+@*#if (MissingAuthority)
+<div class="alert alert-warning" role="alert">
+    Before authentication will function correctly, you must configure your provider details in <code>Program.cs</code>
+</div>
+
+#endif*@
 Welcome to your new app.
 
 <SurveyPrompt Title="How is Blazor working for you?" />

+ 4 - 0
src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/Program.cs

@@ -25,6 +25,10 @@ namespace ComponentsWebAssembly_CSharp
     #else
             builder.Services.AddOidcAuthentication(options =>
             {
+                #if(MissingAuthority)
+                // Configure your authentication provider options here.
+                // For more information, see https://aka.ms/blazor-standalone-auth
+                #endif
                 options.ProviderOptions.Authority = "https://login.microsoftonline.com/";
                 options.ProviderOptions.ClientId = "33333333-3333-3333-33333333333333333";
             });

+ 0 - 1
src/ProjectTemplates/ComponentsWebAssembly.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Program.cs

@@ -22,6 +22,5 @@ namespace ComponentsWebAssembly_CSharp.Server
                 {
                     webBuilder.UseStartup<Startup>();
                 });
-
     }
 }