update 20241121
This commit is contained in:
@@ -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, "");
|
||||
|
||||
Reference in New Issue
Block a user