WebService Security : Filter clients in a WebService scenario using an encrypted storage
(Pseudo Code Mode ON)
[WebServiceDescription(=Somethingwhatever)]
public MySuperWebMethod
{
// (ASP.NET Tip) Use the Request object using Context
if (ShiedObject.IsClientAllowedToCall(Request.UserHostAddress))
{
// Where isClientAllowedToCall is a method of the ShieldObjectClass.
// IsClientAllowed implement a very basic streamreader function to read
// the content of a specific .txt file located somewhere in a private storage.
// This file(which could be encrypted) contains a whitelist
// of trusted ips.
// While looping using a "line by line pattern" if line match the current
// client's ip then break and return true;
// If not keep reading untill the end of the file and if there is not matches
// return false;
// If you reach this line you are allowed to call this "private" method
return HelloWorld();
}
else
{
// Cheers..
throw new YouAreNotAllowedToStayHereException();
}
}