mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 02:39:03 +00:00
Add JWT_SECRET environment variable to Docker configurations and update JwtService to use it
This commit is contained in:
@@ -79,6 +79,7 @@ services:
|
||||
ASPNETCORE_URLS: "http://0.0.0.0:8080"
|
||||
DOTNET_RUNNING_IN_CONTAINER: "true"
|
||||
DB_CONNECTION_STRING: "${DB_CONNECTION_STRING}"
|
||||
JWT_SECRET: "${JWT_SECRET}"
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- devnet
|
||||
|
||||
@@ -59,6 +59,7 @@ services:
|
||||
DOTNET_RUNNING_IN_CONTAINER: "true"
|
||||
MASTER_DB_CONNECTION_STRING: "${MASTER_DB_CONNECTION_STRING}"
|
||||
DB_CONNECTION_STRING: "${DB_CONNECTION_STRING}"
|
||||
JWT_SECRET: "${JWT_SECRET}"
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- prodnet
|
||||
|
||||
@@ -73,6 +73,7 @@ services:
|
||||
environment:
|
||||
DOTNET_RUNNING_IN_CONTAINER: "true"
|
||||
DB_CONNECTION_STRING: "${TEST_DB_CONNECTION_STRING}"
|
||||
JWT_SECRET: "${JWT_SECRET}"
|
||||
volumes:
|
||||
- ./test-results:/app/test-results
|
||||
restart: "no"
|
||||
@@ -93,6 +94,7 @@ services:
|
||||
environment:
|
||||
DOTNET_RUNNING_IN_CONTAINER: "true"
|
||||
DB_CONNECTION_STRING: "${TEST_DB_CONNECTION_STRING}"
|
||||
JWT_SECRET: "${JWT_SECRET}"
|
||||
volumes:
|
||||
- ./test-results:/app/test-results
|
||||
restart: "no"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
@@ -6,10 +7,9 @@ using Microsoft.IdentityModel.Tokens;
|
||||
using JwtRegisteredClaimNames = System.IdentityModel.Tokens.Jwt.JwtRegisteredClaimNames;
|
||||
|
||||
namespace ServiceCore.Services;
|
||||
public class JwtService(IConfiguration config) : IJwtService
|
||||
public class JwtService : IJwtService
|
||||
{
|
||||
// private readonly string? _secret = config["Jwt:Secret"];
|
||||
private readonly string? _secret = "128490218jfklsdajfdsa90f8sd0fid0safasr31jl2k1j4AFSDR!@#$fdsafjdslajfl";
|
||||
private readonly string? _secret = Environment.GetEnvironmentVariable("JWT_SECRET");
|
||||
public string GenerateJwt(Guid userId, string username, DateTime expiry)
|
||||
{
|
||||
var handler = new JsonWebTokenHandler();
|
||||
|
||||
Reference in New Issue
Block a user