Skip to content

Commit cb7942a

Browse files
authored
Add no-https option for all templates (#413)
Addresses #322
1 parent aca30fe commit cb7942a

File tree

53 files changed

+266
-41
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+266
-41
lines changed

src/Microsoft.DotNet.Web.ProjectTemplates/StarterWeb-CSharp.csproj.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
<WebProject_DirectoryAccessLevelKey Condition="'$(OrganizationalAuth)' == 'True' AND '$(OrgReadAccess)' != 'True'">0</WebProject_DirectoryAccessLevelKey>
99
<WebProject_DirectoryAccessLevelKey Condition="'$(OrganizationalAuth)' == 'True' AND '$(OrgReadAccess)' == 'True'">1</WebProject_DirectoryAccessLevelKey>
1010
</PropertyGroup>
11-
<!--#if (IndividualLocalAuth && UseLocalDB) -->
11+
<!--#if (IndividualLocalAuth && UseLocalDB) -->
1212

13-
<!--#endif -->
13+
<!--#endif -->
1414
<ItemGroup Condition=" '$(IndividualLocalAuth)' == 'True' AND '$(UseLocalDB)' != 'True' ">
1515
<None Update="app.db" CopyToOutputDirectory="PreserveNewest" />
1616
</ItemGroup>
@@ -30,7 +30,7 @@
3030
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="${MicrosoftAspNetCoreAuthenticationCookiesPackageVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" />
3131
<PackageReference Include="Microsoft.AspNetCore.CookiePolicy" Version="${MicrosoftAspNetCoreCookiePolicyPackageVersion}" />
3232
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="${MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" />
33-
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" />
33+
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" Condition="'$(RequiresHttps)' == 'True'"/>
3434
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="${MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" />
3535
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="${MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" />
3636
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" />

src/Microsoft.DotNet.Web.ProjectTemplates/StarterWeb-FSharp.fsproj.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" />
2323
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="${MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion}" PrivateAssets="All" />
2424
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="${MicrosoftAspNetCoreStaticFilesPackageVersion}" />
25-
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" />
25+
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" Condition="'$(NoHttps)' != 'True'"/>
2626
</ItemGroup>
2727

2828
</Project>

src/Microsoft.DotNet.Web.ProjectTemplates/WebApi-CSharp.csproj.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" />
2222
<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="${MicrosoftAspNetCoreAuthenticationAzureADUIPackageVersion}" Condition="'$(OrganizationalAuth)' == 'True'" />
2323
<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureADB2C.UI" Version="${MicrosoftAspNetCoreAuthenticationAzureADB2CUIPackageVersion}" Condition="'$(IndividualB2CAuth)' == 'True'" />
24-
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" />
24+
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" Condition="'$(RequiresHttps)' == 'True'" />
2525
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" />
2626
</ItemGroup>
2727

src/Microsoft.DotNet.Web.ProjectTemplates/WebApi-FSharp.fsproj.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<ItemGroup Condition="'$(TargetFrameworkOverride)' != ''">
1818
<PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" />
1919
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" />
20-
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" />
20+
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" Condition="'$(NoHttps)' != 'True'" />
2121
</ItemGroup>
2222

2323
</Project>

src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/dotnetcli.host.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
"ExcludeLaunchSettings": {
2323
"longName": "exclude-launch-settings",
2424
"shortName": ""
25+
},
26+
"NoHttps": {
27+
"longName": "no-https",
28+
"shortName": ""
2529
}
2630
},
2731
"usageExamples": [

src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/template.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"HttpsPort": {
6969
"type": "parameter",
7070
"datatype": "integer",
71-
"description": "Port number to use for the HTTPS endpoint in launchSettings.json."
71+
"description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used)."
7272
},
7373
"HttpsPortGenerated": {
7474
"type": "generated",
@@ -120,6 +120,12 @@
120120
"datatype": "bool",
121121
"description": "If specified, skips the automatic restore of the project on create.",
122122
"defaultValue": "false"
123+
},
124+
"NoHttps": {
125+
"type": "parameter",
126+
"datatype": "bool",
127+
"defaultValue": "false",
128+
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
123129
}
124130
},
125131
"primaryOutputs": [

src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/vs-2017.3.host.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@
2727
}
2828
],
2929
"excludeLaunchSettings": false,
30-
"minFullFrameworkVersion": "4.6.1"
30+
"minFullFrameworkVersion": "4.6.1",
31+
"disableHttpsSymbol": "NoHttps"
3132
}

src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/Properties/launchSettings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
"Company.WebApplication1": {
1919
"commandName": "Project",
2020
"launchBrowser": true,
21+
//#if(NoHttps)
22+
"applicationUrl": "http://localhost:5000",
23+
//#else
2124
"applicationUrl": "https://localhost:5001;http://localhost:5000",
25+
//#endif
2226
"environmentVariables": {
2327
"ASPNETCORE_ENVIRONMENT": "Development"
2428
}

src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/.template.config/dotnetcli.host.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
"ExcludeLaunchSettings": {
2323
"longName": "exclude-launch-settings",
2424
"shortName": ""
25+
},
26+
"NoHttps": {
27+
"longName": "no-https",
28+
"shortName": ""
2529
}
2630
},
2731
"usageExamples": [

src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/.template.config/template.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"HttpsPort": {
6565
"type": "parameter",
6666
"datatype": "integer",
67-
"description": "Port number to use for the HTTPS endpoint in launchSettings.json."
67+
"description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used)."
6868
},
6969
"HttpsPortGenerated": {
7070
"type": "generated",
@@ -116,6 +116,12 @@
116116
"datatype": "bool",
117117
"description": "If specified, skips the automatic restore of the project on create.",
118118
"defaultValue": "false"
119+
},
120+
"NoHttps": {
121+
"type": "parameter",
122+
"datatype": "bool",
123+
"defaultValue": "false",
124+
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
119125
}
120126
},
121127
"primaryOutputs": [

src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/.template.config/vs-2017.3.host.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@
2525
"useHttps": true
2626
}
2727
],
28-
"minFullFrameworkVersion": "4.6.1"
28+
"minFullFrameworkVersion": "4.6.1",
29+
"disableHttpsSymbol": "NoHttps"
2930
}

src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/Properties/launchSettings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
"Company.WebApplication1": {
1919
"commandName": "Project",
2020
"launchBrowser": true,
21+
//#if(NoHttps)
22+
"applicationUrl": "http://localhost:5000",
23+
//#else
2124
"applicationUrl": "https://localhost:5001;http://localhost:5000",
25+
//#endif
2226
"environmentVariables": {
2327
"ASPNETCORE_ENVIRONMENT": "Development"
2428
}

src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/.template.config/template.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,12 @@
307307
"defaultValue": "false",
308308
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
309309
},
310+
"NoHttps": {
311+
"type": "parameter",
312+
"datatype": "bool",
313+
"defaultValue": "false",
314+
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
315+
},
310316
"UseLocalDB": {
311317
"type": "parameter",
312318
"datatype": "bool",

src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/dotnetcli.host.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
"UseBrowserLink": {
7373
"longName": "use-browserlink",
7474
"shortName": ""
75+
},
76+
"NoHttps": {
77+
"longName": "no-https",
78+
"shortName": ""
7579
}
7680
},
7781
"usageExamples": [

src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/template.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@
239239
"HttpsPort": {
240240
"type": "parameter",
241241
"datatype": "integer",
242-
"description": "Port number to use for the HTTPS endpoint in launchSettings.json."
242+
"description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used)."
243243
},
244244
"HttpsPortGenerated": {
245245
"type": "generated",
@@ -292,7 +292,13 @@
292292
},
293293
"RequiresHttps": {
294294
"type": "computed",
295-
"value": "(OrganizationalAuth || IndividualAuth)"
295+
"value": "(OrganizationalAuth || IndividualAuth || !NoHttps)"
296+
},
297+
"NoHttps": {
298+
"type": "parameter",
299+
"datatype": "bool",
300+
"defaultValue": "false",
301+
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
296302
},
297303
"UseLocalDB": {
298304
"type": "parameter",

src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/vs-2017.3.host.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"supportedAuthentications": [
2323
{
2424
"auth": "None",
25-
"authenticationType": "NoAuth"
25+
"authenticationType": "NoAuth",
26+
"allowUnsecured": true
2627
},
2728
{
2829
"auth": "Individual",
@@ -61,5 +62,6 @@
6162
],
6263
"excludeLaunchSettings": false,
6364
"azureReplyUrlPortName": "HttpsPort",
64-
"minFullFrameworkVersion": "4.6.1"
65+
"minFullFrameworkVersion": "4.6.1",
66+
"disableHttpsSymbol": "NoHttps"
6567
}

src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Properties/launchSettings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
"Company.WebApplication1": {
1919
"commandName": "Project",
2020
"launchBrowser": true,
21+
//#if(RequiresHttps)
2122
"applicationUrl": "https://localhost:5001;http://localhost:5000",
23+
//#else
24+
"applicationUrl": "http://localhost:5000",
25+
//#endif
2226
"environmentVariables": {
2327
"ASPNETCORE_ENVIRONMENT": "Development"
2428
}

src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Startup.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
#endif
2222
using Microsoft.AspNetCore.Hosting;
2323
using Microsoft.AspNetCore.Http;
24+
#if (RequiresHttps)
2425
using Microsoft.AspNetCore.HttpsPolicy;
26+
#endif
2527
using Microsoft.AspNetCore.Mvc;
2628
#if (OrganizationalAuth)
2729
using Microsoft.AspNetCore.Mvc.Authorization;
@@ -143,10 +145,15 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
143145
else
144146
{
145147
app.UseExceptionHandler("/Home/Error");
148+
#if (RequiresHttps)
146149
app.UseHsts();
147150
}
148151

149152
app.UseHttpsRedirection();
153+
#else
154+
}
155+
156+
#endif
150157
app.UseStaticFiles();
151158
app.UseCookiePolicy();
152159

src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/.template.config/dotnetcli.host.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
"skipRestore": {
2323
"longName": "no-restore",
2424
"shortName": ""
25+
},
26+
"NoHttps": {
27+
"longName": "no-https",
28+
"shortName": ""
2529
}
2630
},
2731
"usageExamples": [

src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/.template.config/template.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"HttpsPort": {
7575
"type": "parameter",
7676
"datatype": "integer",
77-
"description": "Port number to use for the HTTPS endpoint in launchSettings.json."
77+
"description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used)."
7878
},
7979
"HttpsPortGenerated": {
8080
"type": "generated",
@@ -126,6 +126,12 @@
126126
"datatype": "bool",
127127
"description": "If specified, skips the automatic restore of the project on create.",
128128
"defaultValue": "false"
129+
},
130+
"NoHttps": {
131+
"type": "parameter",
132+
"datatype": "bool",
133+
"defaultValue": "false",
134+
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
129135
}
130136
},
131137
"primaryOutputs": [

src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Properties/launchSettings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
"Company.WebApplication1": {
1919
"commandName": "Project",
2020
"launchBrowser": true,
21+
//#if(NoHttps)
22+
"applicationUrl": "http://localhost:5000",
23+
//#else
2124
"applicationUrl": "https://localhost:5001;http://localhost:5000",
25+
//#endif
2226
"environmentVariables": {
2327
"ASPNETCORE_ENVIRONMENT": "Development"
2428
}

src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ open System.Linq
66
open System.Threading.Tasks
77
open Microsoft.AspNetCore.Builder
88
open Microsoft.AspNetCore.Hosting
9-
open Microsoft.AspNetCore.HttpsPolicy
9+
#if (!NoHttps)
10+
open Microsoft.AspNetCore.HttpsPolicy;
11+
#endif
1012
open Microsoft.AspNetCore.Mvc
1113
open Microsoft.Extensions.Configuration
1214
open Microsoft.Extensions.DependencyInjection
@@ -28,9 +30,13 @@ type Startup private () =
2830
app.UseDeveloperExceptionPage() |> ignore
2931
else
3032
app.UseExceptionHandler("/Home/Error") |> ignore
33+
#if (!NoHttps)
3134
app.UseHsts() |> ignore
3235

3336
app.UseHttpsRedirection() |> ignore
37+
#else
38+
39+
#endif
3440
app.UseStaticFiles() |> ignore
3541

3642
app.UseMvc(fun routes ->

src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/.template.config/dotnetcli.host.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
},
5757
"UserSecretsId": {
5858
"isHidden": true
59+
},
60+
"NoHttps": {
61+
"longName": "no-https",
62+
"shortName": ""
5963
}
6064
},
6165
"usageExamples": [

src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/.template.config/template.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
"HttpsPort": {
152152
"type": "parameter",
153153
"datatype": "integer",
154-
"description": "Port number to use for the HTTPS endpoint in launchSettings.json."
154+
"description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used)."
155155
},
156156
"HttpsPortGenerated": {
157157
"type": "generated",
@@ -196,7 +196,13 @@
196196
},
197197
"RequiresHttps": {
198198
"type": "computed",
199-
"value": "(OrganizationalAuth || IndividualAuth)"
199+
"value": "(OrganizationalAuth || IndividualAuth || !NoHttps)"
200+
},
201+
"NoHttps": {
202+
"type": "parameter",
203+
"datatype": "bool",
204+
"defaultValue": "false",
205+
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
200206
},
201207
"UseLocalDB": {
202208
"type": "parameter",

src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/.template.config/vs-2017.3.host.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"supportedAuthentications": [
2222
{
2323
"auth": "None",
24-
"authenticationType": "NoAuth"
24+
"authenticationType": "NoAuth",
25+
"allowUnsecured": true
2526
},
2627
{
2728
"auth": "Individual",
@@ -50,5 +51,6 @@
5051
],
5152
"excludeLaunchSettings": false,
5253
"azureReplyUrlPortName": "HttpsPort",
53-
"minFullFrameworkVersion": "4.6.1"
54+
"minFullFrameworkVersion": "4.6.1",
55+
"disableHttpsSymbol": "NoHttps"
5456
}

src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Properties/launchSettings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
"Company.WebApplication1": {
1919
"commandName": "Project",
2020
"launchBrowser": true,
21+
//#if(RequiresHttps)
2122
"applicationUrl": "https://localhost:5001;http://localhost:5000",
23+
//#else
24+
"applicationUrl": "http://localhost:5000",
25+
//#endif
2226
"environmentVariables": {
2327
"ASPNETCORE_ENVIRONMENT": "Development"
2428
}

0 commit comments

Comments
 (0)