asp.net mvc - How would authentication and authorization be implemented using RavenDb in an MVC app? -
while i'm used using standard asp.net membership provider new mvc web applications, i've been getting kick out of using ravendb lately still don't believe have grasp on best practice implementing user authentication , role authorisation.
the code have replaced register , logon methods in accountcontroller looks following:
[httppost] public actionresult register(registermodel model) { if (modelstate.isvalid) { using (idocumentsession session = datadocumentstore.instance.opensession()) { session.store(new authenticationuser { name = email, id = string.format("raven/users/{0}", name), alloweddatabases = new[] { "*" } }.setpassword(password)); session.savechanges(); formsauthentication.setauthcookie(model.username, createpersistentcookie: false); // ...etc. etc. [httppost] public jsonresult jsonlogon(logonmodel model, string returnurl) { if (modelstate.isvalid) { using (idocumentsession session = datadocumentstore.instance.opensession()) { book ok = session.load<authenticationuser>(string.format("raven/users/{0}", username)).validatepassword(password); formsauthentication.setauthcookie(model.username, model.rememberme); // etc... i've seen ravendb membership provider code number of people have referenced in similar posts or questions, there seems number of people consider on top , leveraging inefficient api data store doesn't need of what's provided within it.
so best architectural / design strategy ravendb authentication (not oauth, forms authentication) , barking right tree?
i think there few parts problem. first, mvc project's perspective, want use work authorizationattribute. not require using membershipprovider per se, rather stuffing appropriate iprincipal httpcontext.current.user attributes @ authorize things.
from http perspective, taking advantage of existing forms authentication infrastructure makes ton of sense -- solves of sticky security issues should not solve , flexible in terms of working provide.
from there gist of question -- how want authentication system data perspective. think tactical call -- apps might make sense use membershipprovider style model. if had app user centric storing lots of user data consider rolling custom user store based around requirements. if using authentication bundle glom onto extent well. don't think there hard , fast rule @ point -- makes sense app.
one thing should not use authenticationuser above -- meant database system users. in sql server terms making every user in app sql user , authenticating against that. how old intranet products used work world has moved past now.
Comments
Post a Comment