Move swagger out of development-only.

This commit is contained in:
2023-02-06 16:04:44 -06:00
parent bc07f728cf
commit 049465953c
4 changed files with 17 additions and 11 deletions

View File

@@ -30,10 +30,6 @@ public class User
public WhichLoginPlatform LoginPlatform { get; } public WhichLoginPlatform LoginPlatform { get; }
public bool IsGuest => LoginPlatform == WhichLoginPlatform.Guest;
public bool IsAdmin => LoginPlatform == WhichLoginPlatform.Microsoft && Id == "Hauth@live.com";
public User(string id, string displayName, WhichLoginPlatform platform) public User(string id, string displayName, WhichLoginPlatform platform)
{ {
Id = id; Id = id;

View File

@@ -48,6 +48,9 @@ namespace Shogi.Api
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment()) if (app.Environment.IsDevelopment())
{ {
app.UseHttpsRedirection(); // Apache handles HTTPS in production.
}
app.UseSwagger(); app.UseSwagger();
app.UseSwaggerUI(options => app.UseSwaggerUI(options =>
{ {
@@ -55,8 +58,6 @@ namespace Shogi.Api
options.OAuthConfigObject.ClientId = builder.Configuration["AzureAd:SwaggerUIClientId"]; options.OAuthConfigObject.ClientId = builder.Configuration["AzureAd:SwaggerUIClientId"];
options.OAuthConfigObject.UsePkceWithAuthorizationCodeGrant = true; options.OAuthConfigObject.UsePkceWithAuthorizationCodeGrant = true;
}); });
app.UseHttpsRedirection(); // Apache handles HTTPS in production.
}
UseCorsAndWebSockets(app, allowedOrigins); UseCorsAndWebSockets(app, allowedOrigins);
@@ -211,6 +212,7 @@ namespace Shogi.Api
BearerFormat = "JWT", BearerFormat = "JWT",
In = ParameterLocation.Header, In = ParameterLocation.Header,
}); });
// This adds the lock symbol next to every route in SwaggerUI. // This adds the lock symbol next to every route in SwaggerUI.
options.AddSecurityRequirement(new OpenApiSecurityRequirement options.AddSecurityRequirement(new OpenApiSecurityRequirement
{ {

View File

@@ -0,0 +1,7 @@
-- Create a user named Shogi.Api
-- Create a role and grant execute permission to that role
--CREATE ROLE db_executor
--GRANT EXECUTE To db_executor
-- Give Shogi.Api user permission to db_executor, db_datareader, db_datawriter

View File

@@ -95,5 +95,6 @@
<ItemGroup> <ItemGroup>
<None Include="Post Deployment\Scripts\PopulatePieces.sql" /> <None Include="Post Deployment\Scripts\PopulatePieces.sql" />
<None Include="Post Deployment\Scripts\EnableSnapshotIsolationLevel.sql" /> <None Include="Post Deployment\Scripts\EnableSnapshotIsolationLevel.sql" />
<None Include="FirstTimeSetup.sql" />
</ItemGroup> </ItemGroup>
</Project> </Project>