Env swap #21

Merged
danieljsummers merged 30 commits from env-swap into help-wanted 2021-08-10 03:23:50 +00:00
3 changed files with 37 additions and 7 deletions
Showing only changes of commit 37b8f4adb3 - Show all commits

View File

@ -17,8 +17,13 @@
<ProjectReference Include="..\Domain\Domain.fsproj" /> <ProjectReference Include="..\Domain\Domain.fsproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include=".\wwwroot" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Giraffe" Version="5.0.0" /> <PackageReference Include="Giraffe" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.8" />
<PackageReference Include="Microsoft.FSharpLu.Json" Version="0.11.7" /> <PackageReference Include="Microsoft.FSharpLu.Json" Version="0.11.7" />
<PackageReference Include="NodaTime.Serialization.JsonNet" Version="3.0.0" /> <PackageReference Include="NodaTime.Serialization.JsonNet" Version="3.0.0" />
<PackageReference Include="Polly" Version="7.2.2" /> <PackageReference Include="Polly" Version="7.2.2" />

View File

@ -15,14 +15,19 @@ let configureApp (app : IApplicationBuilder) =
.UseCors(fun p -> p.AllowAnyOrigin().AllowAnyHeader() |> ignore) .UseCors(fun p -> p.AllowAnyOrigin().AllowAnyHeader() |> ignore)
.UseStaticFiles() .UseStaticFiles()
.UseRouting() .UseRouting()
.UseAuthentication()
.UseAuthorization()
.UseEndpoints(fun e -> .UseEndpoints(fun e ->
e.MapGiraffeEndpoints Handlers.allEndpoints e.MapGiraffeEndpoints Handlers.allEndpoints
e.MapFallbackToFile "index.html" |> ignore) e.MapFallbackToFile "index.html" |> ignore)
|> ignore |> ignore
open NodaTime open NodaTime
open Microsoft.AspNetCore.Authentication.JwtBearer
open Microsoft.Extensions.Configuration open Microsoft.Extensions.Configuration
open Microsoft.Extensions.Logging open Microsoft.Extensions.Logging
open Microsoft.IdentityModel.Tokens
open System.Text
/// Configure dependency injection /// Configure dependency injection
let configureServices (svc : IServiceCollection) = let configureServices (svc : IServiceCollection) =
@ -30,12 +35,31 @@ let configureServices (svc : IServiceCollection) =
svc.AddSingleton<IClock> SystemClock.Instance |> ignore svc.AddSingleton<IClock> SystemClock.Instance |> ignore
svc.AddLogging () |> ignore svc.AddLogging () |> ignore
svc.AddCors () |> ignore svc.AddCors () |> ignore
let svcs = svc.BuildServiceProvider()
let cfg = svcs.GetRequiredService<IConfiguration>().GetSection "Rethink" let svcs = svc.BuildServiceProvider ()
let cfg = svcs.GetRequiredService<IConfiguration> ()
svc.AddAuthentication(fun o ->
o.DefaultAuthenticateScheme <- JwtBearerDefaults.AuthenticationScheme
o.DefaultChallengeScheme <- JwtBearerDefaults.AuthenticationScheme
o.DefaultScheme <- JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(fun o ->
o.RequireHttpsMetadata <- false
o.TokenValidationParameters <- TokenValidationParameters (
ValidateIssuer = true,
ValidateAudience = true,
ValidAudience = "https://noagendacareers.com",
ValidIssuer = "https://noagendacareers.com",
IssuerSigningKey = SymmetricSecurityKey (
Encoding.UTF8.GetBytes (cfg.GetSection("Auth").["ServerSecret"]))))
|> ignore
svc.AddAuthorization () |> ignore
let dbCfg = cfg.GetSection "Rethink"
let log = svcs.GetRequiredService<ILoggerFactory>().CreateLogger (nameof Data.Startup) let log = svcs.GetRequiredService<ILoggerFactory>().CreateLogger (nameof Data.Startup)
let conn = Data.Startup.createConnection cfg log let conn = Data.Startup.createConnection dbCfg log
svc.AddSingleton conn |> ignore svc.AddSingleton conn |> ignore
Data.Startup.establishEnvironment cfg log conn |> Data.awaitIgnore Data.Startup.establishEnvironment dbCfg log conn |> Data.awaitIgnore
[<EntryPoint>] [<EntryPoint>]
let main _ = let main _ =

View File

@ -1,11 +1,12 @@
{ {
"name": "jobs-jobs-jobs", "name": "jobs-jobs-jobs",
"version": "0.1.0", "version": "1.0.1",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
"build": "vue-cli-service build --mode development", "build": "vue-cli-service build --mode development",
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint",
"apiserve": "vue-cli-service build --mode development && cd ../Api && dotnet run -c Debug"
}, },
"dependencies": { "dependencies": {
"@mdi/font": "5.9.55", "@mdi/font": "5.9.55",