public static bool IsResourceAccessible(string resource)
{
// Check if the resource has a role-based access restriction on it.
foreach (KeyValuePair<string, string> inclusion in s_includedResources)
{
foreach (string item in inclusion.Key.Split(','))
{
if (IsRegexMatch(item.Trim(), resource))
{
// Allow security to be implemented inside the resource.
if (string.IsNullOrEmpty(inclusion.Value))
return true;
// Check resource role requirements against user's role subscription.
return Thread.CurrentPrincipal.IsInRole(inclusion.Value);
}
}
}
return false;
}