Web.Secrets.config -> eigene Config, welche nicht ins git kommt. Anleitung unter Web.Secrets.config.template
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,6 +5,7 @@ DebugConfig.txt
|
||||
Host/Multitenancy/demo.config
|
||||
*.log.txt
|
||||
*temp.txt
|
||||
*.Secrets.config
|
||||
|
||||
# Folder
|
||||
bin[Rr]elease/
|
||||
|
||||
@@ -457,6 +457,8 @@
|
||||
<Content Include="Scripts\jquery-3.7.1.slim.min.map" />
|
||||
<Content Include="Scripts\jquery-3.7.1.min.map" />
|
||||
<Content Include="Scripts\jquery.mobile-1.4.5.min.map" />
|
||||
<None Include="Web.Secrets.config.template" />
|
||||
<None Include="Web.Secrets.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Admin.aspx.cs">
|
||||
|
||||
10
Host/Web.Secrets.config.template
Normal file
10
Host/Web.Secrets.config.template
Normal file
@@ -0,0 +1,10 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Installation:
|
||||
// Einfach diese Datei kopieren und den Kommentar hier oben entfernen.
|
||||
// Ggf. um fehlende API Keys ergänzen
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
<appSettings>
|
||||
<add key="OpenWebUIKey" value=""/>
|
||||
</appSettings>
|
||||
@@ -307,7 +307,6 @@
|
||||
<add key="SendMailModuleGkvReceiver" value="dakota.exchange@ownsoft.de" />
|
||||
|
||||
<add key="OpenWebUIUrl" value="https://owui1.ownsoft.de/"/>
|
||||
<add key="OpenWebUIKey" value="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjMyNzJlZjc5LWRmZjEtNDdjYS05NWNlLWZhNjk1ZDdjZGQ4NCJ9.mhQZvSx_mY18J9nHUDTd36wWhDAOrzzlfG9FOS5MeSM"/>
|
||||
</appSettings>
|
||||
<!-- <> <> <> Appsettings <> <> <> -->
|
||||
<devExpress>
|
||||
|
||||
31
Service/Core/MergedConfig.cs
Normal file
31
Service/Core/MergedConfig.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
|
||||
namespace BeWo.Service.Core
|
||||
{
|
||||
public static class MergedConfig
|
||||
{
|
||||
public static string GetSetting(string key)
|
||||
{
|
||||
// 1. Versuche, aus AppSettings.local.config zu lesen
|
||||
var localConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Web.Secrets.config");
|
||||
if (File.Exists(localConfigPath))
|
||||
{
|
||||
var xml = new XmlDocument();
|
||||
xml.Load(localConfigPath);
|
||||
var node = xml.SelectSingleNode($"/appSettings/add[@key='{key}']");
|
||||
if (node is XmlElement element)
|
||||
return element.GetAttribute("value");
|
||||
}
|
||||
|
||||
// 2. Fallback: Standard-AppSettings
|
||||
return ConfigurationManager.AppSettings[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,6 +230,7 @@
|
||||
<Compile Include="Core\DiamantExporter.cs" />
|
||||
<Compile Include="Core\ExcelDownload.cs" />
|
||||
<Compile Include="Core\FileAttachmentUtils.cs" />
|
||||
<Compile Include="Core\MergedConfig.cs" />
|
||||
<Compile Include="Core\ServiceLogic.cs" />
|
||||
<Compile Include="Core\SettingsLogic.cs" />
|
||||
<Compile Include="Core\Utils.cs" />
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace BeWo.Service.ServiceProxy
|
||||
|
||||
protected override string getKey()
|
||||
{
|
||||
var key = ConfigurationManager.AppSettings["OpenWebUIKey"];
|
||||
var key = Core.MergedConfig.GetSetting("OpenWebUIKey");
|
||||
|
||||
if (string.IsNullOrEmpty(key))
|
||||
throw new InvalidOperationException("OpenWebUIKey is missing");
|
||||
|
||||
Reference in New Issue
Block a user