I've seen a number of examples on securing an MVC application with tokens, roleprovider and membershipprovider but none quite fit my scenario. Here's my setup..
Here's what I'm asking.. How do I validate basic authentication current user against "Admins" from my AdminUsers sql table and then only allow these folks access to my admin area?
Thanks for your time, Chris
If you're not going to rely on membership or roles you could always write a custom implementation of the AuthorizeAttribute
that checks the user against the database.
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public class AdminOnlyAttribute : AuthorizeAttribute
{
public AdminOnlyAttribute()
{
}
public override void OnAuthorization(AuthorizationContext filterContext)
{
if (!User not in Admin table)
{
throw new UnauthorizedAccessException();
}
base.OnAuthorization(filterContext);
}
}
Or something of the sort. Then of course:
[AdminOnly]
public class AdminController : Controller
{
// ...
}