Skip to content

Commit

Permalink
Merge pull request #169 from mark-szabo/v2.4
Browse files Browse the repository at this point in the history
v2.4.3 GitHub Actions and other fixes
  • Loading branch information
mark-szabo authored Jan 8, 2025
2 parents f849e90 + 892e0fe commit 48fa7c9
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mimosonk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
dotnet-version: ${{ env.DOTNET_CORE_VERSION }}
- name: Read version number from package.json
id: build_number
run: echo "VERSION=$(cat ${{ env.WORKING_DIRECTORY }}/ClientApp/package.json | jq '.version')" >> $GITHUB_ENV
run: echo "VERSION=$(cat ${{ env.WORKING_DIRECTORY }}/ClientApp/package.json | jq '.version')" >> "$GITHUB_OUTPUT"
- name: Create .env file with build number
run: echo "REACT_APP_BUILD_NUMBER=${{ steps.build_number.outputs.VERSION }}" > ${{ env.WORKING_DIRECTORY }}/.env
- name: Restore
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ CarWash\.PWA\.Windows/_pkginfo\.txt
TestResults/
CarWash.PWA/Properties/serviceDependencies.mimosonk.json
CarWash.Functions/Properties/serviceDependencies.func-carwash-mimosonk-prod - Zip Deploy.json
CarWash.Functions/Properties/ServiceDependencies/func-carwash-mimosonk-prod - Zip Deploy/appInsights1.arm.json
CarWash.Functions/Properties/ServiceDependencies/func-carwash-mimosonk-prod - Zip Deploy/storage1.arm.json
CarWash.Functions/Properties/ServiceDependencies/func-carwash-mimosonk-prod - Zip Deploy/

# Azure Functions artifacts
bin
Expand Down
2 changes: 2 additions & 0 deletions CarWash.Functions/NotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public static async Task SendBotReminderMessage(Reservation reservation, string
if (connectionString == null)
{
log?.LogWarning("Skipped sending bot message: ServiceBus connection string is not provided.");

return;
}

// since ServiceBusClient implements IAsyncDisposable we create it with "await using"
Expand Down
2 changes: 1 addition & 1 deletion CarWash.PWA/ClientApp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "carwash_pwa",
"version": "2.4.2",
"version": "2.4.3",
"private": true,
"description": "This app is intended to help employees working in Graphisoft park (Budapest, Hungary) reserve car washing services.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion CarWash.PWA/ClientApp/public/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ workbox.core.setCacheNameDetails({
// Don't forget to increase the revision number of index.html (aka. '/')
// as it is needed to include the newly genereted js and css files.
// Error would be thrown: Refused to execute script from '...' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
const VERSION = '2.4.2';
const VERSION = '2.4.3';
console.log(`Build: ${VERSION}`);
workbox.precaching.cleanupOutdatedCaches();
workbox.precaching.precacheAndRoute([
Expand Down
126 changes: 61 additions & 65 deletions CarWash.PWA/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

namespace CarWash.PWA
{
public class Startup
public class Startup(IConfiguration configuration, IWebHostEnvironment currentEnvironment)
{
private const string ContentSecurityPolicy = @"default-src 'self'; " +
"script-src 'self' 'unsafe-inline' 'unsafe-eval' *.msecnd.net storage.googleapis.com; " +
Expand All @@ -55,26 +55,19 @@ public class Startup
PropertyNameCaseInsensitive = true
};

public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
var config = Configuration.Get<CarWashConfiguration>();
var config = configuration.Get<CarWashConfiguration>();
if (config.Services.Count == 0)
{
config.Services = JsonSerializer.Deserialize<List<Service>>(Configuration.GetValue<string>("Services"), jsonOptions);
config.Services = JsonSerializer.Deserialize<List<Service>>(configuration.GetValue<string>("Services"), jsonOptions);
}
config.BuildNumber = Configuration.GetValue<string>("BUILD_NUMBER");
config.Version = Configuration.GetValue<string>("VERSION");
config.BuildNumber = configuration.GetValue<string>("BUILD_NUMBER");
config.Version = configuration.GetValue<string>("VERSION");

// Add application services
services.AddSingleton(Configuration);
services.AddSingleton(configuration);
services.AddSingleton(config);
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddScoped<IUsersController, UsersController>();
Expand All @@ -84,12 +77,12 @@ public void ConfigureServices(IServiceCollection services)
services.AddScoped<IBotService, BotService>();

// Add framework services
services.AddApplicationInsightsTelemetry(Configuration);
services.AddApplicationInsightsTelemetry(configuration);
services.AddApplicationInsightsTelemetryProcessor<SignalrTelemetryFilter>();
// services.AddApplicationInsightsTelemetryProcessor<ForbiddenTelemetryFilter>();

// Configure SnapshotCollector from application settings
services.Configure<SnapshotCollectorConfiguration>(Configuration.GetSection(nameof(SnapshotCollectorConfiguration)));
services.Configure<SnapshotCollectorConfiguration>(configuration.GetSection(nameof(SnapshotCollectorConfiguration)));

// Add SnapshotCollector telemetry processor.
services.AddSingleton<ITelemetryProcessorFactory>(sp => new SnapshotCollectorTelemetryProcessorFactory(sp));
Expand Down Expand Up @@ -243,66 +236,69 @@ public void ConfigureServices(IServiceCollection services)
// Configure SignalR
services.AddSignalR();

// Swagger API Documentation generator
services.AddSwaggerGen(c =>
if (currentEnvironment.IsDevelopment())
{
c.SwaggerDoc("v2", new OpenApiInfo { Title = "CarWash API", Version = "v2" });

var authority = $"{config.AzureAd.Instance}oauth2/v2.0";
c.AddSecurityDefinition("OAuth2", new OpenApiSecurityScheme
// Swagger API Documentation generator
services.AddSwaggerGen(c =>
{
Description = "OAuth2 SSO authentication.",
Type = SecuritySchemeType.OAuth2,
Flows = new OpenApiOAuthFlows
c.SwaggerDoc("v2", new OpenApiInfo { Title = "CarWash API", Version = "v2" });

var authority = $"{config.AzureAd.Instance}oauth2/v2.0";
c.AddSecurityDefinition("OAuth2", new OpenApiSecurityScheme
{
Implicit = new OpenApiOAuthFlow
Description = "OAuth2 SSO authentication.",
Type = SecuritySchemeType.OAuth2,
Flows = new OpenApiOAuthFlows
{
AuthorizationUrl = new Uri(authority + "/authorize"),
TokenUrl = new Uri(authority + "/connect/token"),
Scopes = new Dictionary<string, string>
Implicit = new OpenApiOAuthFlow
{
{ "openid","User offline" },
AuthorizationUrl = new Uri(authority + "/authorize"),
TokenUrl = new Uri(authority + "/connect/token"),
Scopes = new Dictionary<string, string>
{
{ "openid","User offline" },
}
}
}
}
});
});

c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey,
Scheme = "Bearer"
});

c.AddSecurityRequirement(new OpenApiSecurityRequirement
{
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey,
Scheme = "Bearer"
});

c.AddSecurityRequirement(new OpenApiSecurityRequirement
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
new OpenApiSecurityScheme
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
},
Scheme = "oauth2",
Name = "Bearer",
In = ParameterLocation.Header
},
Scheme = "oauth2",
Name = "Bearer",
In = ParameterLocation.Header
},
new List<string>()
new List<string>()
}
});

// Set the comments path for the Swagger JSON and UI.
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
try
{
c.IncludeXmlComments(xmlPath);
}
catch (FileNotFoundException) { }
});

// Set the comments path for the Swagger JSON and UI.
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
try
{
c.IncludeXmlComments(xmlPath);
}
catch (FileNotFoundException) { }
});
}

services.AddHealthChecks();

Expand All @@ -315,7 +311,7 @@ public void ConfigureServices(IServiceCollection services)
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider)
{
var config = Configuration.Get<CarWashConfiguration>();
var config = configuration.Get<CarWashConfiguration>();

if (env.IsDevelopment())
{
Expand Down Expand Up @@ -369,11 +365,11 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IService
endpoints.MapControllerRoute("default", "{controller}/{action=Index}/{id?}");
});

// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();

if (env.IsDevelopment())
{
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();

// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
// specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
Expand Down

0 comments on commit 48fa7c9

Please sign in to comment.