mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-10-06 19:22:12 +00:00
Configure local development environment
- Generalize appsettings.json by removing hardcoded credentials - Add local connection string and JWT config to appsettings.Development.json - Add EF Core Design package for running migrations locally - Seed admin user on startup in development - Skip HTTPS redirect in development for proxy compatibility - Gitignore appsettings.Development.json
This commit is contained in:
parent
a9fc4b8701
commit
0e3cb761c9
5 changed files with 50 additions and 10 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -362,3 +362,5 @@ MigrationBackup/
|
||||||
# Fody - auto-generated XML schema
|
# Fody - auto-generated XML schema
|
||||||
FodyWeavers.xsd
|
FodyWeavers.xsd
|
||||||
/SeaHavenIndustries/wwwroot/ChromeEx/Win_x64_1000083_chrome-win/chrome-win
|
/SeaHavenIndustries/wwwroot/ChromeEx/Win_x64_1000083_chrome-win/chrome-win
|
||||||
|
|
||||||
|
appsettings.Development.json
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,10 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="SendGrid" Version="9.29.3" />
|
<PackageReference Include="SendGrid" Version="9.29.3" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
<PackageReference Include="PasswordGenerator" Version="2.1.0" />
|
<PackageReference Include="PasswordGenerator" Version="2.1.0" />
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,8 @@ if (app.Environment.IsDevelopment() || app.Environment.IsProduction())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
if (!app.Environment.IsDevelopment())
|
||||||
|
app.UseHttpsRedirection();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseCors();
|
app.UseCors();
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
|
|
@ -101,4 +102,32 @@ app.UseAuthorization();
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
|
if (app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
using var scope = app.Services.CreateScope();
|
||||||
|
var userManager = scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();
|
||||||
|
var roleManager = scope.ServiceProvider.GetRequiredService<RoleManager<IdentityRole>>();
|
||||||
|
|
||||||
|
if (!await roleManager.RoleExistsAsync("Admin"))
|
||||||
|
await roleManager.CreateAsync(new IdentityRole("Admin"));
|
||||||
|
|
||||||
|
var adminEmail = "admin@seahavenind.com";
|
||||||
|
if (await userManager.FindByNameAsync(adminEmail) == null)
|
||||||
|
{
|
||||||
|
var admin = new ApplicationUser
|
||||||
|
{
|
||||||
|
UserName = adminEmail,
|
||||||
|
Email = adminEmail,
|
||||||
|
FirstName = "Admin",
|
||||||
|
LastName = "User",
|
||||||
|
EmailConfirmed = true,
|
||||||
|
UniqueName = "Active",
|
||||||
|
CreatedDate = DateTime.Now
|
||||||
|
};
|
||||||
|
var result = await userManager.CreateAsync(admin, "Admin@123");
|
||||||
|
if (result.Succeeded)
|
||||||
|
await userManager.AddToRoleAsync(admin, "Admin");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,19 @@
|
||||||
{
|
{
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"DefaultConnection": "Server=localhost,1433;Database=SeahavenIndustries;User Id=sa;Password=Local@Dev2026!;TrustServerCertificate=True;MultipleActiveResultSets=true"
|
||||||
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"SendGrid": {
|
||||||
|
"ApiKey": "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"
|
||||||
|
},
|
||||||
|
"JWT": {
|
||||||
|
"ValidAudience": "http://localhost:3000",
|
||||||
|
"ValidIssuer": "https://localhost:7195",
|
||||||
|
"Secret": "JWTAuthenticationHIGHsecuredPasswordVVVp1OH7Xzyr"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,6 @@
|
||||||
{
|
{
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
//"DefaultConnection": "Server=DESKTOP-64LC14O\SQLEXPRESS;Database=SeahavenIndustries;TrustServerCertificate=True;Trusted_Connection=True;MultipleActiveResultSets=true",
|
"DefaultConnection": ""
|
||||||
|
|
||||||
// Test database
|
|
||||||
//"DefaultConnection": "Server=SQL5112.site4now.net;Initial Catalog=db_a7141e_seahavenindustries;User Id=db_a7141e_seahavenindustries_admin;Password=Abc123!@#;MultipleActiveResultSets=true"
|
|
||||||
|
|
||||||
//Client Database
|
|
||||||
"DefaultConnection": "Server=SQL5112.site4now.net;Initial Catalog=db_a7141e_seahavenindustry;User Id=db_a7141e_seahavenindustry_admin;Password=Abc123!@#;MultipleActiveResultSets=true"
|
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
|
|
@ -15,12 +9,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"SendGrid": {
|
"SendGrid": {
|
||||||
"ApiKey": "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"
|
"ApiKey": ""
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"JWT": {
|
"JWT": {
|
||||||
"ValidAudience": "http://localhost:4200",
|
"ValidAudience": "http://localhost:4200",
|
||||||
"ValidIssuer": "http://localhost:7195",
|
"ValidIssuer": "http://localhost:7195",
|
||||||
"Secret": "JWTAuthenticationHIGHsecuredPasswordVVVp1OH7Xzyr"
|
"Secret": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue