Skip to content

Commit

Permalink
Enable HTTPS in templates
Browse files Browse the repository at this point in the history
Contributes to #2453
  • Loading branch information
DamianEdwards committed Mar 6, 2024
1 parent 2b892f0 commit cdb1f9d
Show file tree
Hide file tree
Showing 16 changed files with 326 additions and 123 deletions.
6 changes: 4 additions & 2 deletions playground/TestShop/AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
.WithReference(basketCache)
.WithReference(messaging);

var isHttps = string.Equals(builder.Configuration["DOTNET_LAUNCH_PROFILE"], "https", StringComparison.OrdinalIgnoreCase);

builder.AddProject<Projects.MyFrontend>("frontend")
.WithReference(basketService)
.WithReference(catalogService.GetEndpoint("http"));
.WithReference(catalogService.GetEndpoint(isHttps ? "https" : "http"));

builder.AddProject<Projects.OrderProcessor>("orderprocessor", launchProfileName: "OrderProcessor")
.WithReference(messaging);
Expand All @@ -36,6 +38,6 @@
// to test end developer dashboard launch experience. Refer to Directory.Build.props
// for the path to the dashboard binary (defaults to the Aspire.Dashboard bin output
// in the artifacts dir).
builder.AddProject<Projects.Aspire_Dashboard>(KnownResourceNames.AspireDashboard);
//builder.AddProject<Projects.Aspire_Dashboard>(KnownResourceNames.AspireDashboard);

builder.Build().Run();
21 changes: 16 additions & 5 deletions playground/TestShop/AppHost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,35 @@
"commandName": "Project",
"launchBrowser": true,
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:15887;http://localhost:15888",
"applicationUrl": "http://localhost:15888",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16031",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:17031",
"DOTNET_ASPIRE_SHOW_DASHBOARD_RESOURCES": "true"
}
},
"generate-manifest": {
"https": {
"commandName": "Project",
"launchBrowser": true,
"dotnetRunMessages": true,
"commandLineArgs": "--publisher manifest --output-path aspire-manifest.json",
"applicationUrl": "http://localhost:15888",
"applicationUrl": "https://localhost:15887;http://localhost:15888",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16031"
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:16037",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:17037",
"DOTNET_ASPIRE_SHOW_DASHBOARD_RESOURCES": "true"
}
},
"generate-manifest": {
"commandName": "Project",
"dotnetRunMessages": true,
"commandLineArgs": "--publisher manifest --output-path aspire-manifest.json",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development"
}
}
},
Expand Down
8 changes: 5 additions & 3 deletions playground/TestShop/MyFrontend/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

builder.Services.AddHttpForwarderWithServiceDiscovery();

builder.Services.AddHttpClient<CatalogServiceClient>(c => c.BaseAddress = new("http://catalogservice"));
builder.Services.AddHttpClient<CatalogServiceClient>(c => c.BaseAddress = new("https+http://catalogservice"));

builder.Services.AddSingleton<BasketServiceClient>()
.AddGrpcClient<Basket.BasketClient>(o => o.Address = new("http://basketservice"));
.AddGrpcClient<Basket.BasketClient>(o => o.Address = new("https+http://basketservice"));

builder.Services.AddRazorComponents();

Expand All @@ -22,13 +22,15 @@
app.UseExceptionHandler("/error", createScopeForErrors: true);
}

app.UseHttpsRedirection();

app.UseStaticFiles();

app.UseAntiforgery();

app.MapRazorComponents<App>();

app.MapForwarder("/catalog/images/{id}", "http://catalogservice", "/api/v1/catalog/items/{id}/image");
app.MapForwarder("/catalog/images/{id}", "https+http://catalogservice", "/api/v1/catalog/items/{id}/image");

app.MapDefaultEndpoints();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,27 @@
"longName": "no-restore",
"shortName": ""
},
"appHttpPort": {
"appHostHttpPort": {
"isHidden": true
},
"appHttpsPort": {
"appHostHttpsPort": {
"isHidden": true
},
"NoHttps": {
"appHostOtlpHttpPort": {
"isHidden": true
},
"appHostOtlpHttpsPort": {
"isHidden": true
},
"appHostResourceHttpPort": {
"isHidden": true
},
"appHostResourceHttpsPort": {
"isHidden": true
},
"NoHttps": {
"longName": "no-https",
"shortName": ""
}
},
"usageExamples": [ ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$schema": "https://json.schemastore.org/ide.host",
"icon": "ide/AspireAppHost.ico",
"displayOverviewPage": "0",
"disableHttpsSymbol": "NoHttps",
"unsupportedHosts": [
{
"id": "vs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,93 +47,137 @@
"type": "bind",
"binding": "HostIdentifier"
},
"appHttpPort": {
"appHostHttpPort": {
"type": "parameter",
"datatype": "integer",
"description": "Port number to use for the HTTP endpoint in launchSettings.json of the App project."
"description": "Port number to use for the HTTP endpoint in launchSettings.json of the AppHost project."
},
"appHttpPortGenerated": {
"appHostHttpPortGenerated": {
"type": "generated",
"generator": "port",
"parameters": {
"low": 15000,
"high": 15300
}
},
"appHttpPortReplacer": {
"appHostHttpPortReplacer": {
"type": "generated",
"generator": "coalesce",
"parameters": {
"sourceVariableName": "appHttpPort",
"fallbackVariableName": "appHttpPortGenerated"
"sourceVariableName": "appHostHttpPort",
"fallbackVariableName": "appHostHttpPortGenerated"
},
"replaces": "15000"
},
"appOtlpHttpPort": {
"appHostOtlpHttpPort": {
"type": "parameter",
"datatype": "integer",
"description": "Port number to use for the OTLP HTTP endpoint in launchSettings.json of the App project."
"description": "Port number to use for the OTLP HTTP endpoint in launchSettings.json of the AppHost project."
},
"appOtlpHttpPortGenerated": {
"appHostOtlpHttpPortGenerated": {
"type": "generated",
"generator": "port",
"parameters": {
"low": 16000,
"high": 16300
"low": 19000,
"high": 19300
}
},
"appOtlpHttpPortReplacer": {
"appHostOtlpHttpPortReplacer": {
"type": "generated",
"generator": "coalesce",
"parameters": {
"sourceVariableName": "appOtlpHttpPort",
"fallbackVariableName": "appOtlpHttpPortGenerated"
"sourceVariableName": "appHostOtlpHttpPort",
"fallbackVariableName": "appHostOtlpHttpPortGenerated"
},
"replaces": "16000"
"replaces": "19000"
},
"appHttpsPort": {
"appHostResourceHttpPort": {
"type": "parameter",
"datatype": "integer",
"description": "Port number to use for the HTTPS endpoint in launchSettings.json of the App project. This option is only applicable when the parameter no-https is not used."
"description": "Port number to use for the resource service HTTP endpoint in launchSettings.json of the AppHost project."
},
"appHttpsPortGenerated": {
"appHostResourceHttpPortGenerated": {
"type": "generated",
"generator": "port",
"parameters": {
"low": 20000,
"high": 20300
}
},
"appHostResourceHttpPortReplacer": {
"type": "generated",
"generator": "coalesce",
"parameters": {
"sourceVariableName": "appHostResourceHttpPort",
"fallbackVariableName": "appHostResourceHttpPortGenerated"
},
"replaces": "20000"
},
"appHostHttpsPort": {
"type": "parameter",
"datatype": "integer",
"description": "Port number to use for the HTTPS endpoint in launchSettings.json of the AppHost project. This option is only applicable when the parameter no-https is not used."
},
"appHostHttpsPortGenerated": {
"type": "generated",
"generator": "port",
"parameters": {
"low": 17000,
"high": 17300
}
},
"appHttpsPortReplacer": {
"appHostHttpsPortReplacer": {
"type": "generated",
"generator": "coalesce",
"parameters": {
"sourceVariableName": "appHttpsPort",
"fallbackVariableName": "appHttpsPortGenerated"
"sourceVariableName": "appHostHttpsPort",
"fallbackVariableName": "appHostHttpsPortGenerated"
},
"replaces": "17000"
},
"appOtlpHttpsPort": {
"appHostOtlpHttpsPort": {
"type": "parameter",
"datatype": "integer",
"description": "Port number to use for the OTLP HTTPS endpoint in launchSettings.json of the AppHost project."
},
"appHostOtlpHttpsPortGenerated": {
"type": "generated",
"generator": "port",
"parameters": {
"low": 21000,
"high": 21300
}
},
"appHostOtlpHttpsPortReplacer": {
"type": "generated",
"generator": "coalesce",
"parameters": {
"sourceVariableName": "appHostOtlpHttpsPort",
"fallbackVariableName": "appHostOtlpHttpsPortGenerated"
},
"replaces": "21000"
},
"appHostResourceHttpsPort": {
"type": "parameter",
"datatype": "integer",
"description": "Port number to use for the OTLP HTTPS endpoint in launchSettings.json of the App project."
"description": "Port number to use for the resource service HTTPS endpoint in launchSettings.json of the AppHost project."
},
"appOtlpHttpsPortGenerated": {
"appHostResourceHttpsPortGenerated": {
"type": "generated",
"generator": "port",
"parameters": {
"low": 18000,
"high": 18300
"low": 22000,
"high": 22300
}
},
"appOtlpHttpsPortReplacer": {
"appHostResourceHttpsPortReplacer": {
"type": "generated",
"generator": "coalesce",
"parameters": {
"sourceVariableName": "appOtlpHttpsPort",
"fallbackVariableName": "appOtlpHttpsPortGenerated"
"sourceVariableName": "appHostResourceHttpsPort",
"fallbackVariableName": "appHostResourceHttpsPortGenerated"
},
"replaces": "18000"
"replaces": "22000"
},
"skipRestore": {
"type": "parameter",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16000"
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19000",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20000",
}
//#if (HasHttpsProfile)
},
Expand All @@ -21,7 +22,8 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:18000"
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21000",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22000"
}
}
//#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,27 @@
"longName": "no-restore",
"shortName": ""
},
"appHttpPort": {
"appHostHttpPort": {
"isHidden": true
},
"appHttpsPort": {
"appHostHttpsPort": {
"isHidden": true
},
"NoHttps": {
"appHostOtlpHttpPort": {
"isHidden": true
},
"appHostOtlpHttpsPort": {
"isHidden": true
},
"appHostResourceHttpPort": {
"isHidden": true
},
"appHostResourceHttpsPort": {
"isHidden": true
},
"NoHttps": {
"longName": "no-https",
"shortName": ""
}
},
"usageExamples": [ ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$schema": "https://json.schemastore.org/ide.host",
"icon": "ide/AspireEmpty.ico",
"displayOverviewPage": "0",
"disableHttpsSymbol": "NoHttps",
"unsupportedHosts": [
{
"id": "vs",
Expand Down
Loading

0 comments on commit cdb1f9d

Please sign in to comment.