Skip to content

Commit

Permalink
Closes #60
Browse files Browse the repository at this point in the history
Small refactoring.
Bump up package with vulnerability.
Remove not needed global.json file
  • Loading branch information
mtracewicz committed Mar 30, 2024
1 parent 861a7d8 commit a383ccc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 27 deletions.
14 changes: 3 additions & 11 deletions backend/src/api/Data/KeycloakJwtOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@
namespace api.Data;
public class KeycloakJwtOptions
{
public required string Issuer { get; set; }
public required string Audience { get; set; }
public required string Secret { get; set; }

[SetsRequiredMembers]
public KeycloakJwtOptions(string issuer, string audience, string secret)
{
Issuer = issuer;
Audience = audience;
Secret = secret;
}
public required string Issuer { get; init; }
public required string Audience { get; init; }
public required string Secret { get; init; }
}
10 changes: 1 addition & 9 deletions backend/src/api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,7 @@
builder.Services.AddHttpContextAccessor();
builder.Host.UseSerilog();
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseNpgsql(builder.Configuration.GetConnectionString("KSummarized")));
var keycloakJwtOptions = new KeycloakJwtOptions(
builder.Configuration.GetValue<string>("KeycloakJwt:Issuer")!,
builder.Configuration.GetValue<string>("KeycloakJwt:Audience")!,
builder.Configuration.GetValue<string>("KeycloakJwt:Secret")!
);
if(keycloakJwtOptions.Secret is null || keycloakJwtOptions.Issuer is null || keycloakJwtOptions.Audience is null)
{
throw new Exception("Can't start application without JWT options");
}
var keycloakJwtOptions = builder.Configuration.GetRequiredSection("KeycloakJwt").Get<KeycloakJwtOptions>()!;

// Create RSA key for offline validation of Keycloak token
RSA rsa = RSA.Create();
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.26.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.34.0" />
</ItemGroup>

</Project>
6 changes: 0 additions & 6 deletions global.json

This file was deleted.

0 comments on commit a383ccc

Please sign in to comment.