Environemnts refactor
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -484,6 +484,8 @@ yarn-error.log
|
|||||||
##
|
##
|
||||||
**/appsettings.Development.json
|
**/appsettings.Development.json
|
||||||
**/appsettings.Local.json
|
**/appsettings.Local.json
|
||||||
|
**/client_secrets.Development.json
|
||||||
|
**/client
|
||||||
*.p12
|
*.p12
|
||||||
*.key
|
*.key
|
||||||
*.pem
|
*.pem
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ builder.Services.AddAuthentication(options =>
|
|||||||
ValidateAudience = false,
|
ValidateAudience = false,
|
||||||
ValidateLifetime = true,
|
ValidateLifetime = true,
|
||||||
ValidateIssuerSigningKey = true,
|
ValidateIssuerSigningKey = true,
|
||||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Secret"]!))
|
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["JwtSettings:SecurityKey"]!))
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
47
src/Backend/DiunaBI.API/appsettings.Production.json
Normal file
47
src/Backend/DiunaBI.API/appsettings.Production.json
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Serilog": {
|
||||||
|
"MinimumLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Override": {
|
||||||
|
"Microsoft.AspNetCore": "Warning",
|
||||||
|
"Microsoft.EntityFrameworkCore.Database.Command": "Warning",
|
||||||
|
"Microsoft.EntityFrameworkCore.Infrastructure": "Warning",
|
||||||
|
"System.Net.Http.HttpClient": "Warning",
|
||||||
|
"Google.Apis": "Warning",
|
||||||
|
"DiunaBI.Core.Services.PluginManager": "Information"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"WriteTo": [
|
||||||
|
{
|
||||||
|
"Name": "Console",
|
||||||
|
"Args": {
|
||||||
|
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "File",
|
||||||
|
"Args": {
|
||||||
|
"path": "/var/log/diunabi/app-.log",
|
||||||
|
"rollingInterval": "Day",
|
||||||
|
"retainedFileCountLimit": 30,
|
||||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext} {Message:lj} {Properties:j}{NewLine}{Exception}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Enrich": ["FromLogContext", "WithMachineName", "WithThreadId"]
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*",
|
||||||
|
"Kestrel": {
|
||||||
|
"Endpoints": {
|
||||||
|
"Http": {
|
||||||
|
"Url": "http://0.0.0.0:7143"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"PONG": "#{PING}#",
|
|
||||||
"app-version": "#{buildId}#",
|
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
@@ -25,47 +24,9 @@
|
|||||||
"Args": {
|
"Args": {
|
||||||
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
|
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "File",
|
|
||||||
"Args": {
|
|
||||||
"path": "/var/log/diunabi/app-.log",
|
|
||||||
"rollingInterval": "Day",
|
|
||||||
"retainedFileCountLimit": 30,
|
|
||||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext} {Message:lj} {Properties:j}{NewLine}{Exception}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "Seq",
|
|
||||||
"Args": {
|
|
||||||
"serverUrl": "http://localhost:5341",
|
|
||||||
"restrictedToMinimumLevel": "Information"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Enrich": ["FromLogContext", "WithMachineName", "WithThreadId"]
|
"Enrich": ["FromLogContext", "WithMachineName", "WithThreadId"]
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*"
|
||||||
"ConnectionStrings": {
|
|
||||||
"SQLDatabase": "#{db-connection-string}#"
|
|
||||||
},
|
|
||||||
"InstanceName": "#{app-environment}#",
|
|
||||||
"GoogleAuth": {
|
|
||||||
"ClientId": "#{google-backend-login-client-id}#"
|
|
||||||
},
|
|
||||||
"Secret": "#{google-backend-login-secret}#",
|
|
||||||
"apiKey": "#{api-key}#",
|
|
||||||
"powerBI-user": "#{powerBI-user}#",
|
|
||||||
"powerBI-pass": "#{powerBI-pass}#",
|
|
||||||
"morska-user": "#{morska-user}#",
|
|
||||||
"morska-pass": "#{morska-pass}#",
|
|
||||||
"exportDirectory": "#{export-directory}#",
|
|
||||||
"apiLocalUrl": "#{api-local-url}#",
|
|
||||||
"Kestrel": {
|
|
||||||
"Endpoints": {
|
|
||||||
"Http": {
|
|
||||||
"Url": "http://#{api-local-url}#"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "service_account",
|
|
||||||
"project_id": "#{google-backend-project-id}#",
|
|
||||||
"private_key_id": "#{google-backend-private-key-id}#",
|
|
||||||
"private_key": "#{google-backend-private-key}#",
|
|
||||||
"client_email": "#{google-backend-client-email}#",
|
|
||||||
"client_id": "#{google-backend-client-id}#",
|
|
||||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
|
||||||
"token_uri": "https://oauth2.googleapis.com/token",
|
|
||||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
|
||||||
"client_x509_cert_url": "#{google-backend-client-cert-url}#"
|
|
||||||
}
|
|
||||||
@@ -24,13 +24,15 @@ public class GoogleDriveHelper
|
|||||||
}
|
}
|
||||||
private static GoogleCredential GetCredentialsFromFile()
|
private static GoogleCredential GetCredentialsFromFile()
|
||||||
{
|
{
|
||||||
// ReSharper disable once RedundantAssignment
|
|
||||||
var fileName = "client_secrets.json";
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
fileName = "client_secrets.Development.json";
|
using var stream = new FileStream("client_secrets.Development.json", FileMode.Open, FileAccess.Read);
|
||||||
|
return GoogleCredential.FromStream(stream).CreateScoped(Scopes);
|
||||||
|
#else
|
||||||
|
var json = Environment.GetEnvironmentVariable("GOOGLE_SERVICE_ACCOUNT_JSON");
|
||||||
|
if (string.IsNullOrWhiteSpace(json))
|
||||||
|
throw new InvalidOperationException("GOOGLE_SERVICE_ACCOUNT_JSON environment variable is not set.");
|
||||||
|
json = json.Replace("\\n", "\n");
|
||||||
|
return GoogleCredential.FromJson(json).CreateScoped(Scopes);
|
||||||
#endif
|
#endif
|
||||||
using var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
|
|
||||||
var credential = GoogleCredential.FromStream(stream).CreateScoped(Scopes);
|
|
||||||
return credential;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,12 +24,15 @@ public class GoogleSheetsHelper
|
|||||||
}
|
}
|
||||||
private static GoogleCredential GetCredentialsFromFile()
|
private static GoogleCredential GetCredentialsFromFile()
|
||||||
{
|
{
|
||||||
var fileName = "client_secrets.json";
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
fileName = "client_secrets.Development.json";
|
using var stream = new FileStream("client_secrets.Development.json", FileMode.Open, FileAccess.Read);
|
||||||
|
return GoogleCredential.FromStream(stream).CreateScoped(Scopes);
|
||||||
|
#else
|
||||||
|
var json = Environment.GetEnvironmentVariable("GOOGLE_SERVICE_ACCOUNT_JSON");
|
||||||
|
if (string.IsNullOrWhiteSpace(json))
|
||||||
|
throw new InvalidOperationException("GOOGLE_SERVICE_ACCOUNT_JSON environment variable is not set.");
|
||||||
|
json = json.Replace("\\n", "\n");
|
||||||
|
return GoogleCredential.FromJson(json).CreateScoped(Scopes);
|
||||||
#endif
|
#endif
|
||||||
using var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
|
|
||||||
var credential = GoogleCredential.FromStream(stream).CreateScoped(Scopes);
|
|
||||||
return credential;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,12 +6,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"ApiSettings": {
|
|
||||||
"BaseUrl": "#{api-base-url}#"
|
|
||||||
},
|
|
||||||
"GoogleAuth": {
|
|
||||||
"ClientId": "#{google-auth-client-id}#"
|
|
||||||
},
|
|
||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
|
|||||||
10
src/Backend/DiunaBI.UI.Web/appsettings.json
Normal file
10
src/Backend/DiunaBI.UI.Web/appsettings.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user