API Key hinterlegt
This commit is contained in:
@@ -248,6 +248,8 @@
|
||||
<!-- <> <> <> Appsettings <> <> <> -->
|
||||
<appSettings>
|
||||
<add key="AdminServiceIPAddress" value="::1" />
|
||||
<add key="AdminServiceAPIKey" value="HasteGedachteWa" />
|
||||
|
||||
<add key="SendMailOnError" value="false" />
|
||||
<add key="SmptServer" value="mail.ownsoft.de" />
|
||||
<add key="SmtpUser" value="bewoplaner.support@ownsoft.de" />
|
||||
|
||||
@@ -29,6 +29,19 @@ namespace BeWo.Service.ServiceBehavior
|
||||
throw new UnauthorizedAccessException($"Zugriff verweigert. Remote IP ({remoteIP ?? "Unbekannt"}) ist nicht erlaubt.");
|
||||
}
|
||||
|
||||
// Hole erlaubten API Key aus den appSettings
|
||||
string allowedApikey = ConfigurationManager.AppSettings["AdminServiceIPAddress"];
|
||||
|
||||
// Extrahiert den API Key von Remote
|
||||
var prop = (HttpRequestMessageProperty)request.Properties[HttpRequestMessageProperty.Name];
|
||||
var remoteApikey = prop?.Headers["AdminServiceAPIKey"];
|
||||
|
||||
// Vergleicht die API Keys
|
||||
if(remoteApikey == null || !string.Equals(remoteApikey, allowedApikey, StringComparison.Ordinal))
|
||||
{
|
||||
throw new UnauthorizedAccessException($"Zugriff verweigert. API Key ({remoteApikey ?? "Unbekannt"}) ist nicht erlaubt.");
|
||||
}
|
||||
|
||||
return null; // Keine Zustandsinformationen erforderlich
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user