update 20241121

This commit is contained in:
Stefan Hutter
2024-11-21 19:32:26 +01:00
parent d3bf9458eb
commit 6bdbc4173e
56 changed files with 362 additions and 168 deletions

View File

@@ -14,6 +14,8 @@ using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Configuration;
using System.Reflection;
using System.Collections.Specialized;
namespace SecuringWebApiUsingApiKey.Middleware
{
@@ -126,12 +128,21 @@ namespace SecuringWebApiUsingApiKey.Middleware
{ return true; }
else return false;
}
public static string[] get_apikeys()
{
string keyfile = GetValue("APIKeys").ToString();
string fileinahlt = System.IO.File.ReadAllText(keyfile).Replace(System.Environment.NewLine,"");
string decrypted = StringCipher.Decrypt(fileinahlt, "PBod8b%s@c9ib7Lws#na5sGM2trugrx3h!oyB^y!Bc%fHEYUT3QvTVr6sAaAr9FoQWzb");
return decrypted.Split(',');
}
public static Boolean Authorized(HttpRequestMessage request, string function)
{
if (GetValue("AuthCheck") == "Yes")
{
apikeys = GetValue("APIKeys").ToString().Split(',');
apikeys = get_apikeys();
// apikeys = GetValue("APIKeys").ToString().Split(',');
for (int i = 0; i < apikeys.Length; i++)
{
apikeys[i] = apikeys[i].Replace(Environment.NewLine, "");