I have a small C# MVC5 app that I'm building and am ready to add the user security module to it. (previously I just created a session variable for testing roles) However, my security needs do not fit any of the prebuilt security modules that I've seen, i.e. SimpleMembership etc.
Here's a summary of my situation and needs:
No passwords -- username/password auth is not allowed
Users are authenticated at the web server level using a smartcard with client certificate -- I do not manage the server and will never see their card
IIS populates the Request.ClientCertificate and a few others, this is all I have access to
My app will have dedicated user accounts -- not using Windows auth etc -- so more like a username/password system without ever entering a username or password
The server is authenticating them to access the server by using some form of Windows auth with their smart card certificate, but I can't, I just have to accept the certificate loaded into the Request collection
User tables are stored in SQL Server (for now...)
Prefer not to use EntityFramework, since all app data comes from an Oracle DB and trying to get approval to move authentication/authorization tables into it and eliminate working from two DBs, and EF for Oracle doesn't work in our environment, so I'm using OleDb instead :(
What is the best way to go about implementing a scheme like this? What I've started doing is building three tables -- Users, Roles, and UserRoles -- and the Users table holds a copy of the (string) ClientCertificate. Users who come in would be authenticated into the app by pulling the Request.ClientCertificate and looking for a matching Users record, then getting the list of roles from UserRoles. A user object would be stored in the session containing the user and role info, and attributes would be used on controllers to control access by requiring certain roles.
(we have another app that uses this basic approach, but it is J2EE on Linux so I can't just reuse its code)
However, I've also started reading about IIdentity and IPrincipal but I'm not 100% clear on whether or not that is something I can use. Clearly I'd prefer to use a security model designed by experts. So should I build my authentication system using custom classes that inherit from IIdentity and IPrincipal? Or is there some other approach I should use?
It is entirely possible that something like SimpleMembership can be customized to meet my needs, but if so I'm not aware of it.
Thanks for the advice, much appreciated.